mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
Factions should save and load properly (not fully tested). Terminal now scrolls to the bottom when something is posted
This commit is contained in:
parent
d656ee3114
commit
8dbca029de
@ -37,9 +37,12 @@ TESTING TODO:
|
||||
ctrl+C functionality for all running command like hack(), analyze(), and tail
|
||||
Implemented for hack() and analyze(). Seems to work
|
||||
|
||||
Saving/Loading factions
|
||||
No errors thrown when saving/loading game at the start
|
||||
|
||||
Scroll all the way down when something is post()ed
|
||||
|
||||
Tasks TODO:
|
||||
Scroll all the way down when something is post()ed
|
||||
Script logging functionality? Logs to internal "log file" (property of script itself)
|
||||
Tutorial and help
|
||||
Secret Servers
|
||||
|
@ -8,17 +8,22 @@ function Faction(name) {
|
||||
this.playerReputation = 0; //"Reputation" within faction
|
||||
};
|
||||
|
||||
//TODO
|
||||
Faction.prototype.init = function() {
|
||||
|
||||
}
|
||||
|
||||
Faction.prototype.setAugmentations = function(augs) {
|
||||
for (var i = 0; i < augs.length; i++) {
|
||||
this.augmentations.push(augs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Faction.prototype.toJSON = function() {
|
||||
return Generic_toJSON("Faction", this);
|
||||
}
|
||||
|
||||
Faction.fromJSON = function(value) {
|
||||
return Generic_fromJSON(Faction, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.Faction = Faction;
|
||||
|
||||
//Map of factions indexed by faction name
|
||||
Factions = {}
|
||||
|
||||
|
@ -1,18 +1,25 @@
|
||||
//Terminal
|
||||
|
||||
/* Write text to terminal */
|
||||
var post = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td style="color: #66ff33;">' + input.replace( / /g, " " ) + '</td></tr>');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
updateTerminalScroll();
|
||||
}
|
||||
|
||||
//Same thing as post but the td cells have ids so they can be animated for the hack progress bar
|
||||
var hackProgressBarPost = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td id="hack-progress-bar" style="color: #66ff33;">' + input + '</td></tr>');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
updateTerminalScroll();
|
||||
}
|
||||
|
||||
var hackProgressPost = function(input) {
|
||||
$("#terminal-input").before('<tr class="posted"><td id="hack-progress" style="color: #66ff33;">' + input + '</td></tr>');
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
updateTerminalScroll();
|
||||
}
|
||||
|
||||
function updateTerminalScroll() {
|
||||
var element = document.getElementById("terminal-container");
|
||||
element.scrollTop = element.scrollHeight;
|
||||
}
|
||||
|
||||
var postNetburnerText = function() {
|
||||
|
@ -55,11 +55,13 @@ var Engine = {
|
||||
var PlayerSave = JSON.stringify(Player);
|
||||
var AllServersSave = JSON.stringify(AllServers);
|
||||
var CompaniesSave = JSON.stringify(Companies);
|
||||
var FactionsSave = JSON.stringify(Factions);
|
||||
//TODO Add factions + companies here when they're done
|
||||
|
||||
window.localStorage.setItem("netburnerPlayerSave", PlayerSave);
|
||||
window.localStorage.setItem("netburnerAllServersSave", AllServersSave);
|
||||
window.localStorage.setItem("netburnerCompaniesSave", CompaniesSave);
|
||||
window.localStorage.setItem("netburnerFactionsSave", FactionsSave);
|
||||
console.log("Game saved to local storage");
|
||||
},
|
||||
|
||||
@ -75,19 +77,26 @@ var Engine = {
|
||||
} 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 {
|
||||
var PlayerSave = window.localStorage.getItem("netburnerPlayerSave");
|
||||
var AllServersSave = window.localStorage.getItem("netburnerAllServersSave");
|
||||
var CompaniesSave = window.localStorage.getItem("netburnerCompaniesSave");
|
||||
var FactionsSave = window.localStorage.getItem("netburnerFactionsSave");
|
||||
Player = JSON.parse(PlayerSave, Reviver);
|
||||
AllServers = JSON.parse(AllServersSave, Reviver);
|
||||
Companies = JSON.parse(CompaniesSave, Reviver);
|
||||
Factions = JSON.parse(FactionsSave, 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")) {
|
||||
console.log("No Player Save to delete");
|
||||
return false;
|
||||
@ -97,10 +106,14 @@ var Engine = {
|
||||
} 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 {
|
||||
window.localStorage.removeItem("netburnerPlayerSave");
|
||||
window.localStorage.removeItem("netburnerAllServersSave");
|
||||
window.localStorage.removeItem("netburnerCompaniesSave");
|
||||
window.localStorage.removeItem("netburnerFactionsSave");
|
||||
console.log("Deleted saves")
|
||||
return true;
|
||||
}
|
||||
@ -388,6 +401,7 @@ var Engine = {
|
||||
initForeignServers();
|
||||
CompanyPositions.init();
|
||||
initCompanies();
|
||||
initFactions();
|
||||
}
|
||||
|
||||
//Main menu buttons and content
|
||||
|
Loading…
Reference in New Issue
Block a user