Added a bunch of small fixes and features, don't remember exactly what lol

This commit is contained in:
Daniel Xie 2017-02-16 12:52:11 -06:00
parent 1c26d2953b
commit 0ed3d65ae5
18 changed files with 736 additions and 215 deletions

@ -49,6 +49,8 @@ TESTING TODO:
Add possible CompanyPositions for every Company
Applying/working for companies
Factions
Tasks TODO:
Script logging functionality? Logs to internal "log file" (property of script itself)
Tutorial and help
@ -56,7 +58,10 @@ Tasks TODO:
Hack time formula needs rebalancing I think
Factions
Create new menu page for purchased servers
Change Company pages to display "apply for promotion" and other stuff when you are already employed there
Augmentations
Update CONSTANTS.HelpText
Account for Max possible int when gaining exp

151
css/popupboxes.css Normal file

@ -0,0 +1,151 @@
/* Pop-up boxes */
/* Pop-up Dialog Box */
#dialog-box-container {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: black; /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
#dialog-box-content {
background-color: black;
margin: 20% auto; /* 15% from the top and centered */
padding: 10px;
border: 5px solid #FFFFFF;
width: 40%; /* Could be more or less, depending on screen size */
}
.dialog-box-text {
color: #66ff33;
}
#dialog-box-close-button {
color: #aaa;
float: right;
font-size: 20px;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
#dialog-box-close-button:hover,
#dialog-box-close-button:focus {
color: white;
text-decoration: none;
cursor: pointer;
}
/* Purchase server box */
#purchase-server-box-container {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
right: 0;
bottom: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: black; /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
transition: opacity 400ms ease-in;
}
#purchase-server-box-content {
background-color: black;
margin: 15% auto; /* 15% from the top and centered */
padding: 1px;
border: 5px solid #FFFFFF;
width: 80%; /* Could be more or less, depending on screen size */
color: #66ff33;
}
#purchase-server-box-input {
color: white;
}
#purchase-server-box-confirm,
#purchase-server-box-cancel {
color: #aaa;
float: right;
font-size: 16px;
font-weight: bold;
padding: 2px;
border: 1px solid white;
}
#purchase-server-box-confirm:hover,
#purchase-server-box-confirm:focus {
color: #66ff33;
text-decoration: none;
cursor: pointer;
}
#purchase-server-box-cancel:hover,
#purchase-server-box-cancel:focus {
color: #66ff33;
text-decoration: none;
cursor: pointer;
}
/* Faction invitation box */
#faction-invitation-box-container {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
right: 0;
bottom: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: black; /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
transition: opacity 400ms ease-in;
}
#faction-invitation-box-content {
background-color: black;
margin: 15% auto; /* 15% from the top and centered */
padding: 10px;
border: 5px solid #FFFFFF;
width: 80%; /* Could be more or less, depending on screen size */
color: #66ff33;
}
#faction-invitation-box-yes,
#faction-invitation-box-no {
color: #aaa;
font-size: 20px;
font-weight: bold;
padding: 1px;
margin: 3px;
border: 1px solid white;
}
#faction-invitation-box-yes:hover,
#faction-invitation-box-yes:focus {
color: white;
text-decoration: none;
cursor: pointer;
}
#faction-invitation-box-no:hover,
#faction-invitation-box-no:focus {
color: white;
text-decoration: none;
cursor: pointer;
}

@ -68,102 +68,3 @@ h1 {
border-left: 1px solid #333333;
}
/* Pop-up Dialog Box */
#dialog-box-container {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: black; /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
#dialog-box-content {
background-color: black;
margin: 20% auto; /* 15% from the top and centered */
padding: 10px;
border: 5px solid #FFFFFF;
width: 40%; /* Could be more or less, depending on screen size */
}
.dialog-box-text {
color: #66ff33;
}
#dialog-box-close-button {
color: #aaa;
float: right;
font-size: 20px;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
#dialog-box-close-button:hover,
#dialog-box-close-button:focus {
color: white;
text-decoration: none;
cursor: pointer;
}
/* Pop-up Yes/no box */
#purchase-server-box-container {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
right: 0;
bottom: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: black; /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
transition: opacity 400ms ease-in;
}
#purchase-server-box-content {
background-color: black;
margin: 15% auto; /* 15% from the top and centered */
padding: 1px;
border: 5px solid #FFFFFF;
width: 80%; /* Could be more or less, depending on screen size */
color: #66ff33;
}
#purchase-server-box-input {
color: white;
}
#purchase-server-box-confirm,
#purchase-server-box-cancel {
color: #aaa;
float: right;
font-size: 14px;
font-weight: bold;
padding: 2px;
border: 1px solid white
}
#purchase-server-box-confirm:hover,
#purchase-server-box-confirm:focus {
color: #66ff33;
text-decoration: none;
cursor: pointer;
}
#purchase-server-box-cancel:hover,
#purchase-server-box-cancel:focus {
color: #66ff33;
text-decoration: none;
cursor: pointer;
}

@ -17,7 +17,10 @@
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
margin: 10px;
padding: 5px;
border-radius: 12px;
border: 3px solid white;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;

@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css" href="css/terminal.css" />
<link rel="stylesheet" type="text/css" href="css/menupages.css" />
<link rel="stylesheet" type="text/css" href="css/workinprogress.css" />
<link rel="stylesheet" type="text/css" href="css/popupboxes.css" />
<!-- We'll add in the jQuery library here - direct from
the Google CDN (Content Delivery Network). -->
@ -19,6 +20,7 @@
<script src="utils/ObjectHelperFunctions.js"></script>
<script src="utils/DialogBox.js"></script>
<script src="utils/PurchaseServerBox.js"></script>
<script src="utils/FactionInvitationBox.js"></script>
<!-- Netscript -->
<script src="src/netscript/NetScriptWorker.js"></script>
@ -30,6 +32,7 @@
<!-- Main game files -->
<script src="src/Constants.js"></script>
<script src="src/SpecialServerIps.js"></script>
<script src="src/Location.js"></script>
<script src="src/Script.js"></script>
<script src="src/Server.js"></script>
@ -412,7 +415,7 @@
</div>
</div>
<!-- Purchase Server Box -->
<!-- Purchase Server Pop-up Box -->
<div id="purchase-server-box-container">
<div id="purchase-server-box-content">
<p id="purchase-server-box-text"> </p>
@ -423,6 +426,20 @@
</div>
</div>
<!-- Faction Invitation Pop-up Box -->
<div id="faction-invitation-box-container">
<div id="faction-invitation-box-content">
<p id="faction-invitation-box-text"> </p>
<p id="faction-invitation-box-message"> </p>
<p id="faction-invitation-box-warning">
Would you like to join? <br> <br>
Warning: Joining this faction may prevent you from joining other factions during this run!
</p>
<span id="faction-invitation-box-yes"> Yes </span>
<span id="faction-invitation-box-no"> No </span>
</div>
</div>
<!-- Work in progress screen -->
<div id="work-in-progress-container">
<p id="work-in-progress-text"> </p>

@ -301,7 +301,7 @@ CompanyPositions = {
CompanyPositions.Waiter.setPerformanceParameters(0, 10, 0, 10, 10, 70);
CompanyPositions.Waiter.setExperienceGains(0, .01, .01, .01, .01, .05);
CompanyPositions.Employee.setPerformanceParameters(0, 10, 0, 10, 10, 70);
CompanyPositions.Employee.setExperienceGains(0, .01, .01, .01, .01, .05);
CompanyPositions.Employee.setExperienceGains(0, .01, .01, .01, .01, .015);
CompanyPositions.SecurityGuard.setPerformanceParameters(5, 20, 20, 20, 20, 15);
CompanyPositions.SecurityGuard.setExperienceGains(.01, .02, .02, .02, .02, .01);
CompanyPositions.PoliceOfficer.setPerformanceParameters(5, 20, 20, 20, 20, 15);

@ -13,25 +13,25 @@ CONSTANTS = {
CodeOfflineExecutionTime: 10,
//Text that is displayed when the 'help' command is ran in Terminal
HelpText: "analyze Get statistics and information about current machine\n" +
"clear Clear all text on the terminal\n" +
"cls See 'clear' command\n" +
"connect [ip/hostname] Connects to the machine given by its IP or hostname\n" +
"free Check the machine's memory usage\n" +
"hack Hack the current machine\n" +
"help Display this list\n" +
"hostname Displays the hostname of the machine\n" +
"ifconfig Displays the IP address of the machine\n" +
"kill [script name] Stops a script that is running\n" +
"ls Displays all programs and scripts on the machine\n" +
"nano [script name] Text editor - Open up and edit a script\n" +
"netstat Displays all available network connections\n" +
"ps Display all scripts that are currently running\n" +
"rm Delete a script/program from the machine. (WARNING: Permanent)\n" +
"run [script/program] Execute a program or a script\n" +
"scan See 'netstat' command\n" +
"telnet [ip/hostname] See 'connect' command\n" +
"top Display all running scripts and their RAM usage\n",
HelpText: "analyze Get statistics and information about current machine <br>" +
"clear Clear all text on the terminal <br>" +
"cls See 'clear' command <br>" +
"connect [ip/hostname] Connects to the machine given by its IP or hostname <br>" +
"free Check the machine's memory usage<br>" +
"hack Hack the current machine<br>" +
"help Display this list<br>" +
"hostname Displays the hostname of the machine<br>" +
"ifconfig Displays the IP address of the machine<br>" +
"kill [script name] Stops a script that is running<br>" +
"ls Displays all programs and scripts on the machine<br>" +
"nano [script name] Text editor - Open up and edit a script<br>" +
"netstat Displays all available network connections<br>" +
"ps Display all scripts that are currently running<br>" +
"rm Delete a script/program from the machine. (WARNING: Permanent)<br>" +
"run [script/program] Execute a program or a script<br>" +
"scan See 'netstat' command<br>" +
"telnet [ip/hostname] See 'connect' command<br>" +
"top Display all running scripts and their RAM usage<br>",
//TutorialGettingStartedText:

@ -107,8 +107,11 @@ initFactions = function() {
//This function sets the requirements to join a Faction. It checks whether the Player meets
//those requirements and will return an array of all factions that the Player should
//receive an invitation to
PlayerObject.prototype.checkForFactionInvitations() {
invitedFactions = []; //Array which will hold NAMES of all Factions player should be invited to
PlayerObject.prototype.checkForFactionInvitations = function() {
if (Engine.Debug) {
console.log("checkForFactionInvitations() called");
}
invitedFactions = []; //Array which will hold all Factions th eplayer should be invited to
var companyRep = Companies[this.companyName].playerReputation;
@ -122,7 +125,7 @@ PlayerObject.prototype.checkForFactionInvitations() {
this.defense >= 900 && this.total_defense >= 10000 &&
this.dexterity >= 900 && this.total_dexterity >= 10000 &&
this.agility >= 900 && this.total_agility >= 10000) {
invitedFactions.push("Illuminati");
invitedFactions.push(illuminatiFac);
}
//Daedalus
@ -135,7 +138,7 @@ PlayerObject.prototype.checkForFactionInvitations() {
this.defense >= 500 && this.total_defense >= 8000 &&
this.dexterity >= 500 && this.total_dexterity >= 8000 &&
this.agility >= 500 && this.total_agility >= 8000) {
invitedFactions.push("Daedalus");
invitedFactions.push(daedalusFac);
}
//The Covenant
@ -148,91 +151,90 @@ PlayerObject.prototype.checkForFactionInvitations() {
this.defense >= 850 && this.total_defense >= 5000 &&
this.dexterity >= 850 && this.total_dexterity >= 5000 &&
this.agility >= 850 && this.total_agility >= 5000) {
invitedFactions.push("The Covenant");
invitedFactions.push(covenantFac);
}
//ECorp
var ecorpFac = Factions["ECorp"];
if (ecorpFac.isBanned == false && ecorpFac.isMember == false &&
this.companyName == Locations.AevumECorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("ECorp");
invitedFactions.push(ecorpFac);
}
//MegaCorp
var megacorpFac = Factions["MegaCorp"];
if (megacorpFac.isBanned == false && megacorpFac.isMember == false &&
this.companyName == Locations.Sector12MegaCorp && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("MegaCorp");
invitedFactions.push(megacorpFac);
}
//Bachman & Associates
var bachmanandassociatesFac = Factions["Bachman & Associates"];
if (bachmanandassociatesFac.isBanned == false && bachmanandassociatesFac.isMember == false &&
this.companyName == Locations.AevumBachmanAndAssociates && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("Bachman & Associates");
invitedFactions.push(bachmanandassociatesFac);
}
//Blade Industries
var bladeindustriesFac = Factions["Blade Industries"];
if (bladeindustriesFac.isBanned == false && bladeindustriesFac.isMember == false &&
this.companyName == Locations.Sector12BladeIndustries && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("Blade Industries");
invitedFactions.push(bladeindustriesFac);
}
//NWO
var nwoFac = Factions["NWO"];
if (nwoFac.isBanned == false && nwoFac.isMember == false &&
this.companyName == Locations.VolhavenNWO && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("NWO");
invitedFactions.push(nwoFac);
}
//Clarke Incorporated
var clarkeincorporatedFac = Factions["Clarke Incorporated"];
if (clarkeincorporatedFac.isBanned == false && clarkeincorporatedFac.isMember == false &&
this.companyName == Locations.AevumClarkeIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("Clarke Incorporated");
invitedFactions.push(clarkeincorporatedFac);
}
//OmniTek Incorporated
var omnitekincorporatedFac = Factions["OmniTek Incorporated"];
if (omnitekincorporatedFac.isBanned == false && omnitekincorporatedFac.isMember == false &&
this.companyName == Locations.VolhavenOmniTekIncorporated && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("OmniTek Incorporated");
invitedFactions.push(omnitekincorporatedFac);
}
//Four Sigma
var foursigmaFac = Factions["Four Sigma"];
if (foursigmaFac.isBanned == false && foursigmaFac.isMember == false &&
this.companyName == Locations.Sector12FourSigma && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("Four Sigma");
invitedFactions.push(foursigmaFac);
}
//KuaiGong International
var kuaigonginternationalFac = Factions["KuaiGong International"];
if (kuaigonginternationalFac.isBanned == false && kuaigonginternationalFac.isMember == false &&
this.companyName == Locations.ChongqingKuaiGongInternational && companyRep >= CONSTANTS.CorpFactionRepRequirement) {
invitedFactions.push("KuaiGong International");
invitedFactions.push(kuaigonginternationalFac);
}
//Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
var fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
var fulcrumSecretServer = AllServers[SpecialServerIps.fulcrumSecretServer];
var fulcrumSecretServer = AllServers[SpecialServerIps["Fulcrum Secret Technologies Server"]];
if (fulcrumSecretServer == null) {
console.log("Error: Could not find Fulcrum Secret Technologies Server");
}
if (fulcrumsecrettechonologiesFac.isBanned == false && fulcrumsecrettechonologiesFac.isMember == false &&
fulcrumSecretServer.hasAdminRights &&
this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) {
invitedFactions.push("Fulcrum Secret Technologies");
invitedFactions.push(fulcrumsecrettechonologiesFac);
}
//BitRunners
var bitrunnersFac = Factions["BitRunners"];
var homeComp = AllServers[this.homeComputer];
var homeComp = Player.getHomeComputer();
if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false &&
this.hacking_skill >= 600 && homeComp.maxRam >= 32) {
invitedFactions.push("BitRunners");
invitedFactions.push(bitrunnersFac);
}
//The Black Hand
@ -240,27 +242,113 @@ PlayerObject.prototype.checkForFactionInvitations() {
if (theblackhandFac.isBanned == false && theblackhandFac.isMember == false &&
this.hacking_skill >= 400 && this.strength >= 300 && this.defense >= 300 &&
this.agility >= 300 && this.dexterity >= 300 && homeComp.maxRam >= 16) {
invitedFactions.push("The Black Hand");
invitedFactions.push(theblackhandFac);
}
//NiteSec
var nitesecFac = Factions["NiteSec"];
if (nitesecFac.isBanned == false && nitesecFac.isMember == false &&
this.hacking_skill >= 500 && homeComp.maxRam >= 32) {
invitedFactions.push("NiteSec");
invitedFactions.push(nitesecFac);
}
//Chongqing
var chongqingFac = Factions["Chongqing"];
if (chongqingFac.isBanned == false && chongqingFac.isMember == false &&
this.money >= 20000000 && this.location == Locations.Chongqing) {
invitedFactions.push(chongqingFac);
}
//Sector-12
var sector12Fac = Factions["Sector-12"];
if (sector12Fac.isBanned == false && sector12Fac.isMember == false &&
this.money >= 50000000 && this.location == Locations.Sector12) {
invitedFactions.push(sector12Fac);
}
//New Tokyo
var newtokyoFac = Factions["New Tokyo"];
if (newtokyoFac.isBanned == false && newtokyoFac.isMember == false &&
this.money >= 20000000 && this.location == Locations.NewTokyo) {
invitedFactions.push(newtokyoFac);
}
//Aevum
var aevumFac = Factions["Aevum"];
if (aevumFac.isBanned == false && aevumFac.isMember == false &&
this.money >= 40000000 && this.location == Locations.Aevum) {
invitedFactions.push(aevumFac);
}
//Ishima
var ishimaFac = Factions["Ishima"];
if (ishimaFac.isBanned == false && ishimaFac.isMember == false &&
this.money >= 30000000 && this.location == Locations.Ishima) {
invitedFactions.push(ishimaFac);
}
//Volhaven
var volhavenFac = Factions["Volhaven"];
if (volhavenFac.isBanned == false && volhavenFac.isMember == false &&
this.money >= 50000000 && this.location == Locations.Volhaven) {
invitedFactions.push(volhavenFac);
}
//Speakers for the Dead
var speakersforthedeadFac = Factions["Speakers for the Dead"];
if (speakersforthedeadFac.isBanned == false && speakersforthedeadFac.isMember == false &&
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 &&
this.numPeopleKilledTotal >= 100 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) {
invitedFactions.push(speakersforthedeadFac);
}
//The Dark Army
var thedarkarmyFac = Factions["The Dark Army"];
if (thedarkarmyFac.isBanned == false && thedarkarmyFac.isMember == false &&
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.location == Locations.Chongqing &&
this.numPeopleKilled >= 5 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thedarkarmyFac);
}
//The Syndicate
var thesyndicateFac = Factions["The Syndicate"];
if (thesyndicateFac.isBanned == false && thesyndicateFac.isMember == false &&
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
this.dexterity >= 200 && this.agility >= 200 &&
(this.location == Locations.Aevum || this.location == Locations.Sector12) &&
this.money >= 10000000 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thesyndicateFac);
}
//Tian Di Hui
var tiandihuiFac = Factions["Tian Di Hui"];
if (tiandihuiFac.isBanned == false && tiandihuiFac.isMember == false &&
this.money >= 1000000 && this.hacking_skill >= 50 &&
(this.location == Locations.Chongqing || this.location == Locations.NewTokyo ||
this.location == Locations.Ishima)) {
invitedFactions.push(tiandihuiFac);
}
//CyberSec
var cybersecFac = Factions["CyberSec"];
if (cybersecFac.isBanned == false && cybersecFac.isMember == false &&
this.hacking_skill >= 50) {
invitedFactions.push(cybersecFac);
}
return invitedFactions;
}
inviteToFaction = function(faction) {
if (Engine.Debug) {
console.log("inviteToFaction() called with faction: " + faction.name);
}
factionInvitationBoxCreate(faction);
}
joinFaction = function(faction) {
@ -270,6 +358,7 @@ joinFaction = function(faction) {
var item = document.createElement("li");
var aElem = document.createElement("a");
aElem.setAttribute("href", "#");
aElem.setAttribute("class", "a-link-button");
aElem.innerHTML = faction.name;
aElem.addEventListener("click", function() {
displayFactionContent(faction.name);
@ -279,8 +368,50 @@ joinFaction = function(faction) {
var factionsList = document.getElementById("factions-list");
factionsList.appendChild(item);
//Determine what factions you are banned from now that you have joined this faction
if (faction.name == "BitRunners") {
Factions["The Black Hand"].isBanned = true;
Factions["NiteSec"].isBanned = true;
} else if (faction.name == "The Black Hand") {
Factions["BitRunners"].isBanned = true;
Factions["NiteSec"].isBanned = true;
} else if (faction.name == "NiteSec") {
Factions["BitRunners"].isBanned = true;
Factions["The Black Hand"].isBanned = true;
} else 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;
}
}
//TODO Leave faction
//Displays the HTML content for this faction
displayFactionContent = function(factionName) {
var faction = Factions[factionName];

@ -175,7 +175,8 @@ displayLocationContent = function() {
if (loc == Player.companyName) {
var company = Companies[loc];
jobTitle.style.display = "block";
jobReputation.style.display = "block";
jobTitle.innerHTML = "Job Title: " + Player.companyPosition.positionName;
jobReputation.innerHTML = "Company reputation: " + company.playerReputation;
work.style.display = "block";

@ -200,8 +200,21 @@ function evaluate(exp, workerScript) {
var ipPromise = evaluate(exp.args[0], workerScript);
ipPromise.then(function(ip) {
//Check if its a valid IP address. If it's not, assume its a hostname and
//try to get the server. If its not a server, there is an error
var server = null;
if (!isValidIPAddress(ip)) {
//It's not an IP address, so see if its a hostanme
server = GetServerByHostname(ip);
} else {
server = AllServers[ip];
}
if (server == null) {
resolve("Invalid IP or server hostname passed in");
//TODO LOg...or throw error or something
}
//Calculate the hacking time
var server = AllServers[ip];
var hackingTime = scriptCalculateHackingTime(server); //This is in seconds
if (server.hasAdminRights == false) {
@ -517,7 +530,7 @@ function scriptCalculateHackingChance(server) {
//The same as Player's calculateHackingTime() function but takes in the server as an argument
function scriptCalculateHackingTime(server) {
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
var skillFactor = difficultyMult / Player.hacking_skill;
var skillFactor = (difficultyMult + 500) / (Player.hacking_skill + 50);
var hackingTime = skillFactor * Player.hacking_speed_multiplier; //This is in seconds
return hackingTime;
}

@ -54,6 +54,9 @@ function runScriptsLoop() {
if (w instanceof Error) {
//Error text format: |serverip|scriptname|error message
var errorText = w.toString();
if (Engine.Debug) {
console.log("Error in script: " + errorText);
}
var errorTextArray = errorText.split("|");
if (errorTextArray.length != 4) {
console.log("ERROR: Something wrong with Error text in evaluator...");

@ -75,6 +75,11 @@ function PlayerObject() {
//Augmentations
this.numAugmentations = 0;
//Misc statistics
this.numPeopleKilled = 0;
this.numPeopleKilledTotal = 0;
this.numPeopleKilledLifetime = 0;
//Achievements and achievement progress
//Flag to let the engine know the player is starting an action
@ -82,14 +87,16 @@ function PlayerObject() {
this.startAction = false;
this.actionTime = 0;
//Flags/variables for working
//Flags/variables for working (both Company and faction)
this.isWorking = false;
this.isWorkingForFaction = false;
this.workHackExpGainRate = 0;
this.workStrExpGainRate = 0;
this.workDefExpGainRate = 0;
this.workDexExpGainRate = 0;
this.workAgiExpGainRate = 0;
this.workChaExpGainRate = 0;
this.workRepGainRate = 0;
this.workMoneyGainRate = 0;
@ -98,6 +105,7 @@ function PlayerObject() {
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
@ -132,7 +140,7 @@ PlayerObject.prototype.getHomeComputer = function() {
// At the maximum possible exp (MAX_INT = 9007199254740991), the hacking skill will be 1796 TODO REcalculate this
// Gets to level 1000 hacking skill at (TODO Determine this)
PlayerObject.prototype.calculateSkill = function(exp) {
return Math.max(Math.floor(32 * Math.log(exp + 112) - 150), 1);
return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1);
}
PlayerObject.prototype.updateSkillLevels = function() {
@ -164,7 +172,7 @@ PlayerObject.prototype.calculateHackingChance = function() {
// hacking_skill
PlayerObject.prototype.calculateHackingTime = function() {
var difficultyMult = this.getCurrentServer().requiredHackingSkill * this.getCurrentServer().hackDifficulty;
var skillFactor = difficultyMult / this.hacking_skill;
var skillFactor = (difficultyMult + 500) / (this.hacking_skill + 100);
return skillFactor * this.hacking_speed_multiplier;
}
@ -212,18 +220,22 @@ PlayerObject.prototype.gainMoney = function(money) {
this.lifetime_money += money;
}
/* Working */
/* Working for Company */
PlayerObject.prototype.finishWork = function(cancelled) {
//Since the work was cancelled early, player only gains half of what they've earned so far
var cancMult = 1;
if (cancelled) {
cancMult = 2;
}
this.hacking_exp += Math.round(this.workHackExpGained / cancMult);
this.strength_exp += Math.round(this.workStrExpGained / cancMult);
this.defense_exp += Math.round(this.workDefExpGained / cancMult);
this.dexterity_exp += Math.round(this.workDexExpGained / cancMult);
this.agility_exp += Math.round(this.workAgiExpGained / cancMult);
if (Engine.Debug) {
console.log("Player finishWork() called with " + this.workMoneyGained / cancMult + " $ gained");
}
this.hacking_exp += (this.workHackExpGained / cancMult);
this.strength_exp += (this.workStrExpGained / cancMult);
this.defense_exp += (this.workDefExpGained / cancMult);
this.dexterity_exp += (this.workDexExpGained / cancMult);
this.agility_exp += (this.workAgiExpGained / cancMult);
this.charisma_exp += (this.workChaExpGained / cancMult);
var company = Companies[this.companyName];
company.playerReputation += (this.workRepGained / cancMult);
@ -243,10 +255,11 @@ PlayerObject.prototype.finishWork = function(cancelled) {
(this.workStrExpGained / cancMult).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained / cancMult).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>";
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained / cancMult).toFixed(3) + " charisma exp<br>";
} else {
txt = "You worked a full shirt of 8 hours! <br><br> " +
txt = "You worked a full shift of 8 hours! <br><br> " +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained / cancMult) + "<br>" +
(this.workRepGained / cancMult) + " reputation for the company <br>" +
@ -254,13 +267,16 @@ PlayerObject.prototype.finishWork = function(cancelled) {
(this.workStrExpGained / cancMult) + " strength exp <br>" +
(this.workDefExpGained / cancMult) + " defense exp <br>" +
(this.workDexExpGained / cancMult) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult) + " agility exp <br>";
(this.workAgiExpGained / cancMult) + " agility exp <br>" +
(this.workChaExpGained / cancMult) + " charisma exp <br>";
}
dialogBoxCreate(txt);
var mainMenu = document.getElementById("mainmenu-container");
mainMenu.style.visibility = "visible";
Player.isWorking = false;
Engine.loadTerminalContent();
}
@ -272,6 +288,7 @@ PlayerObject.prototype.startWork = function() {
this.workDefExpGainRate = this.getWorkDefExpGain();
this.workDexExpGainRate = this.getWorkDexExpGain();
this.workAgiExpGainRate = this.getWorkAgiExpGain();
this.workChaExpGainRate = this.getWorkChaExpGain();
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
@ -280,14 +297,21 @@ PlayerObject.prototype.startWork = function() {
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
this.timeWorked = 0;
var cancelButton = document.getElementById("work-in-progress-cancel-button");
cancelButton.addEventListener("click", function() {
//Remove all old event listeners from Cancel button
var newCancelButton = cancelButton.cloneNode(true);
cancelButton.parentNode.replaceChild(newCancelButton, cancelButton);
newCancelButton.addEventListener("click", function() {
Player.finishWork(true);
return false;
});
//Display Work In Progress Screen
@ -300,6 +324,7 @@ PlayerObject.prototype.work = function(numCycles) {
this.workDefExpGained += this.workDefExpGainRate * numCycles;
this.workDexExpGained += this.workDexExpGainRate * numCycles;
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
this.workChaExpGained += this.workChaExpGainRate * numCycles;
this.workRepGained += this.workRepGainRate * numCycles;
this.workMoneyGained += this.workMoneyGainRate * numCycles;
@ -307,8 +332,17 @@ PlayerObject.prototype.work = function(numCycles) {
this.timeWorked += Engine._idleSpeed * numCycles;
//TODO If timeWorked == 8 hours, then finish
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
if (this.timeWorked >= 28800000) {
var maxCycles = 144000; //Number of cycles in 8 hours
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
this.workDexExpGained = this.workDexExpGainRate * maxCycles;
this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
this.workChaExpGained = this.workChaExpGainRate * maxCycles;
this.workRepGained = this.workRepGainRate * maxCycles;
this.workMoneyGained = this.workMoneyGainRate * maxCycles;
this.finishWork(false);
}
@ -318,18 +352,167 @@ PlayerObject.prototype.work = function(numCycles) {
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" +
"$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company <br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company <br><br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp <br>" +
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" +
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, <br>" +
"but you will only gain half of the experience, money, and reputation you've earned so far."
}
/* Working for Faction */
PlayerObject.prototype.finishFactionWork = function(cancelled) {
//Since the work was cancelled early, player only gains half of what they've earned so far
var cancMult = 1;
if (cancelled) {
cancMult = 2;
}
if (Engine.Debug) {
console.log("Player finishWork() called with " + this.workMoneyGained / cancMult + " $ gained");
}
this.hacking_exp += (this.workHackExpGained / cancMult);
this.strength_exp += (this.workStrExpGained / cancMult);
this.defense_exp += (this.workDefExpGained / cancMult);
this.dexterity_exp += (this.workDexExpGained / cancMult);
this.agility_exp += (this.workAgiExpGained / cancMult);
this.charisma_exp += (this.workChaExpGained / cancMult);
var company = Companies[this.companyName];
company.playerReputation += (this.workRepGained / cancMult);
this.gainMoney(this.workMoneyGained / cancMult);
this.updateSkillLevels();
var txt = "";
if (cancelled) {
txt = "You worked a short shift of " + convertTimeMsToTimeElapsedString(this.timeWorked) + " <br><br> " +
"Since you cancelled your work early, you only gained half of the experience, money, and reputation you earned. <br><br>" +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained / cancMult).toFixed(2) + "<br>" +
(this.workRepGained / cancMult).toFixed(3) + " reputation for the company <br>" +
(this.workHackExpGained / cancMult).toFixed(3) + " hacking exp <br>" +
(this.workStrExpGained / cancMult).toFixed(3) + " strength exp <br>" +
(this.workDefExpGained / cancMult).toFixed(3) + " defense exp <br>" +
(this.workDexExpGained / cancMult).toFixed(3) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult).toFixed(3) + " agility exp <br>" +
(this.workChaExpGained / cancMult).toFixed(3) + " charisma exp<br>";
} else {
txt = "You worked a full shift of 8 hours! <br><br> " +
"You earned a total of: <br>" +
"$" + (this.workMoneyGained / cancMult) + "<br>" +
(this.workRepGained / cancMult) + " reputation for the company <br>" +
(this.workHackExpGained / cancMult) + " hacking exp <br>" +
(this.workStrExpGained / cancMult) + " strength exp <br>" +
(this.workDefExpGained / cancMult) + " defense exp <br>" +
(this.workDexExpGained / cancMult) + " dexterity exp <br>" +
(this.workAgiExpGained / cancMult) + " agility exp <br>" +
(this.workChaExpGained / cancMult) + " charisma exp <br>";
}
dialogBoxCreate(txt);
var mainMenu = document.getElementById("mainmenu-container");
mainMenu.style.visibility = "visible";
Player.isWorking = false;
Engine.loadTerminalContent();
}
PlayerObject.prototype.startFactionHackWork = function() {
this.isWorking = true;
this.workHackExpGainRate = this.getWorkHackExpGain();
this.workStrExpGainRate = this.getWorkStrExpGain();
this.workDefExpGainRate = this.getWorkDefExpGain();
this.workDexExpGainRate = this.getWorkDexExpGain();
this.workAgiExpGainRate = this.getWorkAgiExpGain();
this.workChaExpGainRate = this.getWorkChaExpGain();
this.workRepGainRate = this.getWorkRepGain();
this.workMoneyGainRate = this.getWorkMoneyGain();
this.workHackExpGained = 0;
this.workStrExpGained = 0;
this.workDefExpGained = 0;
this.workDexExpGained = 0;
this.workAgiExpGained = 0;
this.workChaExpGained = 0;
this.workRepGained = 0;
this.workMoneyGained = 0;
this.timeWorked = 0;
var cancelButton = document.getElementById("work-in-progress-cancel-button");
//Remove all old event listeners from Cancel button
var newCancelButton = cancelButton.cloneNode(true);
cancelButton.parentNode.replaceChild(newCancelButton, cancelButton);
newCancelButton.addEventListener("click", function() {
Player.finishWork(true);
return false;
});
//Display Work In Progress Screen
Engine.loadWorkInProgressContent();
}
PlayerObject.prototype.workForFaction = function(numCycles) {
this.workHackExpGained += this.workHackExpGainRate * numCycles;
this.workStrExpGained += this.workStrExpGainRate * numCycles;
this.workDefExpGained += this.workDefExpGainRate * numCycles;
this.workDexExpGained += this.workDexExpGainRate * numCycles;
this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
this.workChaExpGained += this.workChaExpGainRate * numCycles;
this.workRepGained += this.workRepGainRate * numCycles;
this.workMoneyGained += this.workMoneyGainRate * numCycles;
var cyclesPerSec = 1000 / Engine._idleSpeed;
this.timeWorked += Engine._idleSpeed * numCycles;
//If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
if (this.timeWorked >= 28800000) {
var maxCycles = 144000; //Number of cycles in 8 hours
this.workHackExpGained = this.workhackExpGainRate * maxCycles;
this.workStrExpGained = this.workStrExpGainRate * maxCycles;
this.workDefExpGained = this.workDefExpGainRate * maxCycles;
this.workDexExpGained = this.workDexExpGainRate * maxCycles;
this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
this.workChaExpGained = this.workChaExpGainRate * maxCycles;
this.workRepGained = this.workRepGainRate * maxCycles;
this.workMoneyGained = this.workMoneyGainRate * maxCycles;
this.finishWork(false);
}
var txt = document.getElementById("work-in-progress-text");
txt.innerHTML = "You are currently working as a " + this.companyPosition.positionName +
" at " + Player.companyName + "<br><br>" +
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
"You have earned: <br><br>" +
"$" + this.workMoneyGained + " (" + (this.workMoneyGainRate * cyclesPerSec).toFixed(2) + " / sec) <br><br>" +
this.workRepGained.toFixed(3) + " (" + (this.workRepGainRate * cyclesPerSec).toFixed(3) + " / sec) reputation for this company <br><br>" +
this.workHackExpGained.toFixed(3) + " (" + (this.workHackExpGainRate * cyclesPerSec).toFixed(3) + " / sec) hacking exp <br><br>" +
this.workStrExpGained.toFixed(3) + " (" + (this.workStrExpGainRate * cyclesPerSec).toFixed(3) + " / sec) strength exp <br>" +
this.workDefExpGained.toFixed(3) + " (" + (this.workDefExpGainRate * cyclesPerSec).toFixed(3) + " / sec) defense exp <br>" +
this.workDexExpGained.toFixed(3) + " (" + (this.workDexExpGainRate * cyclesPerSec).toFixed(3) + " / sec) dexterity exp <br>" +
this.workAgiExpGained.toFixed(3) + " (" + (this.workAgiExpGainRate * cyclesPerSec).toFixed(3) + " / sec) agility exp <br><br> " +
this.workChaExpGained.toFixed(3) + " (" + (this.workChaExpGainRate * cyclesPerSec).toFixed(3) + " / sec) charisma exp <br><br>" +
"You will automatically finish after working for 8 hours. You can cancel earlier if you wish, <br>" +
"but you will only gain half of the experience, money, and reputation you've earned so far."
}
//Money gained per game cycle
PlayerObject.prototype.getWorkMoneyGain = function() {
var company = Companies[this.companyName];
@ -339,9 +522,6 @@ PlayerObject.prototype.getWorkMoneyGain = function() {
//Hack exp gained per game cycle
PlayerObject.prototype.getWorkHackExpGain = function() {
var company = Companies[this.companyName];
if (Engine.Debug) {
console.log(company.companyName);
}
return this.companyPosition.hackingExpGain * company.expMultiplier * this.hacking_exp_mult;
}
@ -369,6 +549,12 @@ PlayerObject.prototype.getWorkAgiExpGain = function() {
return this.companyPosition.agilityExpGain * company.expMultiplier * this.agility_exp_mult;
}
//Charisma exp gained per game cycle
PlayerObject.prototype.getWorkChaExpGain = function() {
var company = Companies[this.companyName];
return this.companyPosition.charismaExpGain * company.expMultiplier * this.charisma_exp_mult;
}
//Reputation gained per game cycle
PlayerObject.prototype.getWorkRepGain = function() {
return this.companyPosition.calculateJobPerformance(this.hacking_skill, this.strength,

@ -14,11 +14,18 @@ purchaseServer = function(ram, cost) {
return;
}
newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram);
//Create server
newServ.init(createRandomIp(), hostname, "", true, false, true, true, ram);
AddToAllServers(newServ);
//Add to Player's purchasedServers array
Player.purchasedServers.push(newServ);
//Connect new server to home computer
var homeComputer = Player.getHomeComputer();
homeComputer.serversOnNetwork.push(newServ);
Player.money -= cost;
dialogBoxCreate("Server successfully purchased with hostname " + hostname);

@ -183,7 +183,7 @@ initForeignServers = function() {
FulcrumSecretTechnologiesServer.setPortProperties(5);
AddToAllServers(FulcrumSecretTechnologiesServer);
SpecialServerIps.fulcrumSecretServer = FulcrumSecretTechnologiesServer.ip;
SpecialServerIps.addIp("Fulcrum Secret Technologies Server", FulcrumSecretTechnologiesServer.ip);
var StormTechnologiesServer = new Server();
StormTechnologiesServer.init(createRandomIp(), "stormtech", "Storm Technologies", true, false, false, false, 256);

@ -1,5 +1,19 @@
/* Holds IP of Special Servers */
SpecialServerIps = {
fulcrumSecretServer: "",
function SpecialServerIpsMap() {
}
};
SpecialServerIpsMap.prototype.addIp = function(name, ip) {
this[name] = ip;
}
SpecialServerIpsMap.prototype.toJSON = function() {
return Generic_toJSON("SpecialServerIpsMap", this);
}
SpecialServerIpsMap.fromJSON = function(value) {
return Generic_fromJSON(SpecialServerIpsMap, value.data);
}
Reviver.constructors.SpecialServerIpsMap = SpecialServerIpsMap();
SpecialServerIps = null;

@ -340,7 +340,7 @@ var Terminal = {
//Can only edit script files
if (filename.endsWith(".script") == false) {
post("Error: Only .script files are editable with nano (filename must end with .scrip)"); return;
post("Error: Only .script files are editable with nano (filename must end with .script)"); return;
}
//Script name is the filename without the .script at the end
@ -448,7 +448,7 @@ var Terminal = {
return;
}
}
post("ERROR: No such executable on home computer (Programs can only be run from home computer)");
post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)");
},
//Contains the implementations of all possible programs

@ -61,6 +61,7 @@ var Engine = {
Augmentations: "Augmentations",
Tutorial: "Tutorial",
Location: "Location",
workInProgress: "WorkInProgress",
},
currentPage: null,
@ -75,12 +76,14 @@ var Engine = {
var AllServersSave = JSON.stringify(AllServers);
var CompaniesSave = JSON.stringify(Companies);
var FactionsSave = JSON.stringify(Factions);
//TODO Add factions + companies here when they're done
var SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
window.localStorage.setItem("netburnerPlayerSave", PlayerSave);
window.localStorage.setItem("netburnerAllServersSave", AllServersSave);
window.localStorage.setItem("netburnerCompaniesSave", CompaniesSave);
window.localStorage.setItem("netburnerFactionsSave", FactionsSave);
window.localStorage.setItem("netburnerSpecialServerIpsSave", SpecialServerIpsSave);
console.log("Game saved to local storage");
},
@ -99,15 +102,21 @@ var Engine = {
} else if (!window.localStorage.getItem("netburnerFactionsSave")) {
console.log("No Factions save to load");
return false;
} else if (!window.localStorage.getItem("netburnerSpecialServerIpsSave")) {
console.log("No Special Server Ips save to load");
return false;
} else {
var PlayerSave = window.localStorage.getItem("netburnerPlayerSave");
var AllServersSave = window.localStorage.getItem("netburnerAllServersSave");
var CompaniesSave = window.localStorage.getItem("netburnerCompaniesSave");
var FactionsSave = window.localStorage.getItem("netburnerFactionsSave");
var SpecialServerIpsSave = window.localStorage.getItem("netburnerSpecialServerIpsSave");
Player = JSON.parse(PlayerSave, Reviver);
AllServers = JSON.parse(AllServersSave, Reviver);
Companies = JSON.parse(CompaniesSave, Reviver);
Factions = JSON.parse(FactionsSave, Reviver);
SpecialServerIps = JSON.parse(SpecialServerIpsSave, Reviver);
return true;
}
},
@ -116,25 +125,24 @@ var Engine = {
deleteSave: function() {
//TODO if a save doesn't exist..maybe I shouldn't return? I just keep going
//or else nothing gets deleted. TODO Fix this
if (!window.localStorage.getItem("netburnerPlayerSave")) {
console.log("No Player Save to delete");
return false;
} else if (!window.localStorage.getItem("netburnerAllServersSave")) {
console.log("No AllServers Save to delete");
return false;
} else if (!window.localStorage.getItem("netburnerCompaniesSave")) {
console.log("No Companies Save to delete");
return false;
} else if (!window.localStorage.getItem("netburnerFactionsSave")) {
console.log("No Factions Save to delete");
return false;
} else {
if (window.localStorage.getItem("netburnerPlayerSave")) {
window.localStorage.removeItem("netburnerPlayerSave");
}
if (window.localStorage.getItem("netburnerAllServersSave")) {
window.localStorage.removeItem("netburnerAllServersSave");
}
if (window.localStorage.getItem("netburnerCompaniesSave")) {
window.localStorage.removeItem("netburnerCompaniesSave");
}
if (window.localStorage.getItem("netburnerFactionsSave")) {
window.localStorage.removeItem("netburnerFactionsSave");
console.log("Deleted saves")
return true;
}
if (window.localStorage.getItem("netburnerSpecialServerIpsSave")) {
window.localStorage.removeItem("netburnerSpecialServerIpsSave");
}
},
@ -230,6 +238,7 @@ var Engine = {
Engine.Display.workInProgressContent.style.visibility = "visible";
Engine.currentPage = Engine.Page.WorkInProgress;
},
//Helper function that hides all content
@ -273,7 +282,12 @@ var Engine = {
'Agility: ' + Player.agility + '<br><br>' +
'Charisma: ' + Player.charisma + '<br><br>' +
'Servers owned: ' + Player.purchasedServers.length + '<br><br>' +
'Hacking Experience: ' + Player.hacking_exp.toFixed(4) + '<br><br>';
'Hacking experience: ' + Player.hacking_exp.toFixed(4) + '<br><br>' +
'Strength experience: ' + Player.strength_exp.toFixed(4) + '<br><br>' +
'Defense experience: ' + Player.defense_exp.toFixed(4) + '<br><br>' +
'Dexterity experience: ' + Player.dexterity_exp.toFixed(4) + '<br><br>' +
'Agility experience: ' + Player.agility_exp.toFixed(4) + '<br><br>' +
'Charisma experience: ' + Player.charisma_exp.toFixed(4) + '<br><br>';
},
/* Display locations in the world*/
@ -460,6 +474,8 @@ var Engine = {
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
updateDisplays: 10, //Update displays such as Active Scripts display and character display
serverGrowth: 450, //Process server growth every minute and a half
//checkFactionInvitations: 1500, //Check whether you qualify for any faction invitations every 5 minutes
checkFactionInvitations: 30,
},
decrementAllCounters: function(numCycles = 1) {
@ -498,6 +514,15 @@ var Engine = {
processServerGrowth(numCycles);
Engine.Counters.serverGrowth = 450;
}
if (Engine.Counters.checkFactionInvitations <= 0) {
var invitedFactions = Player.checkForFactionInvitations();
if (invitedFactions.length > 0) {
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
inviteToFaction(randFaction);
}
Engine.Counters.checkFactionInvitations = 1500;
}
},
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
@ -536,28 +561,6 @@ var Engine = {
/* Initialization */
init: function() {
//Initialization functions
if (Engine.loadSave()) {
console.log("Loaded game from save");
CompanyPositions.init();
//Calculate the number of cycles have elapsed while offline
var thisUpdate = new Date().getTime();
var lastUpdate = Player.lastUpdate;
var numCyclesOffline = Math.floor((thisUpdate - lastUpdate) / Engine._idleSpeed);
processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts
loadAllRunningScripts(); //This also takes care of offline production for those scripts
} else {
//No save found, start new game
console.log("Initializing new game");
Player.init();
initForeignServers();
initCompanies();
initFactions();
CompanyPositions.init();
}
//Main menu buttons and content
Engine.Clickables.terminalMainMenuButton = document.getElementById("terminal-menu-link");
Engine.Clickables.terminalMainMenuButton.addEventListener("click", function() {
@ -684,12 +687,48 @@ var Engine = {
//Script editor
Engine.Display.scriptEditorText = document.getElementById("script-editor-text");
//Load game from save or create new game
if (Engine.loadSave()) {
console.log("Loaded game from save");
CompanyPositions.init();
//Calculate the number of cycles have elapsed while offline
var thisUpdate = new Date().getTime();
var lastUpdate = Player.lastUpdate;
var numCyclesOffline = Math.floor((thisUpdate - lastUpdate) / Engine._idleSpeed);
processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts
loadAllRunningScripts(); //This also takes care of offline production for those scripts
Player.work(numCyclesOffline);
} else {
//No save found, start new game
console.log("Initializing new game");
SpecialServerIps = new SpecialServerIpsMap();
Player.init();
initForeignServers();
initCompanies();
initFactions();
CompanyPositions.init();
}
//Message at the top of terminal
postNetburnerText();
//Player was working
if (Player.isWorking) {
var cancelButton = document.getElementById("work-in-progress-cancel-button");
cancelButton.addEventListener("click", function() {
Player.finishWork(true);
});
Engine.loadWorkInProgressContent();
}
//Run main loop
Engine.idleTimer();
//Scripts
runScriptsLoop();
}
};

@ -0,0 +1,50 @@
/* Faction Invitation Pop-up box */
function factionInvitationBoxInit() {
if (Engine.Debug) {
console.log("Faction Invitation Box Initialized");
}
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() {
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
factionInvitationBox.style.display = "none";
}
factionInvitationBoxOpen = function() {
var factionInvitationBox = document.getElementById("faction-invitation-box-container");
factionInvitationBox.style.display = "block";
}
factionInvitationSetText = function(txt) {
var textBox = document.getElementById("faction-invitation-box-text");
textBox.innerHTML = txt;
}
factionInvitationSetMessage = function(msg) {
var msgBox = document.getElementById("faction-invitation-box-message");
msgBox.innerHTML = msg;
}
//ram argument is in GB
factionInvitationBoxCreate = function(faction) {
factionInvitationSetText("You have received a faction invitation from " + faction.name);
//TODO Faction invitation message
var yesButton = document.getElementById("faction-invitation-box-yes");
yesButton.addEventListener("click", function() {
joinFaction(faction);
factionInvitationBoxClose();
return false;
});
factionInvitationBoxOpen();
}