Load Decimal.js values

This commit is contained in:
danielyxie 2017-08-01 14:10:21 -05:00
parent ddca05f4c5
commit c62639099a

@ -59,6 +59,12 @@ loadGame = function(saveObj) {
saveObj = JSON.parse(saveString, Reviver); saveObj = JSON.parse(saveString, Reviver);
Player = JSON.parse(saveObj.PlayerSave, 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); AllServers = JSON.parse(saveObj.AllServersSave, Reviver);
Companies = JSON.parse(saveObj.CompaniesSave, Reviver); Companies = JSON.parse(saveObj.CompaniesSave, Reviver);
Factions = JSON.parse(saveObj.FactionsSave, Reviver); Factions = JSON.parse(saveObj.FactionsSave, Reviver);
@ -112,11 +118,6 @@ loadGame = function(saveObj) {
if (saveObj.hasOwnProperty("VersionSave")) { if (saveObj.hasOwnProperty("VersionSave")) {
try { try {
var ver = JSON.parse(saveObj.VersionSave, Reviver); 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) { if (ver != CONSTANTS.Version) {
createNewUpdateText(); createNewUpdateText();
} }
@ -148,6 +149,12 @@ loadImportedGame = function(saveObj, saveString) {
tempSaveObj = JSON.parse(saveString, Reviver); tempSaveObj = JSON.parse(saveString, Reviver);
tempPlayer = JSON.parse(tempSaveObj.PlayerSave, 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); tempAllServers = JSON.parse(tempSaveObj.AllServersSave, Reviver);
tempCompanies = JSON.parse(tempSaveObj.CompaniesSave, Reviver); tempCompanies = JSON.parse(tempSaveObj.CompaniesSave, Reviver);
tempFactions = JSON.parse(tempSaveObj.FactionsSave, Reviver); tempFactions = JSON.parse(tempSaveObj.FactionsSave, Reviver);