mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 20:37:05 +02:00
CORPORATION: Corp changes prior to 2.3 finalization (#503)
This commit is contained in:
+13
-16
@@ -40,6 +40,8 @@ import { TextFile } from "./TextFile";
|
||||
import { ScriptFilePath, resolveScriptFilePath } from "./Paths/ScriptFilePath";
|
||||
import { Directory, resolveDirectory } from "./Paths/Directory";
|
||||
import { TextFilePath, resolveTextFilePath } from "./Paths/TextFilePath";
|
||||
import { Corporation } from "./Corporation/Corporation";
|
||||
import { Terminal } from "./Terminal";
|
||||
|
||||
/* SaveObject.js
|
||||
* Defines the object used to save/load games
|
||||
@@ -323,9 +325,6 @@ function evaluateVersionCompatibility(ver: string | number): void {
|
||||
if (anyPlayer.gang === 0) {
|
||||
anyPlayer.gang = null;
|
||||
}
|
||||
if (anyPlayer.corporation === 0) {
|
||||
anyPlayer.corporation = null;
|
||||
}
|
||||
// convert all Messages to just filename to save space.
|
||||
const home = anyPlayer.getHomeComputer();
|
||||
for (let i = 0; i < home.messages.length; i++) {
|
||||
@@ -373,19 +372,6 @@ function evaluateVersionCompatibility(ver: string | number): void {
|
||||
}
|
||||
if (ver < 3) {
|
||||
anyPlayer.money = parseFloat(anyPlayer.money);
|
||||
if (anyPlayer.corporation) {
|
||||
anyPlayer.corporation.funds = parseFloat(anyPlayer.corporation.funds);
|
||||
anyPlayer.corporation.revenue = parseFloat(anyPlayer.corporation.revenue);
|
||||
anyPlayer.corporation.expenses = parseFloat(anyPlayer.corporation.expenses);
|
||||
|
||||
for (let i = 0; i < anyPlayer.corporation.divisions.length; ++i) {
|
||||
const ind = anyPlayer.corporation.divisions[i];
|
||||
ind.lastCycleRevenue = parseFloat(ind.lastCycleRevenue);
|
||||
ind.lastCycleExpenses = parseFloat(ind.lastCycleExpenses);
|
||||
ind.thisCycleRevenue = parseFloat(ind.thisCycleRevenue);
|
||||
ind.thisCycleExpenses = parseFloat(ind.thisCycleExpenses);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ver < 9) {
|
||||
if (Object.hasOwn(StockMarket, "Joes Guns")) {
|
||||
@@ -717,6 +703,17 @@ function evaluateVersionCompatibility(ver: string | number): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Reset corporation to new format.
|
||||
const oldCorp = anyPlayer.corporation as Corporation | null | 0;
|
||||
if (oldCorp && Array.isArray(oldCorp.divisions)) {
|
||||
// Corp needs to be reset to new format, just keep some valuation data
|
||||
let valuation = oldCorp.valuation * 2 + oldCorp.revenue * 100;
|
||||
if (isNaN(valuation)) valuation = 300e9;
|
||||
Player.startCorporation(String(oldCorp.name), !!oldCorp.seedFunded);
|
||||
Player.corporation?.addFunds(valuation);
|
||||
Terminal.warn("Loading corporation from version prior to 2.3. Corporation has been reset.");
|
||||
}
|
||||
// End 2.3 changes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user