From 4e9e5d141aa3785dd31822a37267e70aeb64c0fe Mon Sep 17 00:00:00 2001 From: Nero Ignis Date: Mon, 19 Apr 2021 23:33:08 +0200 Subject: [PATCH] Add version-check; --- js/app.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/app.js b/js/app.js index 84603f1..d1bd3a4 100644 --- a/js/app.js +++ b/js/app.js @@ -137,11 +137,14 @@ let game = new Vue({ }, created() { this.storageNames = { + lastVersion: 'lastVersion', resources: 'resources' + this.version, buildings: 'buildings' + this.version, currentQuest: 'currentQuest' + this.version } + this.checkVersion(); + this.checkBuildings(); this.loadResourcesFromStorage(); this.currentQuest = JSON.parse(localStorage.getItem(this.storageNames.currentQuest)); @@ -150,6 +153,16 @@ let game = new Vue({ this.reloadBuildings(); }, methods: { + checkVersion() { + let lastVersion = localStorage.getItem(this.storageNames.lastVersion); + + if (lastVersion && lastVersion < this.version) { + this.sendSystemNotification('Your beta-progress has been resetted due to a new version of the game, we\'re very sorry about that.') + } + + localStorage.setItem(this.storageNames.lastVersion, this.version); + }, + checkBuildings() { let savedBuildings = JSON.parse(localStorage.getItem(this.storageNames.buildings)); @@ -540,6 +553,15 @@ let game = new Vue({ }); }, + sendSystemNotification(message) { + iziToast.show({ + color: 'red', + message: message, + position: 'topCenter', + timeout: 7000, + }); + }, + sendWarning(message) { iziToast.show({ color: 'red',