|
|
@ -3,8 +3,8 @@ let game = new Vue({ |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
money: 0, |
|
|
|
money: 0, |
|
|
|
resources: { |
|
|
|
resources: { |
|
|
|
wood: 0, |
|
|
|
wood: 2, |
|
|
|
stone: 0, |
|
|
|
stone: 2, |
|
|
|
iron: 0, |
|
|
|
iron: 0, |
|
|
|
bricks: 0, |
|
|
|
bricks: 0, |
|
|
|
corn: 0 |
|
|
|
corn: 0 |
|
|
@ -228,6 +228,73 @@ let game = new Vue({ |
|
|
|
if (savedBuildings.length > 0) { |
|
|
|
if (savedBuildings.length > 0) { |
|
|
|
this.buildings = savedBuildings; |
|
|
|
this.buildings = savedBuildings; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generateQuest() { |
|
|
|
|
|
|
|
let possibleAmountsForQuest = [ |
|
|
|
|
|
|
|
0, 5, 10, 15, 20, 25, 30, 35 |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
let randomWood = 0; |
|
|
|
|
|
|
|
let randomStone = 0; |
|
|
|
|
|
|
|
let randomIron = 0; |
|
|
|
|
|
|
|
let randomBricks = 0; |
|
|
|
|
|
|
|
let randomCorn = 0; |
|
|
|
|
|
|
|
let rewardSum = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.resources.wood > 0) { |
|
|
|
|
|
|
|
randomWood = this.getRandomElement(possibleAmountsForQuest); |
|
|
|
|
|
|
|
rewardSum += (randomWood * 5); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.resources.stone > 0) { |
|
|
|
|
|
|
|
randomStone = this.getRandomElement(possibleAmountsForQuest); |
|
|
|
|
|
|
|
rewardSum += (randomStone * 7); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.resources.iron > 0) { |
|
|
|
|
|
|
|
randomIron = this.getRandomElement(possibleAmountsForQuest); |
|
|
|
|
|
|
|
rewardSum += (randomIron * 15); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.resources.bricks > 0) { |
|
|
|
|
|
|
|
randomBricks = this.getRandomElement(possibleAmountsForQuest); |
|
|
|
|
|
|
|
rewardSum += (randomBricks * 25); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.resources.corn > 0) { |
|
|
|
|
|
|
|
randomCorn = this.getRandomElement(possibleAmountsForQuest); |
|
|
|
|
|
|
|
rewardSum += (randomCorn * 30); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rewardSum > 0) { |
|
|
|
|
|
|
|
this.currentQuest = { |
|
|
|
|
|
|
|
wood: randomWood, |
|
|
|
|
|
|
|
stone: randomStone, |
|
|
|
|
|
|
|
iron: randomIron, |
|
|
|
|
|
|
|
bricks: randomBricks, |
|
|
|
|
|
|
|
corn: randomCorn, |
|
|
|
|
|
|
|
reward: rewardSum |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.currentQuest = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.currentQuest; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getRandomElement(possibleValues) { |
|
|
|
|
|
|
|
return possibleValues[Math.floor(Math.random() * possibleValues.length)]; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isQuestRedeemable() { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
this.wood >= this.currentQuest.wood && |
|
|
|
|
|
|
|
this.stone >= this.currentQuest.stone && |
|
|
|
|
|
|
|
this.iron >= this.currentQuest.iron && |
|
|
|
|
|
|
|
this.bricks >= this.currentQuest.bricks && |
|
|
|
|
|
|
|
this.corn >= this.currentQuest.corn |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|