From 6a2aa11b412049e997bb9516734ee549bc7c4baa Mon Sep 17 00:00:00 2001 From: Nero Ignis Date: Wed, 21 Apr 2021 22:48:16 +0200 Subject: [PATCH] Fix quest-generation for no unlocked resources; --- js/app.js | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/js/app.js b/js/app.js index 14d5d2f..40ae019 100644 --- a/js/app.js +++ b/js/app.js @@ -156,26 +156,31 @@ let game = new Vue({ pricePerLevel: [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000], intervalPerLevel: [15, 25, 30, 45, 60, 90, 90, 120, 120, 120], }, - // blacksmith: { - // name: 'Blacksmith', - // resource: 'iron', - // icon: 'medieval_blacksmith', - // level: 0, - // maxLevel: 10, - // isOwned: false, - // isUpgradeable: true, - // amount: 2, - // intervalInSeconds: 20, - // price: 500, - // hasRequirements: true, - // requires: { - // stone: 2, - // coal: 1 - // }, - // 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], - // }, + blacksmith: { + name: 'Blacksmith', + resource: 'iron', + icon: 'medieval_blacksmith', + level: 0, + maxLevel: 10, + isOwned: false, + isUpgradeable: true, + amount: 2, + intervalInSeconds: 20, + price: 500, + hasRequirements: true, + requires: { + stone: 2, + coal: 1 + }, + resourcesToBuild: { + gold: 6000, + wood: 200, + stone: 750 + }, + amountPerLevel: [15, 25, 30, 45, 60, 90, 90, 120, 120, 120], + pricePerLevel: [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000], + intervalPerLevel: [15, 25, 30, 45, 60, 90, 90, 120, 120, 120], + }, farm: { name: 'Farm', resource: 'corn', @@ -509,12 +514,12 @@ let game = new Vue({ 1, (maxResourcesPerQuest > unlockedResources.length) ? unlockedResources.length : maxResourcesPerQuest ); - } else { + } else if (unlockedResources.length === 1) { unlockedResources = [unlockedResources[0]]; } unlockedResources.forEach((resource) => { - if (game.resources[resource].unlocked === true && resource !== 'gold') { + if (resource !== 'gold') { let amount = game.getRandomAmountForQuestResource(); if (amount) {