From 73b1ed10764a9c7738d33240ee39b78ef2618698 Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Fri, 12 Dec 2014 22:19:13 +0100 Subject: [PATCH] Properly validate save game support --- js/app.js | 4 ++-- js/gameobjects.js | 1 - js/helpers.js | 11 ++++++++++- js/ui.js | 22 +--------------------- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/js/app.js b/js/app.js index ecdc9d2..c143d05 100644 --- a/js/app.js +++ b/js/app.js @@ -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) { diff --git a/js/gameobjects.js b/js/gameobjects.js index 2a544fb..dccf0b5 100644 --- a/js/gameobjects.js +++ b/js/gameobjects.js @@ -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, diff --git a/js/helpers.js b/js/helpers.js index bdde8c6..7617d7d 100644 --- a/js/helpers.js +++ b/js/helpers.js @@ -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: '' }; })(); diff --git a/js/ui.js b/js/ui.js index b7f1df6..0db1056 100644 --- a/js/ui.js +++ b/js/ui.js @@ -140,25 +140,6 @@ var UI = (function () { window.setTimeout(remove(alert), 2000); } - var validateVersion = function(version) { - if (version != Helpers.version) { - var alert = ''; - 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 = '