From f952b4def1e08139ad9e059fbcd133c677590823 Mon Sep 17 00:00:00 2001 From: Vermilingua Date: Sun, 13 Oct 2013 21:39:59 +1100 Subject: [PATCH] completed save/load --- script/engine.js | 2 ++ script/prestige.js | 72 ++++++++++++++++++++++++++++++---------------- script/space.js | 4 +-- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/script/engine.js b/script/engine.js index ba7253b..f6ed806 100644 --- a/script/engine.js +++ b/script/engine.js @@ -206,10 +206,12 @@ var Engine = { }, deleteSave: function() { + //var carriedPrestige = $SM.get('previous.stores'); if(typeof Storage != 'undefined' && localStorage) { localStorage.clear(); } location.reload(); + //$SM.set('previous.stores',carriedPrestige); }, share: function() { diff --git a/script/prestige.js b/script/prestige.js index 2a32a1b..fa25d7a 100644 --- a/script/prestige.js +++ b/script/prestige.js @@ -12,30 +12,30 @@ var Prestige = { save: function() { var prevStores = [ //g = goods, w = weapons, a = ammo - $SM.get('stores["wood"]'), // randGen('g'), - $SM.get('stores["fur"]'), // randGen('g'), - $SM.get('stores["meat"]'), // randGen('g'), - $SM.get('stores["iron"]'), // randGen('g'), - $SM.get('stores["coal"]'), // randGen('g'), - $SM.get('stores["sulphur"]'), // randGen('g'), - $SM.get('stores["steel"]'), // randGen('g'), - $SM.get('stores["cured meat"]'), // randGen('g'), - $SM.get('stores["scales"]'), // randGen('g'), - $SM.get('stores["teeth"]'), // randGen('g'), - $SM.get('stores["leather"]'), // randGen('g'), - $SM.get('stores["bait"]'), // randGen('g'), - $SM.get('stores["torch"]'), // randGen('g'), - $SM.get('stores["cloth"]'), // randGen('g'), - $SM.get('stores["bone spear"]'), // randGen('w'), - $SM.get('stores["iron sword"]'), // randGen('w'), - $SM.get('stores["steel sword"]'), // randGen('w'), - $SM.get('stores["bayonet"]'), // randGen('w'), - $SM.get('stores["rifle"]'), // randGen('w'), - $SM.get('stores["laser rifle"]'), // randGen('w'), - $SM.get('stores["bullets"]'), // randGen('a'), - $SM.get('stores["energy cell"]'), // randGen('a'), - $SM.get('stores["grenade"]'), // randGen('a'), - $SM.get('stores["bolas"]') // randGen('a') + $SM.get('stores["wood"]'), + $SM.get('stores["fur"]'), + $SM.get('stores["meat"]'), + $SM.get('stores["iron"]'), + $SM.get('stores["coal"]'), + $SM.get('stores["sulphur"]'), + $SM.get('stores["steel"]'), + $SM.get('stores["cured meat"]'), + $SM.get('stores["scales"]'), + $SM.get('stores["teeth"]'), + $SM.get('stores["leather"]'), + $SM.get('stores["bait"]'), + $SM.get('stores["torch"]'), + $SM.get('stores["cloth"]'), + $SM.get('stores["bone spear"]'), + $SM.get('stores["iron sword"]'), + $SM.get('stores["steel sword"]'), + $SM.get('stores["bayonet"]'), + $SM.get('stores["rifle"]'), + $SM.get('stores["laser rifle"]'), + $SM.get('stores["bullets"]'), + $SM.get('stores["energy cell"]'), + $SM.get('stores["grenade"]'), + $SM.get('stores["bolas"]') ]; $SM.set('previous.stores', prevStores); return prevStores; @@ -43,6 +43,30 @@ var Prestige = { load: function() { var prevStores = $SM.get('previous.stores'); + $SM.add('stores["wood"]',prevStores[0]), + $SM.add('stores["fur"]',prevStores[1]), + $SM.add('stores["meat"]',prevStores[2]), + $SM.add('stores["iron"]',prevStores[3]), + $SM.add('stores["coal"]',prevStores[4]), + $SM.add('stores["sulphur"]',prevStores[5]), + $SM.add('stores["steel"]',prevStores[6]), + $SM.add('stores["cured meat"]',prevStores[7]), + $SM.add('stores["scales"]',prevStores[8]), + $SM.add('stores["teeth"]',prevStores[9]), + $SM.add('stores["leather"]',prevStores[10]), + $SM.add('stores["bait"]',prevStores[11]), + $SM.add('stores["torch"]',prevStores[12]), + $SM.add('stores["cloth"]',prevStores[13]), + $SM.add('stores["bone spear"]',prevStores[14]), + $SM.add('stores["iron sword"]',prevStores[15]), + $SM.add('stores["steel sword"]',prevStores[16]), + $SM.add('stores["bayonet"]',prevStores[17]), + $SM.add('stores["rifle"]',prevStores[18]), + $SM.add('stores["laser rifle"]',prevStores[19]), + $SM.add('stores["bullets"]',prevStores[20]), + $SM.add('stores["energy cell"]',prevStores[21]), + $SM.add('stores["grenade"]',prevStores[22]), + $SM.add('stores["bolas"]',prevStores[23]) return prevStores; } diff --git a/script/space.js b/script/space.js index c597928..cf0a4e8 100644 --- a/script/space.js +++ b/script/space.js @@ -386,13 +386,11 @@ var Space = { $('#notifyGradient').attr('style', 'background-color:'+cur+';background:-webkit-' + s + ';background:' + s); }, complete: function() { - Prestige.save(); - backup = $SM.get('previous.stores'); + //Prestige.save(); $('#starsContainer').remove(); if(typeof Storage != 'undefined' && localStorage) { localStorage.clear(); } - $SM.set('previous.stores',backup); delete window.State; Engine.options = {}; }