diff --git a/script/engine.js b/script/engine.js index 9527146..22d021f 100644 --- a/script/engine.js +++ b/script/engine.js @@ -157,7 +157,6 @@ var Engine = { }, saveGame: function() { - //Score.saveScore(); if(typeof Storage != 'undefined' && localStorage) { if(Engine._saveTimer != null) { clearTimeout(Engine._saveTimer); diff --git a/script/prestige.js b/script/prestige.js index ecb72f2..6f2cd1e 100644 --- a/script/prestige.js +++ b/script/prestige.js @@ -10,39 +10,36 @@ var Prestige = { saveStores: function(saveBool) { var prevStores = [ //g = goods, w = weapons, a = ammo - Math.floor($SM.get('stores["wood"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["fur"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["meat"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["iron"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["coal"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["steel"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["scales"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["teeth"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["leather"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["bait"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["torch"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["cloth"]') / Prestige.randGen(saveBool, 'g')), - Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["rifle"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen(saveBool, 'w')), - Math.floor($SM.get('stores["bullets"]') / Prestige.randGen(saveBool, 'a')), - Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen(saveBool, 'a')), - Math.floor($SM.get('stores["grenade"]') / Prestige.randGen(saveBool, 'a')), - Math.floor($SM.get('stores["bolas"]') / Prestige.randGen(saveBool, 'a')) + Math.floor($SM.get('stores["wood"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["fur"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["meat"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["iron"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["coal"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["steel"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["scales"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["teeth"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["leather"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["bait"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["torch"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["cloth"]') / Prestige.randGen('g')), + Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["rifle"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen('w')), + Math.floor($SM.get('stores["bullets"]') / Prestige.randGen('a')), + Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen('a')), + Math.floor($SM.get('stores["grenade"]') / Prestige.randGen('a')), + Math.floor($SM.get('stores["bolas"]') / Prestige.randGen('a')) ]; for (var n = 0; n <= 23; n++) { if (isNaN(prevStores[n])) { prevStores[n] = 0; } } - if(saveBool) { - $SM.set('previous.stores', prevStores); - } return prevStores; }, @@ -96,26 +93,21 @@ var Prestige = { return prevStores; }, - randGen : function(saveBool, storeType) { - if (saveBool) { - if (storeType == 'g') { - divisor = Math.floor(Math.random() * 10); - } else if (storeType == 'w') { - divisor = Math.floor(Math.floor(Math.random() * 10) / 2); - } else if (storeType == 'a') { - divisor = Math.ceil(Math.random() * 10 - * Math.ceil(Math.random() * 10)); - } else { - divisor = 1; - } - if (divisor === 0) { - divisor = 1; - } - return divisor; - } - else { - return 1; - }; + randGen : function(storeType) { + if (storeType == 'g') { + divisor = Math.floor(Math.random() * 10); + } else if (storeType == 'w') { + divisor = Math.floor(Math.floor(Math.random() * 10) / 2); + } else if (storeType == 'a') { + divisor = Math.ceil(Math.random() * 10 + * Math.ceil(Math.random() * 10)); + } else { + divisor = 1; + } + if (divisor === 0) { + divisor = 1; + } + return divisor; } }; diff --git a/script/scoring.js b/script/scoring.js index 55c6ba4..04b8a83 100644 --- a/script/scoring.js +++ b/script/scoring.js @@ -9,7 +9,7 @@ var Score = { }, calculateScore: function() { - var scoreUnadded = Prestige.saveStores(false); + var scoreUnadded = $SM.getStores(); var fullScore = 0; fullScore = fullScore + scoreUnadded[0] * 1; fullScore = fullScore + scoreUnadded[1] * 1.5; diff --git a/script/space.js b/script/space.js index 3304226..d1248de 100644 --- a/script/space.js +++ b/script/space.js @@ -393,7 +393,8 @@ var Space = { var backup = new Object(); backup.score = null; backup.stores = null; - + Prestige.saveStores(); + Prestige.saveScore(); $('