diff --git a/css/main.css b/css/main.css index 1c84c4d..897f87f 100644 --- a/css/main.css +++ b/css/main.css @@ -57,7 +57,7 @@ div#header { .manualSave { position: absolute; - right: 120px; + right: 125px; bottom: 10px; cursor: pointer; } diff --git a/script/engine.js b/script/engine.js index 22d021f..7b35cfa 100644 --- a/script/engine.js +++ b/script/engine.js @@ -10,7 +10,7 @@ var Engine = { VERSION: 1.3, MAX_STORE: 99999999999999, SAVE_DISPLAY: 30 * 1000, - GAME_OVER: false, + GAME_OVER: false, //object event types topics: {}, @@ -274,13 +274,16 @@ var Engine = { }); }, - deleteSave: function() { - if (!Engine.GAME_OVER) { - if(typeof Storage != 'undefined' && localStorage) { - localStorage.clear(); - } - } - location.reload(); + deleteSave: function(noReload) { + if(typeof Storage != 'undefined' && localStorage) { + var prestige = Prestige.get(); + window.State = {}; + localStorage.clear(); + Prestige.set(prestige); + } + if(!noReload) { + location.reload(); + } }, share: function() { diff --git a/script/events/setpieces.js b/script/events/setpieces.js index d3f1e25..c519734 100644 --- a/script/events/setpieces.js +++ b/script/events/setpieces.js @@ -3433,7 +3433,7 @@ Events.Setpieces = { ], onLoad: function() { World.markVisited(World.curPos[0], World.curPos[1]); - Prestige.load(); + Prestige.collectStores(); }, buttons: { 'leave': { diff --git a/script/prestige.js b/script/prestige.js index 6f2cd1e..5758c12 100644 --- a/script/prestige.js +++ b/script/prestige.js @@ -7,107 +7,89 @@ var Prestige = { init: function(options) { this.options = $.extend(this.options, options); }, - - saveStores: function(saveBool) { - var prevStores = [ //g = goods, w = weapons, a = ammo - 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; - } + + storesMap: [ + { store: 'wood', type: 'g' }, + { store: 'fur', type: 'g' }, + { store: 'meat', type: 'g' }, + { store: 'iron', type: 'g' }, + { store: 'coal', type: 'g' }, + { store: 'sulphur', type: 'g' }, + { store: 'steel', type: 'g' }, + { store: 'cured meat', type: 'g' }, + { store: 'scales', type: 'g' }, + { store: 'teeth', type: 'g' }, + { store: 'leather', type: 'g' }, + { store: 'bait', type: 'g' }, + { store: 'torch', type: 'g' }, + { store: 'cloth', type: 'g' }, + { store: 'bone spear', type: 'w' }, + { store: 'iron sword', type: 'w' }, + { store: 'steel sword', type: 'w' }, + { store: 'bayonet', type: 'w' }, + { store: 'rifle', type: 'w' }, + { store: 'laser rifle', type: 'w' }, + { store: 'bullets', type: 'a' }, + { store: 'energy cell', type: 'a' }, + { store: 'grenade', type: 'a' }, + { store: 'bolas', type: 'a' } + ], + + getStores: function(reduce) { + var stores = []; + + for(var i in this.storesMap) { + var s = this.storesMap[i]; + stores.push($SM.get('stores["' + s.store + '"]', true) / + (reduce ? this.randGen(s.type) : 1)); } - return prevStores; + + return stores; }, - - saveScore: function() { - var prevScore = Score.totalScore(); - $SM.set('previous.score',prevScore); - return prevScore; - }, - - populateNewSave : function(newstate) { - State = { - previous : { - stores : newstate["stores"], - score : newstate["score"] - } - + + get: function() { + return { + stores: $SM.get('previous.stores'), + score: $SM.get('previous.score') }; - Engine.init({ - state : State - }); + }, + + set: function(prestige) { + $SM.set('previous.stores', prestige.stores); + $SM.set('previous.score', prestige.score); + }, + + save: function() { + $SM.set('previous.stores', this.getStores(true)); + $SM.set('previous.score', Score.totalScore()); }, - load : function() { + collectStores : function() { var prevStores = $SM.get('previous.stores'); if(prevStores != null) { - $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]); + var toAdd = {}; + for(var i in this.storesMap) { + var s = this.storesMap[i]; + toAdd[s.store] = prevStores[i]; + } + $SM.addM('stores', toAdd); + + // Loading the stores clears em from the save + prevStores.length = 0; } - return prevStores; }, 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; + switch(storeType) { + case 'g': + return Math.floor(Math.random() * 10); + case 'w': + return Math.floor(Math.floor(Math.random() * 10) / 2); + case 'a': + return Math.ceil(Math.random() * 10 * Math.ceil(Math.random() * 10)); + default: + return 1; } - if (divisor === 0) { - divisor = 1; - } - return divisor; } }; diff --git a/script/room.js b/script/room.js index bac3bdf..cd091a5 100644 --- a/script/room.js +++ b/script/room.js @@ -974,7 +974,7 @@ var Room = { if(Room.buttons[thing]) { return true; } else if($SM.get('game.buildings["trading post"]', true) > 0) { - if(thing == 'compass' || $SM.get('stores["'+thing+'"]')) { + if(thing == 'compass' || typeof $SM.get('stores["'+thing+'"]') != 'undefined') { // Allow the purchase of stuff once you've seen it return true; } diff --git a/script/scoring.js b/script/scoring.js index 04b8a83..f6c527c 100644 --- a/script/scoring.js +++ b/script/scoring.js @@ -1,54 +1,50 @@ var Score = { - name: 'Score', + name : 'Score', - options: {}, + options : {}, - init: function(options) { + init : function(options) { this.options = $.extend(this.options, options); }, - calculateScore: function() { - var scoreUnadded = $SM.getStores(); - var fullScore = 0; - fullScore = fullScore + scoreUnadded[0] * 1; - fullScore = fullScore + scoreUnadded[1] * 1.5; - fullScore = fullScore + scoreUnadded[2] * 1; - fullScore = fullScore + scoreUnadded[3] * 2; - fullScore = fullScore + scoreUnadded[4] * 2; - fullScore = fullScore + scoreUnadded[5] * 3; - fullScore = fullScore + scoreUnadded[6] * 3; - fullScore = fullScore + scoreUnadded[7] * 2; - fullScore = fullScore + scoreUnadded[8] * 2; - fullScore = fullScore + scoreUnadded[9] * 2; - fullScore = fullScore + scoreUnadded[10] * 2; - fullScore = fullScore + scoreUnadded[11] * 1.5; - fullScore = fullScore + scoreUnadded[12] * 1; - fullScore = fullScore + scoreUnadded[13] * 1; - fullScore = fullScore + scoreUnadded[14] * 10; - fullScore = fullScore + scoreUnadded[15] * 30; - fullScore = fullScore + scoreUnadded[16] * 50; - fullScore = fullScore + scoreUnadded[17] * 100; - fullScore = fullScore + scoreUnadded[18] * 150; - fullScore = fullScore + scoreUnadded[19] * 150; - fullScore = fullScore + scoreUnadded[20] * 3; - fullScore = fullScore + scoreUnadded[21] * 3; - fullScore = fullScore + scoreUnadded[22] * 5; - fullScore = fullScore + scoreUnadded[23] * 4; - fullScore = fullScore + $SM.get('stores["alien alloy"]') * 10; - fullScore = fullScore + Ship.getMaxHull() * 50; - return fullScore; - }, - - saveScore: function() { - var score = Score.calculateScore(); - $SM.set('playStats.score',score); - return score; - }, - - totalScore: function() { - var totScore = $SM.get('previous.score') + Score.saveScore(); //$SM.get('playStats.score'); - if (!totScore) {totScore = $SM.get('playStats.score')}; - return totScore; - } -} \ No newline at end of file + calculateScore : function() { + var scoreUnadded = Prestige.getStores(false); + var fullScore = 0; + fullScore = fullScore + scoreUnadded[0] * 1; + fullScore = fullScore + scoreUnadded[1] * 1.5; + fullScore = fullScore + scoreUnadded[2] * 1; + fullScore = fullScore + scoreUnadded[3] * 2; + fullScore = fullScore + scoreUnadded[4] * 2; + fullScore = fullScore + scoreUnadded[5] * 3; + fullScore = fullScore + scoreUnadded[6] * 3; + fullScore = fullScore + scoreUnadded[7] * 2; + fullScore = fullScore + scoreUnadded[8] * 2; + fullScore = fullScore + scoreUnadded[9] * 2; + fullScore = fullScore + scoreUnadded[10] * 2; + fullScore = fullScore + scoreUnadded[11] * 1.5; + fullScore = fullScore + scoreUnadded[12] * 1; + fullScore = fullScore + scoreUnadded[13] * 1; + fullScore = fullScore + scoreUnadded[14] * 10; + fullScore = fullScore + scoreUnadded[15] * 30; + fullScore = fullScore + scoreUnadded[16] * 50; + fullScore = fullScore + scoreUnadded[17] * 100; + fullScore = fullScore + scoreUnadded[18] * 150; + fullScore = fullScore + scoreUnadded[19] * 150; + fullScore = fullScore + scoreUnadded[20] * 3; + fullScore = fullScore + scoreUnadded[21] * 3; + fullScore = fullScore + scoreUnadded[22] * 5; + fullScore = fullScore + scoreUnadded[23] * 4; + fullScore = fullScore + $SM.get('stores["alien alloy"]', true) * 10; + fullScore = fullScore + Ship.getMaxHull() * 50; + return Math.floor(fullScore); + }, + + save: function() { + $SM.set('playStats.score', Score.calculateScore()); + }, + + totalScore : function() { + return $SM.get('previous.score', true) + Score.calculateScore(); + } +}; \ No newline at end of file diff --git a/script/space.js b/script/space.js index 73254f0..eec953b 100644 --- a/script/space.js +++ b/script/space.js @@ -5,7 +5,7 @@ var Space = { SHIP_SPEED: 3, BASE_ASTEROID_DELAY: 500, BASE_ASTEROID_SPEED: 1500, - FTB_SPEED: 60000, + FTB_SPEED: 1000,//60000, STAR_WIDTH: 3000, STAR_HEIGHT: 3000, NUM_STARS: 200, @@ -42,9 +42,6 @@ var Space = { $('