Browse Source

Fix worth of resources;

use resourcesToBuild for every building;
make quest-skip cost 250 gold;
add upgrade notifications for buildings;
add new specific toasts;
master
Nero Ignis 4 years ago
parent
commit
cc6d14cf08
  1. 2
      index.html
  2. 73
      js/app.js

2
index.html

@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
<br/>
<br/>
<a href="javascript:" class="btn btn-sm btn-success float-right" @click="redeemReward()">Redeem reward ({{ currentQuest.reward }} <img class="resource-icon" src="img/gold.png">)</a>
<a class="btn btn-sm btn-info float-right" style="margin-right: 1em;" @click="generateQuestWithRandomItems(true)"><i class="fas fa-question"></i> Get a new quest ({{ 3 - questSkipCounter }} left)</a>
<a class="btn btn-sm btn-info float-right" style="margin-right: 1em;" @click="generateQuestWithRandomItems(true)"><i class="fas fa-question"></i> Get a new quest for 250 <img class="resource-icon" src="img/gold.png"> ({{ 3 - questSkipCounter }} left)</a>
</div>
<div v-else>
You don't have a quest at the moment. <br/>

73
js/app.js

@ -18,56 +18,56 @@ let game = new Vue({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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',

Loading…
Cancel
Save