Merge pull request #52 from danielyxie/dev

Dev v0.20.1
This commit is contained in:
danielyxie 2017-06-08 15:20:33 -05:00 committed by GitHub
commit 5f5db0754d
12 changed files with 302 additions and 64 deletions

@ -297,3 +297,7 @@
text-decoration: none; text-decoration: none;
cursor: pointer; cursor: pointer;
} }
#import-game-file-selector {
display:none;
}

@ -749,6 +749,9 @@
<br> <br>
<a id="changelog-link" class="a-link-button" style="display:block;"> Changelog </a> <a id="changelog-link" class="a-link-button" style="display:block;"> Changelog </a>
<a id="save-game-link" class="a-link-button" style="display:block;"> Save Game </a> <a id="save-game-link" class="a-link-button" style="display:block;"> Save Game </a>
<a id="export-game-link" class="a-link-button" style="display:block;"> (BETA) Export Game </a>
<input type="file" id="import-game-file-selector" name="file"/>
<a id="import-game-link" class="a-link-button" style="display:block;" onclick="saveObject.importGame();"> (BETA) Import Game </a>
<a id="delete-game-link" class="a-link-button" style="display:block;"> Delete Game </a> <a id="delete-game-link" class="a-link-button" style="display:block;"> Delete Game </a>
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;"> <a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;">
(DEBUG) Delete Active Scripts (DEBUG) Delete Active Scripts

@ -1,5 +1,5 @@
CONSTANTS = { CONSTANTS = {
Version: "0.20.0", Version: "0.20.1",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -535,6 +535,13 @@ CONSTANTS = {
"RAM Upgrades on your home computer", "RAM Upgrades on your home computer",
Changelog: Changelog:
"v0.20.1<br>" +
"-Fixed bug where sometimes scripts would crash without showing the error<br>" +
"-Added Deepscan programs to Dark Web<br>" +
"-Declining a faction invite will stop you from receiving invitations from that faction for the rest of the run<br>" +
"-(BETA) Added functionality to export/import saves. WARNING This is only lightly tested. You cannot choose where to save your file " +
"it just goes to the default save location. Also I have no idea what will happen if you try to import a file " +
"that is not a valid save. I will address these in later updates<br><br>" +
"v0.20.0<br>" + "v0.20.0<br>" +
"-Refactored Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " + "-Refactored Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " +
"such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " + "such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " +
@ -645,6 +652,13 @@ CONSTANTS = {
"-You can now see what an Augmentation does and its price even while its locked<br><br>", "-You can now see what an Augmentation does and its price even while its locked<br><br>",
LatestUpdate: LatestUpdate:
"v0.20.1<br>" +
"-Fixed bug where sometimes scripts would crash without showing the error<br>" +
"-Added Deepscan programs to Dark Web<br>" +
"-Declining a faction invite will stop you from receiving invitations from that faction for the rest of the run<br>" +
"-(BETA) Added functionality to export/import saves. WARNING This is only lightly tested. You cannot choose where to save your file " +
"it just goes to the default save location. Also I have no idea what will happen if you try to import a file " +
"that is not a valid save. I will address these in later updates<br><br>" +
"v0.20.0<br>" + "v0.20.0<br>" +
"-Refactored Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " + "-Refactored Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " +
"such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " + "such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " +

@ -47,7 +47,7 @@ listAllDarkwebItems = function() {
} }
buyDarkwebItem = function(itemName) { buyDarkwebItem = function(itemName) {
if (itemName.toLowerCase() == "brutessh.exe") { if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram); var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
@ -57,7 +57,7 @@ buyDarkwebItem = function(itemName) {
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
} }
} else if (itemName.toLowerCase() == "ftpcrack.exe") { } else if (itemName.toLowerCase() == Programs.FTPCrackProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram); var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
@ -67,7 +67,7 @@ buyDarkwebItem = function(itemName) {
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
} }
} else if (itemName.toLowerCase() == "relaysmtp.exe") { } else if (itemName.toLowerCase() == Programs.RelaySMTPProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram); var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
@ -77,7 +77,7 @@ buyDarkwebItem = function(itemName) {
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
} }
} else if (itemName.toLowerCase() == "httpworm.exe") { } else if (itemName.toLowerCase() == Programs.HTTPWormProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram); var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
@ -87,7 +87,7 @@ buyDarkwebItem = function(itemName) {
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
} }
} else if (itemName.toLowerCase() == "sqlinject.exe") { } else if (itemName.toLowerCase() == Programs.SQLInjectProgram.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram); var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);
if (price > 0 && Player.money >= price) { if (price > 0 && Player.money >= price) {
Player.loseMoney(price); Player.loseMoney(price);
@ -97,6 +97,26 @@ buyDarkwebItem = function(itemName) {
} else { } else {
post("Not enough money to purchase " + itemName); post("Not enough money to purchase " + itemName);
} }
} else if (itemName.toLowerCase() == Programs.DeepscanV1.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);
if (price > 0 && Player.money >= price) {
Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV1);
post("You have purchased the DeepscanV1.exe program. The new program " +
"can be found on your home computer.");
} else {
post("Not enough money to purchase " + itemName);
}
} else if (itemName.toLowerCase() == Programs.DeepscanV2.toLowerCase()) {
var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);
if (price > 0 && Player.money >= price) {
Player.loseMoney(price);
Player.getHomeComputer().programs.push(Programs.DeepscanV2);
post("You have purchased the DeepscanV2.exe program. The new program " +
"can be found on your home computer.");
} else {
post("Not enough money to purchase " + itemName);
}
} else { } else {
post("Unrecognized item"); post("Unrecognized item");
} }
@ -129,4 +149,6 @@ DarkWebItems = {
RelaySMTPProgram: Programs.RelaySMTPProgram + " - $5,000,000 - Opens up SMTP Ports", RelaySMTPProgram: Programs.RelaySMTPProgram + " - $5,000,000 - Opens up SMTP Ports",
HTTPWormProgram: Programs.HTTPWormProgram + " - $30,000,000 - Opens up HTTP Ports", HTTPWormProgram: Programs.HTTPWormProgram + " - $30,000,000 - Opens up HTTP Ports",
SQLInjectProgram: Programs.SQLInjectProgram + " - $250,000,000 - Opens up SQL Ports", SQLInjectProgram: Programs.SQLInjectProgram + " - $250,000,000 - Opens up SQL Ports",
DeepScanV1Program: Programs.DeepscanV1 + " - $500,000 - Enables 'scan-analyze' with a depth up to 5",
DeepScanV2Program: Programs.DeepscanV2 + " - $25,000,000 - Enables 'scan-analyze' with a depth up to 10",
} }

@ -25,6 +25,7 @@ function Faction(name) {
this.isMember = false; //Whether player is member this.isMember = false; //Whether player is member
this.isBanned = false; //Whether or not player is banned from joining this faction this.isBanned = false; //Whether or not player is banned from joining this faction
this.playerReputation = 0; //"Reputation" within faction this.playerReputation = 0; //"Reputation" within faction
this.alreadyInvited = false;
//Multipliers for unlocking and purchasing augmentations //Multipliers for unlocking and purchasing augmentations
this.augmentationPriceMult = 1; this.augmentationPriceMult = 1;
@ -188,7 +189,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Illuminati //Illuminati
var illuminatiFac = Factions["Illuminati"]; var illuminatiFac = Factions["Illuminati"];
if (illuminatiFac.isBanned == false && illuminatiFac.isMember == false && if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited &&
this.numAugmentations >= 10 && this.numAugmentations >= 10 &&
this.money >= 10000000000 && this.total_money >= 20000000000 && this.money >= 10000000000 && this.total_money >= 20000000000 &&
this.hacking_skill >= 800 && this.total_hacking >= 7000 && this.hacking_skill >= 800 && this.total_hacking >= 7000 &&
@ -201,7 +202,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Daedalus //Daedalus
var daedalusFac = Factions["Daedalus"]; var daedalusFac = Factions["Daedalus"];
if (daedalusFac.isBanned == false && daedalusFac.isMember == false && if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited &&
this.numAugmentations >= 15 && this.numAugmentations >= 15 &&
this.money >= 1000000000 && this.total_money >= 10000000000 && this.money >= 1000000000 && this.total_money >= 10000000000 &&
this.hacking_skill >= 1000 && this.total_hacking >= 10000 && this.hacking_skill >= 1000 && this.total_hacking >= 10000 &&
@ -214,7 +215,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//The Covenant //The Covenant
var covenantFac = Factions["The Covenant"]; var covenantFac = Factions["The Covenant"];
if (covenantFac.isBanned == false && covenantFac.isMember == false && if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited &&
this.numAugmentations >= 12 && this.numAugmentations >= 12 &&
this.money >= 5000000000 && this.total_money >= 10000000000 && this.money >= 5000000000 && this.total_money >= 10000000000 &&
this.hacking_skill >= 850 && this.total_hack >= 5000 && this.hacking_skill >= 850 && this.total_hack >= 5000 &&
@ -227,63 +228,65 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//ECorp //ECorp
var ecorpFac = Factions["ECorp"]; var ecorpFac = Factions["ECorp"];
if (ecorpFac.isBanned == false && ecorpFac.isMember == false && if (!ecorpFac.isBanned && !ecorpFac.isMember && !ecorpFac.alreadyInvited &&
this.companyName == Locations.AevumECorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.AevumECorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(ecorpFac); invitedFactions.push(ecorpFac);
} }
//MegaCorp //MegaCorp
var megacorpFac = Factions["MegaCorp"]; var megacorpFac = Factions["MegaCorp"];
if (megacorpFac.isBanned == false && megacorpFac.isMember == false && if (!megacorpFac.isBanned && !megacorpFac.isMember && !megacorpFac.alreadyInvited &&
this.companyName == Locations.Sector12MegaCorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.Sector12MegaCorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(megacorpFac); invitedFactions.push(megacorpFac);
} }
//Bachman & Associates //Bachman & Associates
var bachmanandassociatesFac = Factions["Bachman & Associates"]; var bachmanandassociatesFac = Factions["Bachman & Associates"];
if (bachmanandassociatesFac.isBanned == false && bachmanandassociatesFac.isMember == false && if (!bachmanandassociatesFac.isBanned && !bachmanandassociatesFac.isMember &&
!bachmanandassociatesFac.alreadyInvited &&
this.companyName == Locations.AevumBachmanAndAssociates && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.AevumBachmanAndAssociates && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(bachmanandassociatesFac); invitedFactions.push(bachmanandassociatesFac);
} }
//Blade Industries //Blade Industries
var bladeindustriesFac = Factions["Blade Industries"]; var bladeindustriesFac = Factions["Blade Industries"];
if (bladeindustriesFac.isBanned == false && bladeindustriesFac.isMember == false && if (!bladeindustriesFac.isBanned && !bladeindustriesFac.isMember && !bladeindustriesFac.alreadyInvited &&
this.companyName == Locations.Sector12BladeIndustries && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.Sector12BladeIndustries && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(bladeindustriesFac); invitedFactions.push(bladeindustriesFac);
} }
//NWO //NWO
var nwoFac = Factions["NWO"]; var nwoFac = Factions["NWO"];
if (nwoFac.isBanned == false && nwoFac.isMember == false && if (!nwoFac.isBanned && !nwoFac.isMember && !nwoFac.alreadyInvited &&
this.companyName == Locations.VolhavenNWO && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.VolhavenNWO && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(nwoFac); invitedFactions.push(nwoFac);
} }
//Clarke Incorporated //Clarke Incorporated
var clarkeincorporatedFac = Factions["Clarke Incorporated"]; var clarkeincorporatedFac = Factions["Clarke Incorporated"];
if (clarkeincorporatedFac.isBanned == false && clarkeincorporatedFac.isMember == false && if (!clarkeincorporatedFac.isBanned && !clarkeincorporatedFac.isMember && !clarkeincorporatedFac.alreadyInvited &&
this.companyName == Locations.AevumClarkeIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.AevumClarkeIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(clarkeincorporatedFac); invitedFactions.push(clarkeincorporatedFac);
} }
//OmniTek Incorporated //OmniTek Incorporated
var omnitekincorporatedFac = Factions["OmniTek Incorporated"]; var omnitekincorporatedFac = Factions["OmniTek Incorporated"];
if (omnitekincorporatedFac.isBanned == false && omnitekincorporatedFac.isMember == false && if (!omnitekincorporatedFac.isBanned && !omnitekincorporatedFac.isMember && !omnitekincorporatedFac.alreadyInvited &&
this.companyName == Locations.VolhavenOmniTekIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.VolhavenOmniTekIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(omnitekincorporatedFac); invitedFactions.push(omnitekincorporatedFac);
} }
//Four Sigma //Four Sigma
var foursigmaFac = Factions["Four Sigma"]; var foursigmaFac = Factions["Four Sigma"];
if (foursigmaFac.isBanned == false && foursigmaFac.isMember == false && if (!foursigmaFac.isBanned && !foursigmaFac.isMember && !foursigmaFac.alreadyInvited &&
this.companyName == Locations.Sector12FourSigma && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.Sector12FourSigma && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(foursigmaFac); invitedFactions.push(foursigmaFac);
} }
//KuaiGong International //KuaiGong International
var kuaigonginternationalFac = Factions["KuaiGong International"]; var kuaigonginternationalFac = Factions["KuaiGong International"];
if (kuaigonginternationalFac.isBanned == false && kuaigonginternationalFac.isMember == false && if (!kuaigonginternationalFac.isBanned && !kuaigonginternationalFac.isMember &&
!kuaigonginternationalFac.alreadyInvited &&
this.companyName == Locations.ChongqingKuaiGongInternational && companyRep >= CONSTANTS.CorpFactionRepRequirement) { this.companyName == Locations.ChongqingKuaiGongInternational && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push(kuaigonginternationalFac); invitedFactions.push(kuaigonginternationalFac);
} }
@ -294,7 +297,8 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (fulcrumSecretServer == null) { if (fulcrumSecretServer == null) {
console.log("ERROR: Could not find Fulcrum Secret Technologies Server"); console.log("ERROR: Could not find Fulcrum Secret Technologies Server");
} else { } else {
if (fulcrumsecrettechonologiesFac.isBanned == false && fulcrumsecrettechonologiesFac.isMember == false && if (!fulcrumsecrettechonologiesFac.isBanned && !fulcrumsecrettechonologiesFac.isMember &&
!fulcrumsecrettechonologiesFac.alreadyInvited &&
fulcrumSecretServer.manuallyHacked && fulcrumSecretServer.manuallyHacked &&
this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) { this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) {
invitedFactions.push(fulcrumsecrettechonologiesFac); invitedFactions.push(fulcrumsecrettechonologiesFac);
@ -307,8 +311,8 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var bitrunnersServer = AllServers[SpecialServerIps[SpecialServerNames.BitRunnersServer]]; var bitrunnersServer = AllServers[SpecialServerIps[SpecialServerNames.BitRunnersServer]];
if (bitrunnersServer == null) { if (bitrunnersServer == null) {
console.log("ERROR: Could not find BitRunners Server"); console.log("ERROR: Could not find BitRunners Server");
} else if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false && bitrunnersServer.manuallyHacked && } else if (!bitrunnersFac.isBanned && !bitrunnersFac.isMember && bitrunnersServer.manuallyHacked &&
this.hacking_skill >= 500 && homeComp.maxRam >= 128) { !bitrunnersFac.alreadyInvited && this.hacking_skill >= 500 && homeComp.maxRam >= 128) {
invitedFactions.push(bitrunnersFac); invitedFactions.push(bitrunnersFac);
} }
@ -318,7 +322,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (blackhandServer == null) { if (blackhandServer == null) {
console.log("ERROR: Could not find The Black Hand Server"); console.log("ERROR: Could not find The Black Hand Server");
} else if (!theblackhandFac.isBanned && !theblackhandFac.isMember && blackhandServer.manuallyHacked && } else if (!theblackhandFac.isBanned && !theblackhandFac.isMember && blackhandServer.manuallyHacked &&
this.hacking_skill >= 350 && homeComp.maxRam >= 64) { !theblackhandFac.alreadyInvited && this.hacking_skill >= 350 && homeComp.maxRam >= 64) {
invitedFactions.push(theblackhandFac); invitedFactions.push(theblackhandFac);
} }
@ -328,55 +332,55 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (nitesecServer == null) { if (nitesecServer == null) {
console.log("ERROR: Could not find NiteSec Server"); console.log("ERROR: Could not find NiteSec Server");
} else if (!nitesecFac.isBanned && !nitesecFac.isMember && nitesecServer.manuallyHacked && } else if (!nitesecFac.isBanned && !nitesecFac.isMember && nitesecServer.manuallyHacked &&
this.hacking_skill >= 200 && homeComp.maxRam >= 32) { !nitesecFac.alreadyInvited && this.hacking_skill >= 200 && homeComp.maxRam >= 32) {
invitedFactions.push(nitesecFac); invitedFactions.push(nitesecFac);
} }
//Chongqing //Chongqing
var chongqingFac = Factions["Chongqing"]; var chongqingFac = Factions["Chongqing"];
if (chongqingFac.isBanned == false && chongqingFac.isMember == false && if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited &&
this.money >= 20000000 && this.city == Locations.Chongqing) { this.money >= 20000000 && this.city == Locations.Chongqing) {
invitedFactions.push(chongqingFac); invitedFactions.push(chongqingFac);
} }
//Sector-12 //Sector-12
var sector12Fac = Factions["Sector-12"]; var sector12Fac = Factions["Sector-12"];
if (sector12Fac.isBanned == false && sector12Fac.isMember == false && if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
this.money >= 15000000 && this.city == Locations.Sector12) { this.money >= 15000000 && this.city == Locations.Sector12) {
invitedFactions.push(sector12Fac); invitedFactions.push(sector12Fac);
} }
//New Tokyo //New Tokyo
var newtokyoFac = Factions["New Tokyo"]; var newtokyoFac = Factions["New Tokyo"];
if (newtokyoFac.isBanned == false && newtokyoFac.isMember == false && if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited &&
this.money >= 20000000 && this.city == Locations.NewTokyo) { this.money >= 20000000 && this.city == Locations.NewTokyo) {
invitedFactions.push(newtokyoFac); invitedFactions.push(newtokyoFac);
} }
//Aevum //Aevum
var aevumFac = Factions["Aevum"]; var aevumFac = Factions["Aevum"];
if (aevumFac.isBanned == false && aevumFac.isMember == false && if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited &&
this.money >= 40000000 && this.city == Locations.Aevum) { this.money >= 40000000 && this.city == Locations.Aevum) {
invitedFactions.push(aevumFac); invitedFactions.push(aevumFac);
} }
//Ishima //Ishima
var ishimaFac = Factions["Ishima"]; var ishimaFac = Factions["Ishima"];
if (ishimaFac.isBanned == false && ishimaFac.isMember == false && if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited &&
this.money >= 30000000 && this.city == Locations.Ishima) { this.money >= 30000000 && this.city == Locations.Ishima) {
invitedFactions.push(ishimaFac); invitedFactions.push(ishimaFac);
} }
//Volhaven //Volhaven
var volhavenFac = Factions["Volhaven"]; var volhavenFac = Factions["Volhaven"];
if (volhavenFac.isBanned == false && volhavenFac.isMember == false && if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited &&
this.money >= 50000000 && this.city == Locations.Volhaven) { this.money >= 50000000 && this.city == Locations.Volhaven) {
invitedFactions.push(volhavenFac); invitedFactions.push(volhavenFac);
} }
//Speakers for the Dead //Speakers for the Dead
var speakersforthedeadFac = Factions["Speakers for the Dead"]; var speakersforthedeadFac = Factions["Speakers for the Dead"];
if (speakersforthedeadFac.isBanned == false && speakersforthedeadFac.isMember == false && if (!speakersforthedeadFac.isBanned && !speakersforthedeadFac.isMember && !speakersforthedeadFac.alreadyInvited &&
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 && this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 && this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 &&
this.numPeopleKilledTotal >= 100 && this.karma <= -45 && this.companyName != Locations.Sector12CIA && this.numPeopleKilledTotal >= 100 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
@ -386,7 +390,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//The Dark Army //The Dark Army
var thedarkarmyFac = Factions["The Dark Army"]; var thedarkarmyFac = Factions["The Dark Army"];
if (thedarkarmyFac.isBanned == false && thedarkarmyFac.isMember == false && if (!thedarkarmyFac.isBanned && !thedarkarmyFac.isMember && !thedarkarmyFac.alreadyInvited &&
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 && this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing && this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing &&
this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != Locations.Sector12CIA && this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
@ -396,7 +400,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//The Syndicate //The Syndicate
var thesyndicateFac = Factions["The Syndicate"]; var thesyndicateFac = Factions["The Syndicate"];
if (thesyndicateFac.isBanned == false && thesyndicateFac.isMember == false && if (!thesyndicateFac.isBanned && !thesyndicateFac.isMember && !thesyndicateFac.alreadyInvited &&
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 && this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
this.dexterity >= 200 && this.agility >= 200 && this.dexterity >= 200 && this.agility >= 200 &&
(this.city == Locations.Aevum || this.city == Locations.Sector12) && (this.city == Locations.Aevum || this.city == Locations.Sector12) &&
@ -407,7 +411,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Silhouette //Silhouette
var silhouetteFac = Factions["Silhouette"]; var silhouetteFac = Factions["Silhouette"];
if (silhouetteFac.isBanned == false && silhouetteFac.isMember == false && if (!silhouetteFac.isBanned && !silhouetteFac.isMember && !silhouetteFac.alreadyInvited &&
(this.companyPosition.positionName == CompanyPositions.CTO.positionName || (this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
this.companyPosition.positionName == CompanyPositions.CFO.positionName || this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
this.companyPosition.positionName == CompanyPositions.CEO.positionName) && this.companyPosition.positionName == CompanyPositions.CEO.positionName) &&
@ -417,7 +421,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Tetrads //Tetrads
var tetradsFac = Factions["Tetrads"]; var tetradsFac = Factions["Tetrads"];
if (tetradsFac.isBanned == false && tetradsFac.isMember == false && if (!tetradsFac.isBanned && !tetradsFac.isMember && !tetradsFac.alreadyInvited &&
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo || (this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
this.city == Locations.Ishima) && this.strength >= 75 && this.defense >= 75 && this.city == Locations.Ishima) && this.strength >= 75 && this.defense >= 75 &&
this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) { this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) {
@ -426,7 +430,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//SlumSnakes //SlumSnakes
var slumsnakesFac = Factions["Slum Snakes"]; var slumsnakesFac = Factions["Slum Snakes"];
if (slumsnakesFac.isBanned == false && slumsnakesFac.isMember == false && if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited &&
this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 && this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 &&
this.agility >= 30 && this.karma <= -9 && this.money >= 1000000) { this.agility >= 30 && this.karma <= -9 && this.money >= 1000000) {
invitedFactions.push(slumsnakesFac); invitedFactions.push(slumsnakesFac);
@ -442,7 +446,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
totalHacknetRam += Player.hacknetNodes[i].ram; totalHacknetRam += Player.hacknetNodes[i].ram;
totalHacknetCores += Player.hacknetNodes[i].numCores; totalHacknetCores += Player.hacknetNodes[i].numCores;
} }
if (netburnersFac.isBanned == false && netburnersFac.isMember == false && if (!netburnersFac.isBanned && !netburnersFac.isMember && !netburnersFac.alreadyInvited &&
this.hacking_skill >= 80 && totalHacknetRam >= 8 && this.hacking_skill >= 80 && totalHacknetRam >= 8 &&
totalHacknetCores >= 4 && totalHacknetLevels >= 100) { totalHacknetCores >= 4 && totalHacknetLevels >= 100) {
invitedFactions.push(netburnersFac); invitedFactions.push(netburnersFac);
@ -450,7 +454,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Tian Di Hui //Tian Di Hui
var tiandihuiFac = Factions["Tian Di Hui"]; var tiandihuiFac = Factions["Tian Di Hui"];
if (tiandihuiFac.isBanned == false && tiandihuiFac.isMember == false && if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited &&
this.money >= 1000000 && this.hacking_skill >= 50 && this.money >= 1000000 && this.hacking_skill >= 50 &&
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo || (this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
this.city == Locations.Ishima)) { this.city == Locations.Ishima)) {
@ -463,18 +467,14 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (cybersecServer == null) { if (cybersecServer == null) {
console.log("ERROR: Could not find CyberSec Server"); console.log("ERROR: Could not find CyberSec Server");
} else if (!cybersecFac.isBanned && !cybersecFac.isMember && cybersecServer.manuallyHacked && } else if (!cybersecFac.isBanned && !cybersecFac.isMember && cybersecServer.manuallyHacked &&
this.hacking_skill >= 50) { !cybersecFac.alreadyInvited && this.hacking_skill >= 50) {
invitedFactions.push(cybersecFac); invitedFactions.push(cybersecFac);
} }
console.log("invited factions: " + invitedFactions);
return invitedFactions; return invitedFactions;
} }
inviteToFaction = function(faction) { inviteToFaction = function(faction) {
if (Engine.Debug) {
console.log("inviteToFaction() called with faction: " + faction.name);
}
factionInvitationBoxCreate(faction); factionInvitationBoxCreate(faction);
} }

@ -71,7 +71,7 @@ function checkForMessagesToSend() {
sendMessage(bitrunnersTest); sendMessage(bitrunnersTest);
} if (jumper5 && !jumper5.recvd && Player.hacking_skill >= 900) { } if (jumper5 && !jumper5.recvd && Player.hacking_skill >= 900) {
sendMessage(jumper5); sendMessage(jumper5);
Player.getHomeComputer.programs.push(Programs.Flight); Player.getHomeComputer().programs.push(Programs.Flight);
} }
} }

@ -104,8 +104,14 @@ function evaluate(exp, workerScript) {
evaluateProgPromise.then(function(w) { evaluateProgPromise.then(function(w) {
resolve(workerScript); resolve(workerScript);
}, function(e) { }, function(e) {
workerScript.errorMessage = e.toString(); if (typeof e === 'string' || e instanceof String) {
workerScript.errorMessage = e;
reject(workerScript); reject(workerScript);
} else if (e instanceof WorkerScript) {
reject(e);
} else {
reject(workerScript);
}
}); });
break; break;
case "call": case "call":

@ -212,7 +212,7 @@ function netscriptRunProgram(exp, workerScript, programName) {
var env = workerScript.env; var env = workerScript.env;
if (env.stopFlag) {return Promise.reject(workerScript);} if (env.stopFlag) {return Promise.reject(workerScript);}
if (exp.args.length != 1) { if (exp.args.length != 1) {
return Promise.reject(makeRuntimeRejectMsg(workerScript, "nuke() call has incorrect number of arguments. Takes 1 argument")); return Promise.reject(makeRuntimeRejectMsg(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"));
} }
var ipPromise = evaluate(exp.args[0], workerScript); var ipPromise = evaluate(exp.args[0], workerScript);
return ipPromise.then(function(ip) { return ipPromise.then(function(ip) {

@ -81,6 +81,176 @@ loadGame = function(saveObj) {
return true; return true;
} }
loadImportedGame = function(saveObj, saveString) {
var tempSaveObj = null;
var tempPlayer = null;
var tempAllServers = null;
var tempCompanies = null;
var tempFactions = null;
var tempSpecialServerIps = null;
var tempAugmentations = null;
var tempAliases = null;
var tempMessages = null;
try {
saveString = decodeURIComponent(escape(atob(saveString)));
tempSaveObj = new BitburnerSaveObject();
tempSaveObj = JSON.parse(saveString, Reviver);
tempPlayer = JSON.parse(tempSaveObj.PlayerSave, Reviver);
tempAllServers = JSON.parse(tempSaveObj.AllServersSave, Reviver);
tempCompanies = JSON.parse(tempSaveObj.CompaniesSave, Reviver);
tempFactions = JSON.parse(tempSaveObj.FactionsSave, Reviver);
tempSpecialServerIps = JSON.parse(tempSaveObj.SpecialServerIpsSave, Reviver);
tempAugmentations = JSON.parse(tempSaveObj.AugmentationsSave, Reviver);
if (tempSaveObj.hasOwnProperty("AliasesSave")) {
try {
tempAliases = JSON.parse(tempSaveObj.AliasesSave, Reviver);
} catch(e) {
tempAliases = {};
}
} else {
tempAliases = {};
}
if (tempSaveObj.hasOwnProperty("MessagesSave")) {
try {
tempMessages = JSON.parse(tempSaveObj.MessagesSave, Reviver);
} catch(e) {
initMessages();
}
} else {
initMessages();
}
if (tempSaveObj.hasOwnProperty("VersionSave")) {
try {
var ver = JSON.parse(tempSaveObj.VersionSave, Reviver);
if (ver != CONSTANTS.Version) {
createNewUpdateText();
}
} catch(e) {
createNewUpdateText();
}
} else {
createNewUpdateText();
}
} catch(e) {
dialogBoxCreate("Error importing game");
return false;
}
saveObj = tempSaveObj;
Player = tempPlayer;
AllServers = tempAllServers;
Companies = tempCompanies;
Factions = tempFactions;
SpecialServerIps = tempSpecialServerIps;
Augmentations = tempAugmentations;
if (tempAliases) {
Aliases = tempAliases;
}
if (tempMessages) {
Messages = tempMessages;
}
dialogBoxCreate("Imported game");
gameOptionsBoxClose();
//Re-start game
console.log("Importing game");
Engine.setDisplayElements(); //Sets variables for important DOM elements
Engine.init(); //Initialize buttons, work, etc.
CompanyPositions.init();
//Calculate the number of cycles have elapsed while offline
Engine._lastUpdate = new Date().getTime();
var lastUpdate = Player.lastUpdate;
var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
/* Process offline progress */
var offlineProductionFromScripts = loadAllRunningScripts(); //This also takes care of offline production for those scripts
if (Player.isWorking) {
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
if (Player.workType == CONSTANTS.WorkTypeFaction) {
Player.workForFaction(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
Player.createProgramWork(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
Player.takeClass(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
Player.commitCrime(numCyclesOffline);
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
Player.workPartTime(numCyclesOffline);
} else {
Player.work(numCyclesOffline);
}
}
//Hacknet Nodes offline progress
var offlineProductionFromHacknetNodes = processAllHacknetNodeEarnings(numCyclesOffline);
//Passive faction rep gain offline
processPassiveFactionRepGain(numCyclesOffline);
//Update total playtime
var time = numCyclesOffline * Engine._idleSpeed;
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
Player.totalPlaytime += time;
//Re-apply augmentations
Player.reapplyAllAugmentations();
//Clear terminal
$("#terminal tr:not(:last)").remove();
Player.lastUpdate = Engine._lastUpdate;
Engine.start(); //Run main game loop and Scripts loop
dialogBoxCreate("While you were offline, your scripts generated $" +
formatNumber(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
formatNumber(offlineProductionFromHacknetNodes, 2));
return true;
}
BitburnerSaveObject.prototype.exportGame = function() {
this.PlayerSave = JSON.stringify(Player);
this.AllServersSave = JSON.stringify(AllServers);
this.CompaniesSave = JSON.stringify(Companies);
this.FactionsSave = JSON.stringify(Factions);
this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
this.AugmentationsSave = JSON.stringify(Augmentations);
this.AliasesSave = JSON.stringify(Aliases);
this.MessagesSave = JSON.stringify(Messages);
this.VersionSave = JSON.stringify(CONSTANTS.Version);
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
var file = new Blob([saveString], {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 = "bitburnerSave.json";
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
BitburnerSaveObject.prototype.importGame = function() {
if (window.File && window.FileReader && window.FileList && window.Blob) {
var fileSelector = clearEventListeners("import-game-file-selector");
fileSelector.addEventListener("change", openImportFileHandler, false);
$("#import-game-file-selector").click();
} else {
dialogBoxCreate("ERR: Your browser does not support HTML5 File API. Cannot import.");
}
}
BitburnerSaveObject.prototype.deleteGame = function() { BitburnerSaveObject.prototype.deleteGame = function() {
if (window.localStorage.getItem("bitburnerSave")) { if (window.localStorage.getItem("bitburnerSave")) {
window.localStorage.removeItem("bitburnerSave"); window.localStorage.removeItem("bitburnerSave");
@ -105,3 +275,20 @@ BitburnerSaveObject.fromJSON = function(value) {
} }
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject; Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;
//Import game
function openImportFileHandler(evt) {
var file = evt.target.files[0];
if (!file) {
dialogBoxCreate("Invalid file selected");
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
loadImportedGame(saveObject, contents);
};
reader.readAsText(file);
}

@ -37,6 +37,8 @@ function Server() {
//Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change. //Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100) this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100)
this.baseDifficulty = 1; //Starting difficulty
this.minDifficulty = 1;
this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100) this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100)
this.timesHacked = 0; this.timesHacked = 0;
@ -80,6 +82,8 @@ Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvai
this.moneyAvailable = moneyAvailable; this.moneyAvailable = moneyAvailable;
this.moneyMax = 50 * moneyAvailable; this.moneyMax = 50 * moneyAvailable;
this.hackDifficulty = hackDifficulty; this.hackDifficulty = hackDifficulty;
this.baseDifficulty = hackDifficulty;
this.minDifficulty = Math.max(1, hackDifficulty - 25);
this.serverGrowth = serverGrowth; this.serverGrowth = serverGrowth;
} }

@ -890,7 +890,7 @@ var Engine = {
//Active scripts list //Active scripts list
Engine.ActiveScriptsList = document.getElementById("active-scripts-list"); Engine.ActiveScriptsList = document.getElementById("active-scripts-list");
//Save and Delete buttons //Save, Delete, Import/Export buttons
Engine.Clickables.saveMainMenuButton = document.getElementById("save-game-link"); Engine.Clickables.saveMainMenuButton = document.getElementById("save-game-link");
Engine.Clickables.saveMainMenuButton.addEventListener("click", function() { Engine.Clickables.saveMainMenuButton.addEventListener("click", function() {
saveObject.saveGame(); saveObject.saveGame();
@ -903,6 +903,11 @@ var Engine = {
return false; return false;
}); });
document.getElementById("export-game-link").addEventListener("click", function() {
saveObject.exportGame();
return false;
});
//Character Overview Save button //Character Overview Save button
var charOverviewSaveButton = document.getElementById("character-overview-save-button"); var charOverviewSaveButton = document.getElementById("character-overview-save-button");
charOverviewSaveButton.addEventListener("click", function() { charOverviewSaveButton.addEventListener("click", function() {
@ -1011,6 +1016,7 @@ var Engine = {
console.log("Deleting running scripts on home computer"); console.log("Deleting running scripts on home computer");
Player.getHomeComputer().runningScripts = []; Player.getHomeComputer().runningScripts = [];
dialogBoxCreate("Forcefully deleted all running scripts on home computer. Please save and refresh page"); dialogBoxCreate("Forcefully deleted all running scripts on home computer. Please save and refresh page");
gameOptionsBoxClose();
return false; return false;
}); });
@ -1018,6 +1024,7 @@ var Engine = {
document.getElementById("debug-soft-reset").addEventListener("click", function() { document.getElementById("debug-soft-reset").addEventListener("click", function() {
dialogBoxCreate("Soft Reset!"); dialogBoxCreate("Soft Reset!");
prestigeAugmentation(); prestigeAugmentation();
gameOptionsBoxClose();
return false; return false;
}); });
}, },

@ -1,16 +1,4 @@
/* Faction Invitation Pop-up box */ /* Faction Invitation Pop-up box */
function factionInvitationBoxInit() {
var cancelButton = document.getElementById("faction-invitation-box-no");
//Close Dialog box
cancelButton.addEventListener("click", function() {
factionInvitationBoxClose();
return false;
});
};
document.addEventListener("DOMContentLoaded", factionInvitationBoxInit, false);
factionInvitationBoxClose = function() { factionInvitationBoxClose = function() {
var factionInvitationBox = document.getElementById("faction-invitation-box-container"); var factionInvitationBox = document.getElementById("faction-invitation-box-container");
factionInvitationBox.style.display = "none"; factionInvitationBox.style.display = "none";
@ -37,15 +25,18 @@ factionInvitationBoxCreate = function(faction) {
//TODO Faction invitation message //TODO Faction invitation message
var newYesButton = clearEventListeners("faction-invitation-box-yes"); var newYesButton = clearEventListeners("faction-invitation-box-yes");
//var yesButton = document.getElementById("faction-invitation-box-yes");
//var newYesButton = yesButton.cloneNode(true);
//yesButton.parentNode.replaceChild(newYesButton, yesButton);
newYesButton.addEventListener("click", function() { newYesButton.addEventListener("click", function() {
joinFaction(faction); joinFaction(faction);
factionInvitationBoxClose(); factionInvitationBoxClose();
return false; return false;
}); });
var noButton = clearEventListeners("faction-invitation-box-no");
noButton.addEventListener("click", function() {
factionInvitationBoxClose();
faction.alreadyInvited = true;
return false;
});
factionInvitationBoxOpen(); factionInvitationBoxOpen();
} }