Properly validate save game support

This commit is contained in:
Tadej Novak
2014-12-12 22:19:13 +01:00
parent 9fed95e1f1
commit 73b1ed1076
4 changed files with 13 additions and 25 deletions
+2 -2
View File
@@ -1,5 +1,7 @@
'use strict';
(function() {
Helpers.validateSaveVersion();
var game = new Game.Game();
game.load();
@@ -11,8 +13,6 @@
var allObjects = game.allObjects;
var lastSaved;
UI.validateVersion(lab.version);
var app = angular.module('particleClicker', []);
app.filter('niceNumber', ['$filter', function($filter) {
-1
View File
@@ -21,7 +21,6 @@ var GameObjects = (function() {
var Lab = function() {
GameObject.apply(this, [{
key : 'lab',
version : 0.9,
state : {
name : 'Give your lab an awesome name!',
detector : 1,
+10 -1
View File
@@ -68,12 +68,21 @@ var Helpers = (function () {
return str.join(', ');
};
var saveVersion = '1.0';
var validateSaveVersion = function () {
var ver = ObjectStorage.load('saveVersion');
if (typeof ver === 'undefined' || ver != saveVersion) {
ObjectStorage.clear();
ObjectStorage.save('saveVersion', saveVersion);
}
};
return {
loadFile: loadFile,
formatNumberPostfix: formatNumberPostfix,
formatTime: formatTime,
version: '0.9',
validateSaveVersion: validateSaveVersion,
analytics: ''
};
})();
+1 -21
View File
@@ -140,25 +140,6 @@ var UI = (function () {
window.setTimeout(remove(alert), 2000);
}
var validateVersion = function(version) {
if (version != Helpers.version) {
var alert = '<div id="outofdate" class="alert alert-info alert-dismissible" role="alert">';
alert += '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>';
alert += '<i class="fa fa-info-circle alert-glyph"></i> <span class="alert-text">Your saved state is out of date. <a href="#"><strong>Restart</strong></a> to use latest version of the game.</span>';
alert += '</div>';
alert = $(alert);
alert.find('a').click(function ()
{
if (window.confirm('Do you really want to restart the game? All progress will be lost.')) {
ObjectStorage.clear();
window.location.reload(true);
}
})
$('#messages-container').append(alert);
}
}
if (typeof $.cookie('cookielaw') === 'undefined') {
var alert = '<div id="cookielaw" class="alert alert-info" role="alert">';
alert += '<button type="button" class="btn btn-primary">OK</button>';
@@ -193,8 +174,7 @@ var UI = (function () {
showAchievement: showAchievement,
showModal: showModal,
showLevels: showLevels,
showUpdateValue: showUpdateValue,
validateVersion: validateVersion
showUpdateValue: showUpdateValue
}
})();