mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +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() {
|
||||
//Score.saveScore();
|
||||
if(typeof Storage != 'undefined' && localStorage) {
|
||||
if(Engine._saveTimer != null) {
|
||||
clearTimeout(Engine._saveTimer);
|
||||
|
||||
+39
-47
@@ -10,39 +10,36 @@ var Prestige = {
|
||||
|
||||
saveStores: function(saveBool) {
|
||||
var prevStores = [ //g = goods, w = weapons, a = ammo
|
||||
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'))
|
||||
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;
|
||||
}
|
||||
}
|
||||
if(saveBool) {
|
||||
$SM.set('previous.stores', prevStores);
|
||||
}
|
||||
return prevStores;
|
||||
},
|
||||
|
||||
@@ -96,26 +93,21 @@ var Prestige = {
|
||||
return prevStores;
|
||||
},
|
||||
|
||||
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;
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ var Score = {
|
||||
},
|
||||
|
||||
calculateScore: function() {
|
||||
var scoreUnadded = Prestige.saveStores(false);
|
||||
var scoreUnadded = $SM.getStores();
|
||||
var fullScore = 0;
|
||||
fullScore = fullScore + scoreUnadded[0] * 1;
|
||||
fullScore = fullScore + scoreUnadded[1] * 1.5;
|
||||
|
||||
+22
-21
@@ -393,7 +393,8 @@ var Space = {
|
||||
var backup = new Object();
|
||||
backup.score = null;
|
||||
backup.stores = null;
|
||||
|
||||
Prestige.saveStores();
|
||||
Prestige.saveScore();
|
||||
|
||||
$('<center>')
|
||||
.addClass('centerCont')
|
||||
@@ -410,30 +411,30 @@ var Space = {
|
||||
.text('total score: ' + Score.totalScore())
|
||||
.appendTo('.centerCont')
|
||||
.animate({opacity:1},1500);
|
||||
$('<br />')
|
||||
$('<br />')
|
||||
.appendTo('.centerCont');
|
||||
|
||||
$('#starsContainer').remove();
|
||||
$('#starsContainer').remove();
|
||||
if(typeof Storage != 'undefined' && localStorage) {
|
||||
backup.stores = Prestige.saveStores(true);
|
||||
backup.score = Prestige.saveScore();
|
||||
backup.stores = $SM.getStores();
|
||||
backup.score = Score.totalScore();
|
||||
localStorage.clear();
|
||||
}
|
||||
delete window.State;
|
||||
Prestige.populateNewSave(backup);
|
||||
$('.deleteSave, .share, .manualSave').remove();
|
||||
$('#content, #notifications').remove();
|
||||
$('.deleteSave, .share, .manualSave').attr('style', 'color: white;').animate({opacity:0},1500);
|
||||
$('<span>')
|
||||
.addClass('deleteSave endGame')
|
||||
.text('restart.')
|
||||
.click(Engine.confirmDelete)
|
||||
.appendTo('.centerCont')
|
||||
.animate({opacity:1},1500);
|
||||
Engine.options = {};
|
||||
}
|
||||
});
|
||||
}, 2000);
|
||||
}
|
||||
delete window.State;
|
||||
Prestige.populateNewSave(backup);
|
||||
$('.deleteSave, .share, .manualSave').remove();
|
||||
$('#content, #notifications').remove();
|
||||
$('.deleteSave, .share, .manualSave').attr('style', 'color: white;').animate({opacity:0},1500);
|
||||
$('<span>')
|
||||
.addClass('deleteSave endGame')
|
||||
.text('restart.')
|
||||
.click(Engine.confirmDelete)
|
||||
.appendTo('.centerCont')
|
||||
.animate({opacity:1},1500);
|
||||
Engine.options = {};
|
||||
}
|
||||
});
|
||||
}, 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
|
||||
//hopefully this won't ever need to be more complicated
|
||||
buildPath: function(input){
|
||||
|
||||
Reference in New Issue
Block a user