diff --git a/.gitignore b/.gitignore index 40a85ff..b4aeda7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.settings +*.TODO \ No newline at end of file diff --git a/css/space.css b/css/space.css index e74fa08..9bcf331 100644 --- a/css/space.css +++ b/css/space.css @@ -131,4 +131,19 @@ position: absolute; top: 0px; left: 0px; +} + +.centerCont { + padding-top:10%; +} + +.endGame { + font-size:48px; + color:#FFFFFF; + opacity:0; + position:relative; +} + +.endGameRestart { + font-size: 32px; } \ No newline at end of file diff --git a/index.html b/index.html index 0389885..ac8eba3 100644 --- a/index.html +++ b/index.html @@ -34,6 +34,7 @@ + @@ -61,7 +62,7 @@ (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), 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('send', 'pageview'); diff --git a/list.TODO b/list.TODO new file mode 100644 index 0000000..5df55ae --- /dev/null +++ b/list.TODO @@ -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) \ No newline at end of file diff --git a/script/prestige.js b/script/prestige.js index ab6a096..6f2cd1e 100644 --- a/script/prestige.js +++ b/script/prestige.js @@ -8,7 +8,7 @@ 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')), @@ -40,24 +40,29 @@ var Prestige = { prevStores[n] = 0; } } - $SM.set('previous.stores', prevStores); - return 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]); diff --git a/script/scoring.js b/script/scoring.js new file mode 100644 index 0000000..04b8a83 --- /dev/null +++ b/script/scoring.js @@ -0,0 +1,54 @@ +var Score = { + + name: 'Score', + + options: {}, + + init: function(options) { + this.options = $.extend(this.options, options); + }, + + calculateScore: function() { + var scoreUnadded = $SM.getStores(); + 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; + } +} \ No newline at end of file diff --git a/script/space.js b/script/space.js index 628a2b9..73254f0 100644 --- a/script/space.js +++ b/script/space.js @@ -42,6 +42,9 @@ var Space = { $('
').addClass('row_key').text('hull: ').appendTo(h); $('
').addClass('row_val').appendTo(h); + //save current score + Score.saveScore(); + //subscribe to stateUpdates $.Dispatch('stateUpdate').subscribe(Space.handleStateUpdates); }, @@ -251,7 +254,7 @@ var Space = { }, 1000); 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.createAsteroid(); @@ -331,7 +334,7 @@ var Space = { $('#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'); Engine.activeModule = Ship; Ship.onArrival(); @@ -387,21 +390,53 @@ var Space = { }, complete: function() { Engine.GAME_OVER = true; - var backup; - $('#starsContainer').remove(); - if(typeof Storage != 'undefined' && localStorage) { - backup = Prestige.save(); - localStorage.clear(); - } - delete window.State; - $('.deleteSave, .share').remove(); - Prestige.populateNewSave(backup); - $('#content, #notifications').remove(); - $('.deleteSave, .share').attr('style', 'color: white;'); - Engine.options = {}; - } - }); - }, 2000); + var backup = new Object(); + backup.score = null; + backup.stores = null; + Prestige.saveStores(); + Prestige.saveScore(); + + $('
') + .addClass('centerCont') + .appendTo('body'); + $('') + .addClass('endGame') + .text('score for this game: ' + Score.calculateScore()) + .appendTo('.centerCont') + .animate({opacity:1},1500); + $('
') + .appendTo('.centerCont'); + $('') + .addClass('endGame') + .text('total score: ' + Score.totalScore()) + .appendTo('.centerCont') + .animate({opacity:1},1500); + $('
') + .appendTo('.centerCont'); + $('
') + .appendTo('.centerCont'); + + $('#starsContainer').remove(); + if(typeof Storage != 'undefined' && localStorage) { + 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); + $('') + .addClass('deleteSave endGame endGameRestart') + .text('restart.') + .click(Engine.confirmDelete) + .appendTo('.centerCont') + .animate({opacity:1},1500); + Engine.options = {}; + } + }); + }, 2000); }); }, 2000); }); diff --git a/script/state_manager.js b/script/state_manager.js index 3b0e9ea..eed28d5 100644 --- a/script/state_manager.js +++ b/script/state_manager.js @@ -34,7 +34,8 @@ var StateManager = { 'income', 'timers', '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) { @@ -189,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){