From 1be4d5edc59b23a0f8aa0f398e0f7bf8ab6382a1 Mon Sep 17 00:00:00 2001 From: Vermilingua Date: Sun, 13 Oct 2013 11:53:11 +1100 Subject: [PATCH] started backup/loading mechanic --- script/events/setpieces.js | 7 ++++--- script/prestige.js | 8 +++++++- script/space.js | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/script/events/setpieces.js b/script/events/setpieces.js index 161dcb0..57e2686 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -3394,12 +3394,12 @@ Events.Setpieces = { } }, "cache": { /* Cache - contains some of supplies from previous game */ - title: 'An Underground Cache', + title: 'A Destroyed Village', scenes: { 'start': { text: [ 'a destroyed village stands before you', - 'with bodies littering the ground.' + 'charred bodies littering the ground.' ], notification: 'you smell the metallic tang of a wanderer afterburner.', buttons: { @@ -3415,7 +3415,7 @@ Events.Setpieces = { }, 'underground': { text: [ - 'a small shack stands at the center of the village.', + 'a shack stands at the center of the village.', 'there are still supplies inside.' ], buttons: { @@ -3432,6 +3432,7 @@ Events.Setpieces = { ], onLoad: function() { World.markVisited(World.curPos[0], World.curPos[1]); + Prestige.load(); }, buttons: { 'leave': { diff --git a/script/prestige.js b/script/prestige.js index 6c3b2f9..2a32a1b 100644 --- a/script/prestige.js +++ b/script/prestige.js @@ -11,7 +11,7 @@ var Prestige = { }, save: function() { - prevStores = [ //g = goods, w = weapons, a = ammo + 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'), @@ -37,9 +37,15 @@ var Prestige = { $SM.get('stores["grenade"]'), // randGen('a'), $SM.get('stores["bolas"]') // randGen('a') ]; + $SM.set('previous.stores', prevStores); return prevStores; }, + load: function() { + var prevStores = $SM.get('previous.stores'); + return prevStores; + } + /*randGen: function(storeType) { if (storeType == 'g') { divisor = Math.floor(Math.random()*10) diff --git a/script/space.js b/script/space.js index b6b92f5..c597928 100644 --- a/script/space.js +++ b/script/space.js @@ -387,10 +387,12 @@ var Space = { }, complete: function() { Prestige.save(); + backup = $SM.get('previous.stores'); $('#starsContainer').remove(); if(typeof Storage != 'undefined' && localStorage) { localStorage.clear(); } + $SM.set('previous.stores',backup); delete window.State; Engine.options = {}; }