From c62639099a618211783dd5fe4caded7ebea2e69e Mon Sep 17 00:00:00 2001 From: danielyxie Date: Tue, 1 Aug 2017 14:10:21 -0500 Subject: [PATCH] Load Decimal.js values --- src/SaveObject.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/SaveObject.js b/src/SaveObject.js index 1b86814ef..f065ea82f 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -59,6 +59,12 @@ loadGame = function(saveObj) { saveObj = JSON.parse(saveString, Reviver); Player = JSON.parse(saveObj.PlayerSave, Reviver); + + //Parse Decimal.js objects + Player.money = new Decimal(Player.money); + Player.total_money = new Decimal(Player.total_money); + Player.lifetime_money = new Decimal(Player.lifetime_money); + AllServers = JSON.parse(saveObj.AllServersSave, Reviver); Companies = JSON.parse(saveObj.CompaniesSave, Reviver); Factions = JSON.parse(saveObj.FactionsSave, Reviver); @@ -112,11 +118,6 @@ loadGame = function(saveObj) { if (saveObj.hasOwnProperty("VersionSave")) { try { var ver = JSON.parse(saveObj.VersionSave, Reviver); - if (CONSTANTS.Version == "0.26.3") { - Player.money = new Decimal(Player.money); - Player.total_money = new Decimal(Player.total_money); - Player.lifetime_money = new Decimal(Player.lifetime_money); - } if (ver != CONSTANTS.Version) { createNewUpdateText(); } @@ -148,6 +149,12 @@ loadImportedGame = function(saveObj, saveString) { tempSaveObj = JSON.parse(saveString, Reviver); tempPlayer = JSON.parse(tempSaveObj.PlayerSave, Reviver); + + //Parse Decimal.js objects + tempPlayer.money = new Decimal(tempPlayer.money); + tempPlayer.total_money = new Decimal(tempPlayer.total_money); + tempPlayer.lifetime_money = new Decimal(tempPlayer.lifetime_money); + tempAllServers = JSON.parse(tempSaveObj.AllServersSave, Reviver); tempCompanies = JSON.parse(tempSaveObj.CompaniesSave, Reviver); tempFactions = JSON.parse(tempSaveObj.FactionsSave, Reviver);