mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
started scoring system, yet to be populated
This commit is contained in:
@@ -131,4 +131,15 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centerCont {
|
||||||
|
padding-top:10%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.endGame {
|
||||||
|
font-size:48px;
|
||||||
|
color:#FFFFFF;
|
||||||
|
opacity:0;
|
||||||
|
position:relative;
|
||||||
}
|
}
|
||||||
+2
-1
@@ -34,6 +34,7 @@
|
|||||||
<script src="script/ship.js"></script>
|
<script src="script/ship.js"></script>
|
||||||
<script src="script/space.js"></script>
|
<script src="script/space.js"></script>
|
||||||
<script src="script/prestige.js"></script>
|
<script src="script/prestige.js"></script>
|
||||||
|
<script src="script/scoring.js"></script>
|
||||||
<!-- Event modules -->
|
<!-- Event modules -->
|
||||||
<script src="script/events/global.js"></script>
|
<script src="script/events/global.js"></script>
|
||||||
<script src="script/events/room.js"></script>
|
<script src="script/events/room.js"></script>
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
ga('create', 'UA-41314886-1', 'doublespeakgames.com');
|
ga('create', 'UA-41314886-1', 'doublespeakgames.com');
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
☐ fix the NaN issue at the space screen
|
||||||
|
☐ persuade michael to get everyone onboard with a big update
|
||||||
|
☐ school (never gonna happen)
|
||||||
|
☐ about page
|
||||||
|
✔ drool over sublime text @done (13-10-31 22:33)
|
||||||
@@ -157,6 +157,7 @@ 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);
|
||||||
|
|||||||
+59
-46
@@ -8,56 +8,64 @@ var Prestige = {
|
|||||||
this.options = $.extend(this.options, options);
|
this.options = $.extend(this.options, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
save: function() {
|
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('g')),
|
Math.floor($SM.get('stores["wood"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["fur"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["fur"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["meat"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["meat"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["iron"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["iron"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["coal"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["coal"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["sulphur"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["steel"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["steel"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["cured meat"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["scales"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["scales"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["teeth"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["teeth"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["leather"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["leather"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["bait"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["bait"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["torch"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["torch"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["cloth"]') / Prestige.randGen('g')),
|
Math.floor($SM.get('stores["cloth"]') / Prestige.randGen(saveBool, 'g')),
|
||||||
Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["bone spear"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["iron sword"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["steel sword"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["bayonet"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["rifle"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["rifle"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen('w')),
|
Math.floor($SM.get('stores["laser rifle"]') / Prestige.randGen(saveBool, 'w')),
|
||||||
Math.floor($SM.get('stores["bullets"]') / Prestige.randGen('a')),
|
Math.floor($SM.get('stores["bullets"]') / Prestige.randGen(saveBool, 'a')),
|
||||||
Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen('a')),
|
Math.floor($SM.get('stores["energy cell"]') / Prestige.randGen(saveBool, 'a')),
|
||||||
Math.floor($SM.get('stores["grenade"]') / Prestige.randGen('a')),
|
Math.floor($SM.get('stores["grenade"]') / Prestige.randGen(saveBool, 'a')),
|
||||||
Math.floor($SM.get('stores["bolas"]') / Prestige.randGen('a'))
|
Math.floor($SM.get('stores["bolas"]') / Prestige.randGen(saveBool, '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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$SM.set('previous.stores', prevStores);
|
if(saveBool) {
|
||||||
return prevStores;
|
$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 = {
|
State = {
|
||||||
previous : {
|
previous : {
|
||||||
stores : newstate
|
stores : newstate["stores"],
|
||||||
|
score : newstate["score"]
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
Engine.init({
|
Engine.init({
|
||||||
state : State
|
state : State
|
||||||
});
|
});
|
||||||
return State;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load : function() {
|
load : function() {
|
||||||
var prevStores = $SM.get('previous.stores');
|
var prevStores = $SM.get('previous.stores');
|
||||||
if(prevStores != null) {
|
if(prevStores != null) {
|
||||||
$SM.add('stores["wood"]', prevStores[0]);
|
$SM.add('stores["wood"]', prevStores[0]);
|
||||||
@@ -88,21 +96,26 @@ var Prestige = {
|
|||||||
return prevStores;
|
return prevStores;
|
||||||
},
|
},
|
||||||
|
|
||||||
randGen : function(storeType) {
|
randGen : function(saveBool, storeType) {
|
||||||
if (storeType == 'g') {
|
if (saveBool) {
|
||||||
divisor = Math.floor(Math.random() * 10);
|
if (storeType == 'g') {
|
||||||
} else if (storeType == 'w') {
|
divisor = Math.floor(Math.random() * 10);
|
||||||
divisor = Math.floor(Math.floor(Math.random() * 10) / 2);
|
} else if (storeType == 'w') {
|
||||||
} else if (storeType == 'a') {
|
divisor = Math.floor(Math.floor(Math.random() * 10) / 2);
|
||||||
divisor = Math.ceil(Math.random() * 10
|
} else if (storeType == 'a') {
|
||||||
* Math.ceil(Math.random() * 10));
|
divisor = Math.ceil(Math.random() * 10
|
||||||
} else {
|
* Math.ceil(Math.random() * 10));
|
||||||
divisor = 1;
|
} else {
|
||||||
}
|
divisor = 1;
|
||||||
if (divisor === 0) {
|
}
|
||||||
divisor = 1;
|
if (divisor === 0) {
|
||||||
}
|
divisor = 1;
|
||||||
return divisor;
|
}
|
||||||
|
return divisor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
var Score = {
|
||||||
|
|
||||||
|
name: 'Score',
|
||||||
|
|
||||||
|
options: {},
|
||||||
|
|
||||||
|
init: function(options) {
|
||||||
|
this.options = $.extend(this.options, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
calculateScore: function() {
|
||||||
|
var scoreUnadded = Prestige.saveStores(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"]') * 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
-9
@@ -42,6 +42,9 @@ var Space = {
|
|||||||
$('<div>').addClass('row_key').text('hull: ').appendTo(h);
|
$('<div>').addClass('row_key').text('hull: ').appendTo(h);
|
||||||
$('<div>').addClass('row_val').appendTo(h);
|
$('<div>').addClass('row_val').appendTo(h);
|
||||||
|
|
||||||
|
//save current score
|
||||||
|
Score.saveScore();
|
||||||
|
|
||||||
//subscribe to stateUpdates
|
//subscribe to stateUpdates
|
||||||
$.Dispatch('stateUpdate').subscribe(Space.handleStateUpdates);
|
$.Dispatch('stateUpdate').subscribe(Space.handleStateUpdates);
|
||||||
},
|
},
|
||||||
@@ -251,7 +254,7 @@ var Space = {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
Space._panelTimeout = setTimeout(function() {
|
Space._panelTimeout = setTimeout(function() {
|
||||||
$('#spacePanel, .deleteSave, .share').animate({color: 'white'}, 500, 'linear');
|
$('#spacePanel, .deleteSave, .share, .manualSave').animate({color: 'white'}, 500, 'linear');
|
||||||
}, Space.FTB_SPEED / 2);
|
}, Space.FTB_SPEED / 2);
|
||||||
|
|
||||||
Space.createAsteroid();
|
Space.createAsteroid();
|
||||||
@@ -331,7 +334,7 @@ var Space = {
|
|||||||
$('#starsContainer').remove();
|
$('#starsContainer').remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#spacePanel, .deleteSave, .share').animate({color: 'black'}, 300, 'linear');
|
$('#spacePanel, .deleteSave, .share, .manualSave').animate({color: 'black'}, 300, 'linear');
|
||||||
$('#outerSlider').animate({top: '0px'}, 300, 'linear');
|
$('#outerSlider').animate({top: '0px'}, 300, 'linear');
|
||||||
Engine.activeModule = Ship;
|
Engine.activeModule = Ship;
|
||||||
Ship.onArrival();
|
Ship.onArrival();
|
||||||
@@ -387,17 +390,44 @@ var Space = {
|
|||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
Engine.GAME_OVER = true;
|
Engine.GAME_OVER = true;
|
||||||
var backup;
|
var backup = new Object();
|
||||||
$('#starsContainer').remove();
|
backup.score = null;
|
||||||
|
backup.stores = null;
|
||||||
|
$('.deleteSave, .share, .manualSave').remove();
|
||||||
|
Prestige.populateNewSave(backup);
|
||||||
|
$('#content, #notifications').remove();
|
||||||
|
$('.deleteSave, .share, .manualSave').attr('style', 'color: white;').animate({opacity:0},1500);
|
||||||
|
|
||||||
|
$('<center>')
|
||||||
|
.addClass('centerCont')
|
||||||
|
.appendTo('body');
|
||||||
|
$('<span>')
|
||||||
|
.addClass('endGame')
|
||||||
|
.text('score for this game: ' + Score.calculateScore())
|
||||||
|
.appendTo('.centerCont')
|
||||||
|
.animate({opacity:1},1500);
|
||||||
|
$('<br />')
|
||||||
|
.appendTo('.centerCont');
|
||||||
|
$('<span>')
|
||||||
|
.addClass('endGame')
|
||||||
|
.text('total score: ' + Score.totalScore())
|
||||||
|
.appendTo('.centerCont')
|
||||||
|
.animate({opacity:1},1500);
|
||||||
|
$('<br />')
|
||||||
|
.appendTo('.centerCont');
|
||||||
|
$('<span>')
|
||||||
|
.addClass('deleteSave endGame')
|
||||||
|
.text('restart.')
|
||||||
|
.click(Engine.confirmDelete)
|
||||||
|
.appendTo('.centerCont')
|
||||||
|
.animate({opacity:1},1500);
|
||||||
|
$('#starsContainer').remove();
|
||||||
if(typeof Storage != 'undefined' && localStorage) {
|
if(typeof Storage != 'undefined' && localStorage) {
|
||||||
backup = Prestige.save();
|
backup.stores = Prestige.saveStores(true);
|
||||||
|
backup.score = Prestige.saveScore();
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
}
|
}
|
||||||
delete window.State;
|
delete window.State;
|
||||||
$('.deleteSave, .share').remove();
|
|
||||||
Prestige.populateNewSave(backup);
|
|
||||||
$('#content, #notifications').remove();
|
|
||||||
$('.deleteSave, .share').attr('style', 'color: white;');
|
|
||||||
Engine.options = {};
|
Engine.options = {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ var StateManager = {
|
|||||||
'income',
|
'income',
|
||||||
'timers',
|
'timers',
|
||||||
'game', //mostly location related: fire temp, workers, population, world map, etc
|
'game', //mostly location related: fire temp, workers, population, world map, etc
|
||||||
'playStats' //anything play related: play time, loads, etc
|
'playStats', //anything play related: play time, loads, etc
|
||||||
|
'previous' // prestige, score, trophies (in future), achievements (again, not yet), etc
|
||||||
];
|
];
|
||||||
|
|
||||||
for(var which in cats) {
|
for(var which in cats) {
|
||||||
|
|||||||
Reference in New Issue
Block a user