mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-24 10:12:53 +02:00
Initial commit for company code refactor. Split out all components into separate files and converted to typescript
This commit is contained in:
+44
-60
@@ -1,7 +1,7 @@
|
||||
import {loadAliases, loadGlobalAliases,
|
||||
Aliases, GlobalAliases} from "./Alias";
|
||||
import {loadCompanies, Companies,
|
||||
CompanyPositions} from "./Company";
|
||||
import {Companies, loadCompanies} from "./Company/Companies";
|
||||
import {CompanyPosition} from "./Company/CompanyPosition";
|
||||
import {CONSTANTS} from "./Constants";
|
||||
import {Engine} from "./engine";
|
||||
import {loadFactions, Factions,
|
||||
@@ -187,29 +187,20 @@ function loadGame(saveString) {
|
||||
if (saveObj.hasOwnProperty("VersionSave")) {
|
||||
try {
|
||||
var ver = JSON.parse(saveObj.VersionSave, Reviver);
|
||||
if (Player.bitNodeN == null || Player.bitNodeN === 0) {
|
||||
Player.setBitNodeNumber(1);
|
||||
}
|
||||
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {
|
||||
console.log("Evaluating changes needed for version compatibility");
|
||||
if (Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 ||
|
||||
Player.sourceFiles.length > 0) {
|
||||
//If you have already purchased an Aug...you are far enough in the game
|
||||
//that everything should be available
|
||||
Player.firstFacInvRecvd = true;
|
||||
Player.firstAugPurchased = true;
|
||||
Player.firstJobRecvd = true;
|
||||
Player.firstTimeTraveled = true;
|
||||
Player.firstProgramAvailable = true;
|
||||
} else {
|
||||
if (Player.factions.length > 0 || Player.factionInvitations.length > 0) {
|
||||
Player.firstFacInvRecvd = true;
|
||||
}
|
||||
if (Player.companyName !== "" || Player.companyPosition !== "") {
|
||||
Player.firstJobRecvd = true;
|
||||
}
|
||||
if (Player.hacking_skill >= 25) {
|
||||
Player.firstScriptAvailable = true;
|
||||
// This version refactored the Company/job-related code
|
||||
if (ver < "0.41.2") {
|
||||
// Player's company position is now a string
|
||||
if (Player.companyPosition !== "" || Player.companyPosition instanceof CompanyPosition) {
|
||||
console.log("Changed Player.companyPosition value to be compatible with v0.41.2");
|
||||
Player.companyPosition = Player.companyPosition.positionName;
|
||||
}
|
||||
|
||||
// The "companyName" property of all Companies is renamed to "name"
|
||||
for (var companyName in Companies) {
|
||||
const company = Companies[companyName];
|
||||
if (company.name == null && company.companyName != null) {
|
||||
console.log("Changed company name property to be compatible with v0.41.2");
|
||||
company.name = company.companyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,23 +301,27 @@ function loadImportedGame(saveObj, saveString) {
|
||||
if (tempSaveObj.hasOwnProperty("VersionSave")) {
|
||||
try {
|
||||
var ver = JSON.parse(tempSaveObj.VersionSave, Reviver);
|
||||
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {
|
||||
if (tempPlayer.bitNodeN == null || tempPlayer.bitNodeN == 0) {
|
||||
tempPlayer.bitNodeN = 1;
|
||||
// This version refactored the Company/job-related code
|
||||
if (ver < "0.41.2") {
|
||||
// Player's company position is now a string
|
||||
if (Player.companyPosition !== "" || Player.companyPosition instanceof CompanyPosition) {
|
||||
console.log("Changed Player.companyPosition value to be compatible with v0.41.2");
|
||||
Player.companyPosition = Player.companyPosition.positionName;
|
||||
}
|
||||
if (tempPlayer.sourceFiles == null) {
|
||||
tempPlayer.sourceFiles = [];
|
||||
|
||||
// The "companyName" property of all Companies is renamed to "name"
|
||||
for (var companyName in Companies) {
|
||||
const company = Companies[companyName];
|
||||
if (company.name == null && company.companyName != null) {
|
||||
console.log("Changed company name property to be compatible with v0.41.2");
|
||||
company.name = company.companyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ver != CONSTANTS.Version) {
|
||||
//createNewUpdateText();
|
||||
}
|
||||
} catch(e) {
|
||||
console.log("Parsing Version save failed: " + e);
|
||||
//createNewUpdateText();
|
||||
console.error("Parsing Version save failed: " + e);
|
||||
}
|
||||
} else {
|
||||
//createNewUpdateText();
|
||||
}
|
||||
if (tempPlayer.bitNodeN == 2 && tempPlayer.inGang() && tempSaveObj.hasOwnProperty("AllGangsSave")) {
|
||||
try {
|
||||
@@ -405,30 +400,20 @@ function loadImportedGame(saveObj, saveString) {
|
||||
if (saveObj.hasOwnProperty("VersionSave")) {
|
||||
try {
|
||||
var ver = JSON.parse(saveObj.VersionSave, Reviver);
|
||||
if (Player.bitNodeN == null || Player.bitNodeN == 0) {
|
||||
Player.setBitNodeNumber(1);
|
||||
// This version refactored the Company/job-related code
|
||||
if (ver < "0.41.2") {
|
||||
// Player's company position is now a string
|
||||
if (Player.companyPosition !== "" || Player.companyPosition instanceof CompanyPosition) {
|
||||
console.log("Changed Player.companyPosition value to be compatible with v0.41.2");
|
||||
Player.companyPosition = Player.companyPosition.positionName;
|
||||
}
|
||||
|
||||
}
|
||||
if (ver.startsWith("0.27.") || ver.startsWith("0.28.")) {
|
||||
console.log("Evaluating changes needed for version compatibility");
|
||||
if (Player.augmentations.length > 0 || Player.queuedAugmentations.length > 0 ||
|
||||
Player.sourceFiles.length > 0) {
|
||||
//If you have already purchased an Aug...you are far enough in the game
|
||||
//that everything should be available
|
||||
Player.firstFacInvRecvd = true;
|
||||
Player.firstAugPurchased = true;
|
||||
Player.firstJobRecvd = true;
|
||||
Player.firstTimeTraveled = true;
|
||||
Player.firstProgramAvailable = true;
|
||||
} else {
|
||||
if (Player.factions.length > 0 || Player.factionInvitations.length > 0) {
|
||||
Player.firstFacInvRecvd = true;
|
||||
}
|
||||
if (Player.companyName !== "" || Player.companyPosition !== "") {
|
||||
Player.firstJobRecvd = true;
|
||||
}
|
||||
if (Player.hacking_skill >= 25) {
|
||||
Player.firstScriptAvailable = true;
|
||||
// The "companyName" property of all Companies is renamed to "name"
|
||||
for (var companyName in Companies) {
|
||||
const company = Companies[companyName];
|
||||
if (company.name == null && company.companyName != null) {
|
||||
console.log("Changed company name property to be compatible with v0.41.2");
|
||||
company.name = company.companyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,7 +452,6 @@ function loadImportedGame(saveObj, saveString) {
|
||||
console.log("Importing game");
|
||||
Engine.setDisplayElements(); //Sets variables for important DOM elements
|
||||
Engine.init(); //Initialize buttons, work, etc.
|
||||
CompanyPositions.init();
|
||||
|
||||
//Calculate the number of cycles have elapsed while offline
|
||||
Engine._lastUpdate = new Date().getTime();
|
||||
|
||||
Reference in New Issue
Block a user