2019-04-03 17:08:11 -07:00
|
|
|
import { Corporation } from "./Corporation/Corporation";
|
|
|
|
import { PlayerObject } from "./PersonObjects/Player/PlayerObject";
|
2021-03-08 20:31:34 -05:00
|
|
|
import { sanitizeExploits } from "./Exploits/Exploit";
|
2019-04-01 02:23:25 -07:00
|
|
|
|
2019-04-03 17:08:11 -07:00
|
|
|
import { Reviver } from "../utils/JSONReviver";
|
2019-04-01 02:23:25 -07:00
|
|
|
|
2019-04-03 17:08:11 -07:00
|
|
|
import Decimal from "decimal.js";
|
2019-04-01 02:23:25 -07:00
|
|
|
|
|
|
|
export let Player = new PlayerObject();
|
|
|
|
|
|
|
|
export function loadPlayer(saveString) {
|
2017-08-30 12:44:29 -05:00
|
|
|
Player = JSON.parse(saveString, Reviver);
|
|
|
|
|
2019-04-12 18:22:46 -07:00
|
|
|
// Parse Decimal.js objects
|
2017-08-30 12:44:29 -05:00
|
|
|
Player.money = new Decimal(Player.money);
|
2017-12-01 21:50:08 -06:00
|
|
|
|
|
|
|
if (Player.corporation instanceof Corporation) {
|
|
|
|
Player.corporation.funds = new Decimal(Player.corporation.funds);
|
|
|
|
Player.corporation.revenue = new Decimal(Player.corporation.revenue);
|
|
|
|
Player.corporation.expenses = new Decimal(Player.corporation.expenses);
|
|
|
|
|
|
|
|
for (var i = 0; i < Player.corporation.divisions.length; ++i) {
|
|
|
|
var ind = Player.corporation.divisions[i];
|
|
|
|
ind.lastCycleRevenue = new Decimal(ind.lastCycleRevenue);
|
|
|
|
ind.lastCycleExpenses = new Decimal(ind.lastCycleExpenses);
|
|
|
|
ind.thisCycleRevenue = new Decimal(ind.thisCycleRevenue);
|
|
|
|
ind.thisCycleExpenses = new Decimal(ind.thisCycleExpenses);
|
|
|
|
}
|
|
|
|
}
|
2021-03-08 20:31:34 -05:00
|
|
|
|
|
|
|
Player.exploits = sanitizeExploits(Player.exploits);
|
2017-08-30 12:44:29 -05:00
|
|
|
}
|