mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-11 23:17:12 +08:00
made store collection routine in SM, and updated everything to suit
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
+39
-47
@@ -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,26 +93,21 @@ 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') {
|
divisor = Math.floor(Math.floor(Math.random() * 10) / 2);
|
||||||
divisor = Math.floor(Math.floor(Math.random() * 10) / 2);
|
} else if (storeType == 'a') {
|
||||||
} else if (storeType == 'a') {
|
divisor = Math.ceil(Math.random() * 10
|
||||||
divisor = Math.ceil(Math.random() * 10
|
* Math.ceil(Math.random() * 10));
|
||||||
* Math.ceil(Math.random() * 10));
|
} else {
|
||||||
} else {
|
divisor = 1;
|
||||||
divisor = 1;
|
}
|
||||||
}
|
if (divisor === 0) {
|
||||||
if (divisor === 0) {
|
divisor = 1;
|
||||||
divisor = 1;
|
}
|
||||||
}
|
return divisor;
|
||||||
return divisor;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 1;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -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;
|
||||||
|
|||||||
+22
-21
@@ -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')
|
||||||
@@ -410,30 +411,30 @@ var Space = {
|
|||||||
.text('total score: ' + Score.totalScore())
|
.text('total score: ' + Score.totalScore())
|
||||||
.appendTo('.centerCont')
|
.appendTo('.centerCont')
|
||||||
.animate({opacity:1},1500);
|
.animate({opacity:1},1500);
|
||||||
$('<br />')
|
$('<br />')
|
||||||
.appendTo('.centerCont');
|
.appendTo('.centerCont');
|
||||||
|
|
||||||
$('#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;
|
||||||
Prestige.populateNewSave(backup);
|
Prestige.populateNewSave(backup);
|
||||||
$('.deleteSave, .share, .manualSave').remove();
|
$('.deleteSave, .share, .manualSave').remove();
|
||||||
$('#content, #notifications').remove();
|
$('#content, #notifications').remove();
|
||||||
$('.deleteSave, .share, .manualSave').attr('style', 'color: white;').animate({opacity:0},1500);
|
$('.deleteSave, .share, .manualSave').attr('style', 'color: white;').animate({opacity:0},1500);
|
||||||
$('<span>')
|
$('<span>')
|
||||||
.addClass('deleteSave endGame')
|
.addClass('deleteSave endGame')
|
||||||
.text('restart.')
|
.text('restart.')
|
||||||
.click(Engine.confirmDelete)
|
.click(Engine.confirmDelete)
|
||||||
.appendTo('.centerCont')
|
.appendTo('.centerCont')
|
||||||
.animate({opacity:1},1500);
|
.animate({opacity:1},1500);
|
||||||
Engine.options = {};
|
Engine.options = {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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){
|
||||||
|
|||||||
Reference in New Issue
Block a user