made store collection routine in SM, and updated everything to suit

This commit is contained in:
Vermilingua
2013-11-01 17:01:21 +11:00
parent a68f58e648
commit d7fc109554
5 changed files with 97 additions and 70 deletions
-1
View File
@@ -157,7 +157,6 @@ var Engine = {
}, },
saveGame: function() { saveGame: function() {
//Score.saveScore();
if(typeof Storage != 'undefined' && localStorage) { if(typeof Storage != 'undefined' && localStorage) {
if(Engine._saveTimer != null) { if(Engine._saveTimer != null) {
clearTimeout(Engine._saveTimer); clearTimeout(Engine._saveTimer);
+25 -33
View File
@@ -10,39 +10,36 @@ var Prestige = {
saveStores: function(saveBool) { saveStores: function(saveBool) {
var prevStores = [ //g = goods, w = weapons, a = ammo var prevStores = [ //g = goods, w = weapons, a = ammo
Math.floor($SM.get('stores["wood"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["wood"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["fur"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["fur"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["meat"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["meat"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["iron"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["iron"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["coal"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["coal"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["steel"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["steel"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["scales"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["scales"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["teeth"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["teeth"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["leather"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["leather"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["bait"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["bait"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["torch"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["torch"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["cloth"]') / Prestige.randGen(saveBool, 'g')), Math.floor($SM.get('stores["cloth"]') / Prestige.randGen('g')),
Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["rifle"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["rifle"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen(saveBool, 'w')), Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen('w')),
Math.floor($SM.get('stores["bullets"]') / Prestige.randGen(saveBool, 'a')), Math.floor($SM.get('stores["bullets"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen(saveBool, 'a')), Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["grenade"]') / Prestige.randGen(saveBool, 'a')), Math.floor($SM.get('stores["grenade"]') / Prestige.randGen('a')),
Math.floor($SM.get('stores["bolas"]') / Prestige.randGen(saveBool, 'a')) Math.floor($SM.get('stores["bolas"]') / Prestige.randGen('a'))
]; ];
for (var n = 0; n <= 23; n++) { for (var n = 0; n <= 23; n++) {
if (isNaN(prevStores[n])) { if (isNaN(prevStores[n])) {
prevStores[n] = 0; prevStores[n] = 0;
} }
} }
if(saveBool) {
$SM.set('previous.stores', prevStores);
}
return prevStores; return prevStores;
}, },
@@ -96,8 +93,7 @@ var Prestige = {
return prevStores; return prevStores;
}, },
randGen : function(saveBool, storeType) { randGen : function(storeType) {
if (saveBool) {
if (storeType == 'g') { if (storeType == 'g') {
divisor = Math.floor(Math.random() * 10); divisor = Math.floor(Math.random() * 10);
} else if (storeType == 'w') { } else if (storeType == 'w') {
@@ -113,9 +109,5 @@ var Prestige = {
} }
return divisor; return divisor;
} }
else {
return 1;
};
}
}; };
+1 -1
View File
@@ -9,7 +9,7 @@ var Score = {
}, },
calculateScore: function() { calculateScore: function() {
var scoreUnadded = Prestige.saveStores(false); var scoreUnadded = $SM.getStores();
var fullScore = 0; var fullScore = 0;
fullScore = fullScore + scoreUnadded[0] * 1; fullScore = fullScore + scoreUnadded[0] * 1;
fullScore = fullScore + scoreUnadded[1] * 1.5; fullScore = fullScore + scoreUnadded[1] * 1.5;
+4 -3
View File
@@ -393,7 +393,8 @@ var Space = {
var backup = new Object(); var backup = new Object();
backup.score = null; backup.score = null;
backup.stores = null; backup.stores = null;
Prestige.saveStores();
Prestige.saveScore();
$('<center>') $('<center>')
.addClass('centerCont') .addClass('centerCont')
@@ -415,8 +416,8 @@ var Space = {
$('#starsContainer').remove(); $('#starsContainer').remove();
if(typeof Storage != 'undefined' && localStorage) { if(typeof Storage != 'undefined' && localStorage) {
backup.stores = Prestige.saveStores(true); backup.stores = $SM.getStores();
backup.score = Prestige.saveScore(); backup.score = Score.totalScore();
localStorage.clear(); localStorage.clear();
} }
delete window.State; delete window.State;
+35
View File
@@ -190,6 +190,41 @@ var StateManager = {
}; };
}, },
getStores: function() {
var stores = [
$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"]')
];
for (var n = 0; n <= 23; n++) {
if (isNaN(stores[n])) {
stores[n] = 0;
}
}
return stores;
},
//creates full reference from input //creates full reference from input
//hopefully this won't ever need to be more complicated //hopefully this won't ever need to be more complicated
buildPath: function(input){ buildPath: function(input){