bitburner-src/src/Player.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-04-04 02:08:11 +02:00
import { Corporation } from "./Corporation/Corporation";
import { PlayerObject } from "./PersonObjects/Player/PlayerObject";
2019-04-04 02:08:11 +02:00
import { Reviver } from "../utils/JSONReviver";
2019-04-04 02:08:11 +02:00
import Decimal from "decimal.js";
export let Player = new PlayerObject();
export function loadPlayer(saveString) {
Player = JSON.parse(saveString, Reviver);
// Parse Decimal.js objects
Player.money = new Decimal(Player.money);
2017-12-02 04:50:08 +01: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);
}
}
}