From cc6d14cf08e0e594f141b7a8ea9dd0892160bb93 Mon Sep 17 00:00:00 2001 From: Nero Ignis Date: Wed, 21 Apr 2021 23:22:28 +0200 Subject: [PATCH] Fix worth of resources; use resourcesToBuild for every building; make quest-skip cost 250 gold; add upgrade notifications for buildings; add new specific toasts; --- index.html | 2 +- js/app.js | 73 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 59 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 01c7b23..722e1af 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,7 @@

Redeem reward ({{ currentQuest.reward }} ) - Get a new quest ({{ 3 - questSkipCounter }} left) + Get a new quest for 250 ({{ 3 - questSkipCounter }} left)
You don't have a quest at the moment.
diff --git a/js/app.js b/js/app.js index 40ae019..fa3834b 100644 --- a/js/app.js +++ b/js/app.js @@ -18,56 +18,56 @@ let game = new Vue({ gold: { amount: 500, name: 'Gold', - worth: 100, + worth: 1, icon: 'img/gold.png', unlocked: true }, wood: { amount: 0, name: 'Wood', - worth: 10, + worth: 5, icon: 'img/wood.png', unlocked: false }, stone: { amount: 0, name: 'Stone', - worth: 25, + worth: 10, icon: 'img/stone.png', unlocked: false }, iron: { amount: 0, name: 'Iron', - worth: 100, + worth: 25, icon: 'img/iron.png', unlocked: false }, bricks: { amount: 0, name: 'Bricks', - worth: 200, + worth: 50, icon: 'img/bricks.png', unlocked: false }, corn: { amount: 0, name: 'Corn', - worth: 75, + worth: 35, icon: 'img/corn.png', unlocked: false }, coal: { amount: 0, name: 'Coal', - worth: 25, + worth: 30, icon: 'img/coal.png', unlocked: false }, planks: { amount: 0, name: 'Planks', - worth: 100, + worth: 75, icon: 'img/planks.png', unlocked: false } @@ -85,7 +85,7 @@ let game = new Vue({ amount: 100, intervalInSeconds: 15, price: 500, - amountPerLevel: [100, 250, 500, 750, 1000, 1500, 2000, 2500, 3000, 5000], + amountPerLevel: [100, 150, 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], }, @@ -100,9 +100,12 @@ let game = new Vue({ amount: 2, intervalInSeconds: 10, price: 250, - amountPerLevel: [10, 15, 20, 25, 30, 35, 40, 45, 50, 55], - pricePerLevel: [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000], - intervalPerLevel: [15, 15, 15, 15, 15, 15, 15, 15, 15, 15], + resourcesToBuild: { + gold: 250 + }, + amountPerLevel: [10, 15, 20, 25, 30, 30, 30, 30, 30, 30], + pricePerLevel: [250, 500, 1000, 1250, 1500, 2000, 3000, 4000, 5000, 6000], + intervalPerLevel: [15, 15, 15, 15, 15, 15, 10, 10, 5, 5], }, carpenter: { name: 'Carpenter', @@ -119,6 +122,10 @@ let game = new Vue({ requires: { wood: 2 }, + resourcesToBuild: { + wood: 600, + stone: 250 + }, 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], @@ -134,6 +141,9 @@ let game = new Vue({ amount: 2, intervalInSeconds: 20, price: 500, + resourcesToBuild: { + wood: 500 + }, 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], @@ -404,8 +414,9 @@ let game = new Vue({ if (resourcesMissing.length) { resourcesMissing.forEach((resource) => { - game.sendWarning( - 'Not enough ' + resource + ' to build ' + building.name + '!' + game.sendNotEnoughResourceToBuildWarning( + 'Not enough ' + resource + ' to build ' + building.name + '!', + building ); }); @@ -432,6 +443,10 @@ let game = new Vue({ upgradeBuilding(building, first = false) { if (building.level < (building.maxLevel)) { building.level++; + this.sendBuildingUpgradedNotification( + building.name + ' has been upgraded to level ' + building.level + '!', + building + ); if (building.level === building.maxLevel) { building.isUpgradeable = false; @@ -531,7 +546,13 @@ let game = new Vue({ if (rewardSum > 0) { if (skip) { - game.questSkipCounter++; + if (game.resources.gold.amount > 250) { + game.resources.gold.amount -= 250; + game.questSkipCounter++; + } else { + game.sendWarning('Not enough gold to skip this quest'); + return false; + } } quest['reward'] = rewardSum; @@ -681,6 +702,28 @@ let game = new Vue({ }); }, + sendNotEnoughResourceToBuildWarning(message, building) { + iziToast.show({ + color: 'red', + message: message, + image: 'img/' + building.icon + '.png', + position: 'bottomCenter', + transitionIn: 'boundInRight', + transitionInMobile: 'boundInRight' + }); + }, + + sendBuildingUpgradedNotification(message, building) { + iziToast.show({ + color: 'green', + message: message, + image: 'img/' + building.icon + '.png', + position: 'bottomCenter', + transitionIn: 'boundInRight', + transitionInMobile: 'boundInRight' + }); + }, + sendWarning(message) { iziToast.show({ color: 'red',