mirror of
https://github.com/wassname/cardsforscience.git
synced 2026-08-11 11:16:12 +08:00
Properly validate save game support
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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: ''
|
||||
};
|
||||
})();
|
||||
|
||||
@@ -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">×</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
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user