|
|
@ -23,11 +23,14 @@ let game = new Vue({ |
|
|
|
isOwned: true, |
|
|
|
isOwned: true, |
|
|
|
isUpgradeable: true, |
|
|
|
isUpgradeable: true, |
|
|
|
amount: 100, |
|
|
|
amount: 100, |
|
|
|
amountMultiplicator: 1.5, |
|
|
|
amountMultiplicator: false, |
|
|
|
intervalInSeconds: 30, |
|
|
|
intervalInSeconds: 15, |
|
|
|
intervalMultiplicator: 1, |
|
|
|
intervalMultiplicator: false, |
|
|
|
price: 1000, |
|
|
|
price: 500, |
|
|
|
priceMultiplicator: 10, |
|
|
|
priceMultiplicator: false, |
|
|
|
|
|
|
|
amountPerLevel: [100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 5000], |
|
|
|
|
|
|
|
pricePerLevel: [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000], |
|
|
|
|
|
|
|
intervalPerLevel: [15, 25, 30, 45, 60, 90, 90, 120, 120, 120], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
name: 'Lumberjack', |
|
|
|
name: 'Lumberjack', |
|
|
@ -141,7 +144,7 @@ let game = new Vue({ |
|
|
|
|
|
|
|
|
|
|
|
this.checkBuildings(); |
|
|
|
this.checkBuildings(); |
|
|
|
this.loadResourcesFromStorage(); |
|
|
|
this.loadResourcesFromStorage(); |
|
|
|
this.currentQuest = JSON.parse(localStorage.getItem('currentQuest')); |
|
|
|
this.currentQuest = JSON.parse(localStorage.getItem(this.storageNames.currentQuest)); |
|
|
|
|
|
|
|
|
|
|
|
this.loadBuildingsFromStorage(); |
|
|
|
this.loadBuildingsFromStorage(); |
|
|
|
this.reloadBuildings(); |
|
|
|
this.reloadBuildings(); |
|
|
@ -153,17 +156,17 @@ let game = new Vue({ |
|
|
|
if (!savedBuildings) { |
|
|
|
if (!savedBuildings) { |
|
|
|
localStorage.setItem(this.storageNames.buildings, JSON.stringify(this.buildings)); |
|
|
|
localStorage.setItem(this.storageNames.buildings, JSON.stringify(this.buildings)); |
|
|
|
} else if (savedBuildings.length !== this.buildings.length) { |
|
|
|
} else if (savedBuildings.length !== this.buildings.length) { |
|
|
|
localStorage.setItem('buildings', JSON.stringify(this.buildings)); |
|
|
|
localStorage.setItem(this.storageNames.buildings, JSON.stringify(this.buildings)); |
|
|
|
this.sendInfo('Buildings have been resetted due to an important update.'); |
|
|
|
this.sendInfo('Buildings have been resetted due to an important update.'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
saveBuildingsToStorage() { |
|
|
|
saveBuildingsToStorage() { |
|
|
|
localStorage.setItem('buildings', JSON.stringify(this.buildings)); |
|
|
|
localStorage.setItem(this.storageNames.buildings, JSON.stringify(this.buildings)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
loadBuildingsFromStorage() { |
|
|
|
loadBuildingsFromStorage() { |
|
|
|
let savedBuildings = JSON.parse(localStorage.getItem('buildings')); |
|
|
|
let savedBuildings = JSON.parse(localStorage.getItem(this.storageNames.buildings)); |
|
|
|
|
|
|
|
|
|
|
|
if (savedBuildings) { |
|
|
|
if (savedBuildings) { |
|
|
|
savedBuildings.forEach((building) => { |
|
|
|
savedBuildings.forEach((building) => { |
|
|
@ -181,11 +184,11 @@ let game = new Vue({ |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
saveResourcesToStorage() { |
|
|
|
saveResourcesToStorage() { |
|
|
|
localStorage.setItem('resources', JSON.stringify(this.resources)); |
|
|
|
localStorage.setItem(this.storageNames.resources, JSON.stringify(this.resources)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
loadResourcesFromStorage: function () { |
|
|
|
loadResourcesFromStorage: function () { |
|
|
|
let savedResources = JSON.parse(localStorage.getItem('resources')); |
|
|
|
let savedResources = JSON.parse(localStorage.getItem(this.storageNames.resources)); |
|
|
|
|
|
|
|
|
|
|
|
if (savedResources) { |
|
|
|
if (savedResources) { |
|
|
|
this.resources = savedResources; |
|
|
|
this.resources = savedResources; |
|
|
@ -336,13 +339,26 @@ let game = new Vue({ |
|
|
|
building.isUpgradeable = false; |
|
|
|
building.isUpgradeable = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building.priceMultiplicator) { |
|
|
|
building.price = Number( |
|
|
|
building.price = Number( |
|
|
|
building.price * building.priceMultiplicator |
|
|
|
building.price * building.priceMultiplicator |
|
|
|
).toFixed(2); |
|
|
|
).toFixed(0); |
|
|
|
|
|
|
|
} else if (building.pricePerLevel) { |
|
|
|
|
|
|
|
building.price = building.pricePerLevel[building.level]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (first === false) { |
|
|
|
if (first === false) { |
|
|
|
|
|
|
|
if (building.amountMultiplicator) { |
|
|
|
building.amount = building.amount * building.amountMultiplicator; |
|
|
|
building.amount = building.amount * building.amountMultiplicator; |
|
|
|
|
|
|
|
} else if (building.amountPerLevel) { |
|
|
|
|
|
|
|
building.amount = building.amountPerLevel[building.level]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building.intervalMultiplicator) { |
|
|
|
building.intervalInSeconds = Number(building.intervalInSeconds * building.intervalMultiplicator).toFixed(2); |
|
|
|
building.intervalInSeconds = Number(building.intervalInSeconds * building.intervalMultiplicator).toFixed(2); |
|
|
|
|
|
|
|
} else if (building.intervalPerLevel) { |
|
|
|
|
|
|
|
building.intervalInSeconds = building.intervalPerLevel[building.level]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.reloadSingleBuilding(building); |
|
|
|
this.reloadSingleBuilding(building); |
|
|
@ -423,7 +439,7 @@ let game = new Vue({ |
|
|
|
this.sendInfo('There are no quests available, get some resources first.') |
|
|
|
this.sendInfo('There are no quests available, get some resources first.') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
localStorage.setItem('currentQuest', JSON.stringify(this.currentQuest)); |
|
|
|
localStorage.setItem(this.storageNames.currentQuest, JSON.stringify(this.currentQuest)); |
|
|
|
return this.currentQuest; |
|
|
|
return this.currentQuest; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|