mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
refactored saving/loading by making it into a class. Tested and debugged prestige mechanic
This commit is contained in:
parent
2c53073f21
commit
56ebfaf2bf
@ -104,6 +104,11 @@
|
|||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active-scripts-list > li {
|
||||||
|
margin: 6px;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
.active-scripts-list>li h2{
|
.active-scripts-list>li h2{
|
||||||
color: #66ff33;
|
color: #66ff33;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
@ -290,6 +295,19 @@
|
|||||||
color: #66ff33;
|
color: #66ff33;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#augmentations-list > li {
|
||||||
|
margin: 6px;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#augmentations-list > li h2{
|
||||||
|
color: #66ff33;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-left: 10px;
|
||||||
|
background-color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
.installed-augmentation {
|
.installed-augmentation {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
<script src="src/Perk.js"></script>
|
<script src="src/Perk.js"></script>
|
||||||
<script src="src/HacknetNode.js"></script>
|
<script src="src/HacknetNode.js"></script>
|
||||||
<script src="src/Crimes.js"></script>
|
<script src="src/Crimes.js"></script>
|
||||||
|
<script src="src/Prestige.js"></script>
|
||||||
|
<script src="src/SaveObject.js"></script>
|
||||||
|
|
||||||
<script src="src/engine.js"></script>
|
<script src="src/engine.js"></script>
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ CONSTANTS = {
|
|||||||
"free Check the machine's memory (RAM) usage<br>" +
|
"free Check the machine's memory (RAM) usage<br>" +
|
||||||
"hack Hack the current machine<br>" +
|
"hack Hack the current machine<br>" +
|
||||||
"help Display this help text<br>" +
|
"help Display this help text<br>" +
|
||||||
|
"home Connect to home computer<br>" +
|
||||||
"hostname Displays the hostname of the machine<br>" +
|
"hostname Displays the hostname of the machine<br>" +
|
||||||
"ifconfig Displays the IP address of the machine<br>" +
|
"ifconfig Displays the IP address of the machine<br>" +
|
||||||
"kill [script name] Stops a script that is running on the current machine<br>" +
|
"kill [script name] Stops a script that is running on the current machine<br>" +
|
||||||
|
@ -582,7 +582,7 @@ function isScriptErrorMessage(msg) {
|
|||||||
//The same as Player's calculateHackingChance() function but takes in the server as an argument
|
//The same as Player's calculateHackingChance() function but takes in the server as an argument
|
||||||
function scriptCalculateHackingChance(server) {
|
function scriptCalculateHackingChance(server) {
|
||||||
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
||||||
var skillMult = (Player.hacking_chance_mult * Player.hacking_skill);
|
var skillMult = (2 * Player.hacking_chance_mult * Player.hacking_skill);
|
||||||
var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
|
var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
|
||||||
var chance = skillChance * difficultyMult;
|
var chance = skillChance * difficultyMult;
|
||||||
if (chance < 0) {return 0;}
|
if (chance < 0) {return 0;}
|
||||||
@ -593,7 +593,7 @@ function scriptCalculateHackingChance(server) {
|
|||||||
function scriptCalculateHackingTime(server) {
|
function scriptCalculateHackingTime(server) {
|
||||||
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
||||||
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50);
|
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50);
|
||||||
var hackingTime = skillFactor * Player.hacking_speed_mult; //This is in seconds
|
var hackingTime = skillFactor * Player.hacking_speed_mult * 5; //This is in seconds
|
||||||
return hackingTime;
|
return hackingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ function scriptCalculateExpGain(server) {
|
|||||||
function scriptCalculatePercentMoneyHacked(server) {
|
function scriptCalculatePercentMoneyHacked(server) {
|
||||||
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
||||||
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
|
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
|
||||||
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult;
|
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 1000;
|
||||||
if (percentMoneyHacked < 0) {return 0;}
|
if (percentMoneyHacked < 0) {return 0;}
|
||||||
if (percentMoneyHacked > 1) {return 1;}
|
if (percentMoneyHacked > 1) {return 1;}
|
||||||
return percentMoneyHacked;
|
return percentMoneyHacked;
|
||||||
|
@ -14,10 +14,9 @@ function PlayerObject() {
|
|||||||
//Intelligence, perhaps?
|
//Intelligence, perhaps?
|
||||||
|
|
||||||
//Hacking multipliers
|
//Hacking multipliers
|
||||||
this.hacking_chance_mult = 2; //Increase through ascensions/augmentations
|
this.hacking_chance_mult = 1; //Increase through ascensions/augmentations
|
||||||
this.hacking_speed_mult = 5; //Decrease through ascensions/augmentations
|
this.hacking_speed_mult = 1; //Decrease through ascensions/augmentations
|
||||||
//this.hacking_speed_mult = 1; //Make it faster for debugging
|
this.hacking_money_mult = 1; //Increase through ascensions/augmentations. Can't go above 1
|
||||||
this.hacking_money_mult = .001; //Increase through ascensions/augmentations. Can't go above 1
|
|
||||||
|
|
||||||
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
|
//Note: "Lifetime" refers to current ascension, "total" refers to the entire game history
|
||||||
//Accumulative stats and skills
|
//Accumulative stats and skills
|
||||||
@ -101,7 +100,7 @@ function PlayerObject() {
|
|||||||
this.numTimesDealtDrugsLifetime = 0;
|
this.numTimesDealtDrugsLifetime = 0;
|
||||||
this.numTimesTraffickArms = 0;
|
this.numTimesTraffickArms = 0;
|
||||||
this.numTimesTraffickArmsTotal = 0;
|
this.numTimesTraffickArmsTotal = 0;
|
||||||
this.numTimesTrafficksArmsLifetime = 0;
|
this.numTimesTraffickArmsLifetime = 0;
|
||||||
this.numPeopleKilled = 0;
|
this.numPeopleKilled = 0;
|
||||||
this.numPeopleKilledTotal = 0;
|
this.numPeopleKilledTotal = 0;
|
||||||
this.numPeopleKilledLifetime = 0;
|
this.numPeopleKilledLifetime = 0;
|
||||||
@ -207,7 +206,7 @@ PlayerObject.prototype.updateSkillLevels = function() {
|
|||||||
// (hacking_chance_multiplier * hacking_skill) 100
|
// (hacking_chance_multiplier * hacking_skill) 100
|
||||||
PlayerObject.prototype.calculateHackingChance = function() {
|
PlayerObject.prototype.calculateHackingChance = function() {
|
||||||
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
||||||
var skillMult = (this.hacking_chance_mult * this.hacking_skill);
|
var skillMult = (2 * this.hacking_chance_mult * this.hacking_skill);
|
||||||
var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult;
|
var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult;
|
||||||
var chance = skillChance * difficultyMult;
|
var chance = skillChance * difficultyMult;
|
||||||
if (chance < 0) {return 0;}
|
if (chance < 0) {return 0;}
|
||||||
@ -222,7 +221,7 @@ PlayerObject.prototype.calculateHackingChance = function() {
|
|||||||
PlayerObject.prototype.calculateHackingTime = function() {
|
PlayerObject.prototype.calculateHackingTime = function() {
|
||||||
var difficultyMult = this.getCurrentServer().requiredHackingSkill * this.getCurrentServer().hackDifficulty;
|
var difficultyMult = this.getCurrentServer().requiredHackingSkill * this.getCurrentServer().hackDifficulty;
|
||||||
var skillFactor = (2.5 * difficultyMult + 200) / (this.hacking_skill + 100);
|
var skillFactor = (2.5 * difficultyMult + 200) / (this.hacking_skill + 100);
|
||||||
return skillFactor * this.hacking_speed_mult;
|
return skillFactor * this.hacking_speed_mult * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculates the PERCENTAGE of a server's money that the player will hack from the server if successful
|
//Calculates the PERCENTAGE of a server's money that the player will hack from the server if successful
|
||||||
@ -233,7 +232,7 @@ PlayerObject.prototype.calculateHackingTime = function() {
|
|||||||
PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
||||||
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
||||||
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
|
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
|
||||||
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult;
|
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 1000;
|
||||||
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
||||||
if (percentMoneyHacked < 0) {return 0;}
|
if (percentMoneyHacked < 0) {return 0;}
|
||||||
if (percentMoneyHacked > 1) {return 1;}
|
if (percentMoneyHacked > 1) {return 1;}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
//Prestige by purchasing augmentation
|
//Prestige by purchasing augmentation
|
||||||
function prestigeAugmentation() {
|
function prestigeAugmentation() {
|
||||||
|
//Sum up lifetime/total statistics
|
||||||
Player.total_hacking += Player.hacking_skill;
|
Player.total_hacking += Player.hacking_skill;
|
||||||
Player.lifetime_hacking += Player.hacking_skill;
|
Player.lifetime_hacking += Player.hacking_skill;
|
||||||
Player.total_strength += Player.strength;
|
Player.total_strength += Player.strength;
|
||||||
@ -15,6 +16,27 @@ function prestigeAugmentation() {
|
|||||||
Player.total_charisma += Player.charisma;
|
Player.total_charisma += Player.charisma;
|
||||||
Player.lifetime_charisma += Player.charisma;
|
Player.lifetime_charisma += Player.charisma;
|
||||||
|
|
||||||
|
//Crime statistics
|
||||||
|
Player.numTimesShopliftedTotal += Player.numTimesShoplifted;
|
||||||
|
Player.numTimesShopliftedLifetime += Player.numTimesShoplifted;
|
||||||
|
Player.numTimesShoplifted = 0;
|
||||||
|
Player.numPeopleMuggedTotal += Player.numPeopleMugged;
|
||||||
|
Player.numPeopleMuggedLifetime += Player.numPeopleMugged;
|
||||||
|
Player.numPeopleMugged = 0;
|
||||||
|
Player.numTimesDealtDrugsTotal += Player.numTimesDealtDrugs;
|
||||||
|
Player.numTimesDealtDrugsLifetime += Player.numTimesDealtDrugs;
|
||||||
|
Player.numTimesDealtDrugs = 0;
|
||||||
|
Player.numTimesTraffickArmsTotal += Player.numTimesTraffickArms;
|
||||||
|
Player.numTimesTraffickArmsLifetime += Player.numTimesTraffickArms;
|
||||||
|
Player.numTimesTraffickArms = 0;
|
||||||
|
Player.numPeopleKilledTotal += Player.numPeopleKilled;
|
||||||
|
Player.numPeopleKilledLifetime += Player.numPeopleKilled;
|
||||||
|
Player.numPeopleKilled = 0;
|
||||||
|
Player.numTimesKidnappedTotal += Player.numTimesKidnapped;
|
||||||
|
Player.numTimesKidnappedLifetime += Player.numTimesKidnapped;
|
||||||
|
Player.numTimesKidnapped = 0;
|
||||||
|
|
||||||
|
//Reset stats
|
||||||
Player.hacking_skill = 1;
|
Player.hacking_skill = 1;
|
||||||
|
|
||||||
Player.strength = 1;
|
Player.strength = 1;
|
||||||
@ -53,6 +75,9 @@ function prestigeAugmentation() {
|
|||||||
Player.isWorking = false;
|
Player.isWorking = false;
|
||||||
Player.currentWorkFactionName = "";
|
Player.currentWorkFactionName = "";
|
||||||
Player.currentWorkFactionDescription = "";
|
Player.currentWorkFactionDescription = "";
|
||||||
|
this.createProgramName = "";
|
||||||
|
this.className = "";
|
||||||
|
this.crimeType = "";
|
||||||
|
|
||||||
Player.workHackExpGainRate = 0;
|
Player.workHackExpGainRate = 0;
|
||||||
Player.workStrExpGainRate = 0;
|
Player.workStrExpGainRate = 0;
|
||||||
@ -82,6 +107,20 @@ function prestigeAugmentation() {
|
|||||||
}
|
}
|
||||||
AllServers = {};
|
AllServers = {};
|
||||||
|
|
||||||
|
//Delete all running scripts objects
|
||||||
|
for (var i = 0; i < workerScripts.length; ++i) {
|
||||||
|
workerScripts[i].env.stopFlag = true;
|
||||||
|
}
|
||||||
|
//Delete active scripts display elements
|
||||||
|
var list = Engine.ActiveScriptsList.querySelectorAll('#active-scripts-list li');
|
||||||
|
for (var i = list.length-1; i >= 0; --i) {
|
||||||
|
Engine.deleteActiveScriptsItem(i);
|
||||||
|
}
|
||||||
|
workerScripts.length = 0;
|
||||||
|
|
||||||
|
//Delete Hacknet Nodes
|
||||||
|
Player.hacknetNodes.length = 0;
|
||||||
|
|
||||||
//Delete Special Server IPs
|
//Delete Special Server IPs
|
||||||
for (var member in SpecialServerIps) {
|
for (var member in SpecialServerIps) {
|
||||||
delete SpecialServerIps[member];
|
delete SpecialServerIps[member];
|
||||||
@ -107,4 +146,6 @@ function prestigeAugmentation() {
|
|||||||
initCompanies();
|
initCompanies();
|
||||||
initFactions();
|
initFactions();
|
||||||
CompanyPositions.init();
|
CompanyPositions.init();
|
||||||
|
|
||||||
|
Engine.loadTerminalContent();
|
||||||
}
|
}
|
59
src/SaveObject.js
Normal file
59
src/SaveObject.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* SaveObject.js
|
||||||
|
* Defines the object used to save/load games
|
||||||
|
*/
|
||||||
|
var saveObject = new BitburnerSaveObject();
|
||||||
|
|
||||||
|
function BitburnerSaveObject() {
|
||||||
|
this.PlayerSave = "";
|
||||||
|
this.AllServersSave = "";
|
||||||
|
this.CompaniesSave = "";
|
||||||
|
this.FactionsSave = "";
|
||||||
|
this.SpecialServerIpsSave = "";
|
||||||
|
this.AugmentationsSave = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
BitburnerSaveObject.prototype.saveGame = 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);
|
||||||
|
|
||||||
|
var saveString = JSON.stringify(this);
|
||||||
|
window.localStorage.setItem("bitburnerSave", saveString);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadGame = function(saveObj) {
|
||||||
|
if (!window.localStorage.getItem("bitburnerSave")) {
|
||||||
|
console.log("No save file to load");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var saveString = window.localStorage.getItem("bitburnerSave");
|
||||||
|
saveObj = JSON.parse(saveString, Reviver);
|
||||||
|
|
||||||
|
Player = JSON.parse(saveObj.PlayerSave, Reviver);
|
||||||
|
AllServers = JSON.parse(saveObj.AllServersSave, Reviver);
|
||||||
|
Companies = JSON.parse(saveObj.CompaniesSave, Reviver);
|
||||||
|
Factions = JSON.parse(saveObj.FactionsSave, Reviver);
|
||||||
|
SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver);
|
||||||
|
Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BitburnerSaveObject.prototype.deleteGame = function() {
|
||||||
|
if (window.localStorage.getItem("bitburnerSave")) {
|
||||||
|
window.localStorage.removeItem("bitburnerSave");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BitburnerSaveObject.prototype.toJSON = function() {
|
||||||
|
return Generic_toJSON("BitburnerSaveObject", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
BitburnerSaveObject.fromJSON = function(value) {
|
||||||
|
return Generic_fromJSON(BitburnerSaveObject, value.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;
|
@ -201,8 +201,8 @@ scriptCalculateOfflineProduction = function(script) {
|
|||||||
|
|
||||||
//Calculate the "confidence" rating of the script's true production. This is based
|
//Calculate the "confidence" rating of the script's true production. This is based
|
||||||
//entirely off of time. We will arbitrarily say that if a script has been running for
|
//entirely off of time. We will arbitrarily say that if a script has been running for
|
||||||
//120 minutes (7200 sec) then we are completely confident in its ability
|
//4 hours (14400 sec) then we are completely confident in its ability
|
||||||
var confidence = (script.onlineRunningTime) / 7200;
|
var confidence = (script.onlineRunningTime) / 14400;
|
||||||
if (confidence >= 1) {confidence = 1;}
|
if (confidence >= 1) {confidence = 1;}
|
||||||
console.log("onlineRunningTime: " + script.onlineRunningTime.toString());
|
console.log("onlineRunningTime: " + script.onlineRunningTime.toString());
|
||||||
console.log("Confidence: " + confidence.toString());
|
console.log("Confidence: " + confidence.toString());
|
||||||
@ -214,11 +214,15 @@ scriptCalculateOfflineProduction = function(script) {
|
|||||||
var expGain = (1/2) * (script.onlineExpGained / script.onlineRunningTime) * timePassed;
|
var expGain = (1/2) * (script.onlineExpGained / script.onlineRunningTime) * timePassed;
|
||||||
expGain *= confidence;
|
expGain *= confidence;
|
||||||
|
|
||||||
//Account for production in Player and server
|
//Account for production in Player and server)
|
||||||
Player.gainMoney(production);
|
var server = AllServers[script.server];
|
||||||
Player.hacking_exp += expGain;
|
if (production > server.moneyAvailable) {
|
||||||
|
production = server.moneyAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player.gainMoney(production);
|
||||||
|
Player.gainHackingExp(expGain);
|
||||||
|
|
||||||
var server = AllServers[script.server];
|
|
||||||
server.moneyAvailable -= production;
|
server.moneyAvailable -= production;
|
||||||
if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
|
if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
|
||||||
|
|
||||||
|
@ -113,7 +113,6 @@ $(document).keydown(function(event) {
|
|||||||
arg = commandArray[1];
|
arg = commandArray[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("arg: " + arg);
|
|
||||||
tabCompletion(commandArray[0], arg, allPos);
|
tabCompletion(commandArray[0], arg, allPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -438,7 +437,13 @@ var Terminal = {
|
|||||||
post(CONSTANTS.HelpText);
|
post(CONSTANTS.HelpText);
|
||||||
break;
|
break;
|
||||||
case "home":
|
case "home":
|
||||||
//TODO return to home computer
|
if (commandArray.length != 1) {
|
||||||
|
post("Incorrect usage of home command. Usage: home"); return;
|
||||||
|
}
|
||||||
|
Player.getCurrentServer().isConnectedTo = false;
|
||||||
|
Player.currentServer = Player.getHomeComputer().ip;
|
||||||
|
Player.getCurrentServer().isConnectedTo = true;
|
||||||
|
post("Connected to home");
|
||||||
break;
|
break;
|
||||||
case "hostname":
|
case "hostname":
|
||||||
if (commandArray.length != 1) {
|
if (commandArray.length != 1) {
|
||||||
|
132
src/engine.js
132
src/engine.js
@ -85,92 +85,6 @@ var Engine = {
|
|||||||
_lastUpdate: new Date().getTime(),
|
_lastUpdate: new Date().getTime(),
|
||||||
_idleSpeed: 200, //Speed (in ms) at which the main loop is updated
|
_idleSpeed: 200, //Speed (in ms) at which the main loop is updated
|
||||||
|
|
||||||
//Save function
|
|
||||||
saveGame: function() {
|
|
||||||
var PlayerSave = JSON.stringify(Player);
|
|
||||||
var AllServersSave = JSON.stringify(AllServers);
|
|
||||||
var CompaniesSave = JSON.stringify(Companies);
|
|
||||||
var FactionsSave = JSON.stringify(Factions);
|
|
||||||
var SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
|
|
||||||
var AugmentationsSave = JSON.stringify(Augmentations);
|
|
||||||
|
|
||||||
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);
|
|
||||||
window.localStorage.setItem("netburnerAugmentationsSave", AugmentationsSave);
|
|
||||||
|
|
||||||
console.log("Game saved to local storage");
|
|
||||||
},
|
|
||||||
|
|
||||||
//Load saved game function
|
|
||||||
loadSave: function() {
|
|
||||||
//Check to see if file exists
|
|
||||||
if (!window.localStorage.getItem("netburnerPlayerSave")) {
|
|
||||||
console.log("No Player save to load");
|
|
||||||
return false;
|
|
||||||
} else if (!window.localStorage.getItem("netburnerAllServersSave")) {
|
|
||||||
console.log("No AllServers save to load");
|
|
||||||
return false;
|
|
||||||
} else if (!window.localStorage.getItem("netburnerCompaniesSave")) {
|
|
||||||
console.log("No Companies save to load");
|
|
||||||
return false;
|
|
||||||
} 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 if (!window.localStorage.getItem("netburnerAugmentationsSave")) {
|
|
||||||
console.log("No Augmentations 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");
|
|
||||||
var AugmentationsSave = window.localStorage.getItem("netburnerAugmentationsSave");
|
|
||||||
|
|
||||||
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);
|
|
||||||
Augmentations = JSON.parse(AugmentationsSave, Reviver);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
//Delete saved game function
|
|
||||||
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")) {
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.localStorage.getItem("netburnerSpecialServerIpsSave")) {
|
|
||||||
window.localStorage.removeItem("netburnerSpecialServerIpsSave");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.localStorage.getItem("netburnerAugmentationsSave")) {
|
|
||||||
window.localStorage.removeItem("netburnerAugmentationsSave");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/* Load content when a main menu button is clicked */
|
/* Load content when a main menu button is clicked */
|
||||||
loadTerminalContent: function() {
|
loadTerminalContent: function() {
|
||||||
@ -312,7 +226,7 @@ var Engine = {
|
|||||||
companyPosition = Player.companyPosition.positionName;
|
companyPosition = Player.companyPosition.positionName;
|
||||||
}
|
}
|
||||||
Engine.Display.characterInfo.innerHTML =
|
Engine.Display.characterInfo.innerHTML =
|
||||||
'<b>General</b><br><br>' +
|
('<b>General</b><br><br>' +
|
||||||
'Current City: ' + Player.city + '<br><br>' +
|
'Current City: ' + Player.city + '<br><br>' +
|
||||||
'Employer: ' + Player.companyName + '<br>' +
|
'Employer: ' + Player.companyName + '<br>' +
|
||||||
'Job Title: ' + companyPosition + '<br><br>' +
|
'Job Title: ' + companyPosition + '<br><br>' +
|
||||||
@ -320,43 +234,43 @@ var Engine = {
|
|||||||
'<b>Stats</b><br><br>' +
|
'<b>Stats</b><br><br>' +
|
||||||
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
|
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
|
||||||
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +
|
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +
|
||||||
'Strength: ' + (Player.strength).toLocaleString() +
|
'Strength: ' + (Player.strength).toLocaleString() +
|
||||||
" (" + formatNumber(Player.strength_exp, 4) + ' experience)<br>' +
|
" (" + formatNumber(Player.strength_exp, 4) + ' experience)<br>' +
|
||||||
'Defense: ' + (Player.defense).toLocaleString() +
|
'Defense: ' + (Player.defense).toLocaleString() +
|
||||||
" (" + formatNumber(Player.defense_exp, 4) + ' experience)<br>' +
|
" (" + formatNumber(Player.defense_exp, 4) + ' experience)<br>' +
|
||||||
'Dexterity: ' + (Player.dexterity).toLocaleString() +
|
'Dexterity: ' + (Player.dexterity).toLocaleString() +
|
||||||
" (" + formatNumber(Player.dexterity_exp, 4) + ' experience)<br>' +
|
" (" + formatNumber(Player.dexterity_exp, 4) + ' experience)<br>' +
|
||||||
'Agility: ' + (Player.agility).toLocaleString() +
|
'Agility: ' + (Player.agility).toLocaleString() +
|
||||||
" (" + formatNumber(Player.agility_exp, 4) + ' experience)<br>' +
|
" (" + formatNumber(Player.agility_exp, 4) + ' experience)<br>' +
|
||||||
'Charisma: ' + (Player.charisma).toLocaleString() +
|
'Charisma: ' + (Player.charisma).toLocaleString() +
|
||||||
" (" + formatNumber(Player.charisma_exp, 4) + ' experience)<br><br><br>' +
|
" (" + formatNumber(Player.charisma_exp, 4) + ' experience)<br><br><br>' +
|
||||||
'<b>Multipliers</b><br><br>' +
|
'<b>Multipliers</b><br><br>' +
|
||||||
'Hacking Chance multiplier: ' + formatNumber(Player.hacking_chance_mult * 100, 2) + '%<br>' +
|
'Hacking Chance multiplier: ' + formatNumber(Player.hacking_chance_mult * 100, 2) + '%<br>' +
|
||||||
'Hacking Speed multiplier: ' + formatNumber(Player.hacking_speed_mult * 100, 2) + '%<br>' +
|
'Hacking Speed multiplier: ' + formatNumber(Player.hacking_speed_mult * 100, 2) + '%<br>' +
|
||||||
'Hacking money multiplier: ' + formatNumber(Player.hacking_money_mult * 100, 2) + '%<br><br>' +
|
'Hacking money multiplier: ' + formatNumber(Player.hacking_money_mult * 100, 2) + '%<br><br>' +
|
||||||
'Hacking Level multiplier: ' + formatNumber(Player.hacking_mult * 100, 2) + '%<br>' +
|
'Hacking Level multiplier: ' + formatNumber(Player.hacking_mult * 100, 2) + '%<br>' +
|
||||||
'Hacking Experience multiplier: ' + formatNumber(Player.hacking_exp_mult * 100, 2) + '%<br><br>' +
|
'Hacking Experience multiplier: ' + formatNumber(Player.hacking_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Strength Level multiplier: ' + formatNumber(Player.strength_mult * 100, 2) + '%<br>' +
|
'Strength Level multiplier: ' + formatNumber(Player.strength_mult * 100, 2) + '%<br>' +
|
||||||
'Strength Experience multiplier: ' + formatNumber(Player.strength_exp_mult * 100, 2) + '%<br><br>' +
|
'Strength Experience multiplier: ' + formatNumber(Player.strength_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Defense Level multiplier: ' + formatNumber(Player.defense_mult * 100, 2) + '%<br>' +
|
'Defense Level multiplier: ' + formatNumber(Player.defense_mult * 100, 2) + '%<br>' +
|
||||||
'Defense Experience multiplier: ' + formatNumber(Player.defense_exp_mult * 100, 2) + '%<br><br>' +
|
'Defense Experience multiplier: ' + formatNumber(Player.defense_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Dexterity Level multiplier: ' + formatNumber(Player.dexterity_mult * 100, 2) + '%<br>' +
|
'Dexterity Level multiplier: ' + formatNumber(Player.dexterity_mult * 100, 2) + '%<br>' +
|
||||||
'Dexterity Experience multiplier: ' + formatNumber(Player.dexterity_exp_mult * 100, 2) + '%<br><br>' +
|
'Dexterity Experience multiplier: ' + formatNumber(Player.dexterity_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Agility Level multiplier: ' + formatNumber(Player.agility_mult * 100, 2) + '%<br>' +
|
'Agility Level multiplier: ' + formatNumber(Player.agility_mult * 100, 2) + '%<br>' +
|
||||||
'Agility Experience multiplier: ' + formatNumber(Player.agility_exp_mult * 100, 2) + '%<br><br>' +
|
'Agility Experience multiplier: ' + formatNumber(Player.agility_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Charisma Level multiplier: ' + formatNumber(Player.charisma_mult * 100, 2) + '%<br>' +
|
'Charisma Level multiplier: ' + formatNumber(Player.charisma_mult * 100, 2) + '%<br>' +
|
||||||
'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' +
|
'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' +
|
||||||
'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' +
|
'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' +
|
||||||
'Hacknet Node purchase cost multiplier: '+ formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' +
|
'Hacknet Node purchase cost multiplier: ' + formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' +
|
||||||
'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' +
|
'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' +
|
||||||
'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' +
|
'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' +
|
||||||
'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' +
|
'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' +
|
||||||
'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' +
|
'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' +
|
||||||
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' +
|
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' +
|
||||||
'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br><br><br>' +
|
'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br><br><br>' +
|
||||||
'<b>Misc</b><br><br>' +
|
'<b>Misc</b><br><br>' +
|
||||||
'Servers owned: ' + Player.purchasedServers.length + '<br>' +
|
'Servers owned: ' + Player.purchasedServers.length + '<br>' +
|
||||||
'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '<br>';
|
'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '<br>').replace( / /g, " " );
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -660,7 +574,7 @@ var Engine = {
|
|||||||
//is necessary and then resets the counter
|
//is necessary and then resets the counter
|
||||||
checkCounters: function() {
|
checkCounters: function() {
|
||||||
if (Engine.Counters.autoSaveCounter <= 0) {
|
if (Engine.Counters.autoSaveCounter <= 0) {
|
||||||
Engine.saveGame();
|
saveObject.saveGame();
|
||||||
Engine.Counters.autoSaveCounter = 300;
|
Engine.Counters.autoSaveCounter = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,13 +720,13 @@ var Engine = {
|
|||||||
|
|
||||||
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() {
|
||||||
Engine.saveGame();
|
saveObject.saveGame();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
Engine.Clickables.deleteMainMenuButton = document.getElementById("delete-game-link");
|
Engine.Clickables.deleteMainMenuButton = document.getElementById("delete-game-link");
|
||||||
Engine.Clickables.deleteMainMenuButton.addEventListener("click", function() {
|
Engine.Clickables.deleteMainMenuButton.addEventListener("click", function() {
|
||||||
Engine.deleteSave();
|
saveObject.deleteGame();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -927,7 +841,7 @@ var Engine = {
|
|||||||
Engine.Display.scriptEditorText = document.getElementById("script-editor-text");
|
Engine.Display.scriptEditorText = document.getElementById("script-editor-text");
|
||||||
|
|
||||||
//Load game from save or create new game
|
//Load game from save or create new game
|
||||||
if (Engine.loadSave()) {
|
if (loadGame(saveObject)) {
|
||||||
console.log("Loaded game from save");
|
console.log("Loaded game from save");
|
||||||
CompanyPositions.init();
|
CompanyPositions.init();
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
|
|||||||
} else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) {
|
} else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) {
|
||||||
applyAugmentation(aug, fac);
|
applyAugmentation(aug, fac);
|
||||||
//TODO Make this text better
|
//TODO Make this text better
|
||||||
dialogBoxCreate("You slowly drift to sleep as " + fac.name + "'s scientists put you under <br>" +
|
dialogBoxCreate("You slowly drift to sleep as " + fac.name + "'s scientists put you under " +
|
||||||
" in order to install the " + aug.name + " Augmentation. <br>br>" +
|
" in order to install the " + aug.name + " Augmentation. <br><br>" +
|
||||||
"You wake up in your home...you feel different...");
|
"You wake up in your home...you feel different...");
|
||||||
|
|
||||||
prestigeAugmentation();
|
prestigeAugmentation();
|
||||||
|
Loading…
Reference in New Issue
Block a user