started scoring system, yet to be populated

This commit is contained in:
Vermilingua
2013-10-18 11:58:33 +11:00
parent a19643517a
commit 3b3755cda9
8 changed files with 173 additions and 57 deletions
+59 -46
View File
@@ -8,56 +8,64 @@ var Prestige = {
this.options = $.extend(this.options, options);
},
save: function() {
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'))
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'))
];
for (var n = 0; n <= 23; n++) {
if (isNaN(prevStores[n])) {
prevStores[n] = 0;
}
}
$SM.set('previous.stores', prevStores);
return prevStores;
if(saveBool) {
$SM.set('previous.stores', prevStores);
}
return prevStores;
},
saveScore: function() {
var prevScore = Score.totalScore();
$SM.set('previous.score',prevScore);
return prevScore;
},
populateNewSave : function(newstate) {
populateNewSave : function(newstate) {
State = {
previous : {
stores : newstate
stores : newstate["stores"],
score : newstate["score"]
}
};
Engine.init({
state : State
});
return State;
},
load : function() {
load : function() {
var prevStores = $SM.get('previous.stores');
if(prevStores != null) {
$SM.add('stores["wood"]', prevStores[0]);
@@ -88,21 +96,26 @@ var Prestige = {
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;
}
if (divisor === 0) {
divisor = 1;
}
return divisor;
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;
};
}
};