Browse Source

Major refactor; Add debug options;

master
Nero Ignis 4 years ago
parent
commit
af08c41508
  1. 5
      .idea/inspectionProfiles/Project_Default.xml
  2. 145
      index.html
  3. 231
      js/app.js

5
.idea/inspectionProfiles/Project_Default.xml

@ -1,6 +1,11 @@
<component name="InspectionProjectProfileManager"> <component name="InspectionProjectProfileManager">
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="52" name="JavaScript" />
</Languages>
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false"> <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" /> <option name="processCode" value="true" />
<option name="processLiterals" value="true" /> <option name="processLiterals" value="true" />

145
index.html

@ -24,42 +24,15 @@
</a> </a>
<div class="card-body" id="collapseResources"> <div class="card-body" id="collapseResources">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12" v-for="resource in resources" v-if="resource.amount > 0 || resource.name === 'Gold'">
<div class="float-right">{{ getFormattedNumber(resources.gold) }} <img class="resource-icon" src="img/gold.png"></div> <div class="float-right">{{ getFormattedNumber(resource.amount) }} <img class="resource-icon" :src="resource.icon"></div>
Gold {{ resource.name }}
</div>
<div class="col-md-12" v-if="resources.wood > 0">
<div class="float-right">{{ getFormattedNumber(resources.wood) }} <img class="resource-icon" src="img/wood.png"></div>
Wood
</div>
<div class="col-md-12" v-if="resources.planks > 0">
<div class="float-right">{{ getFormattedNumber(resources.planks) }} <img class="resource-icon" src="img/planks.png"></div>
Planks
</div>
<div class="col-md-12" v-if="resources.stone > 0">
<div class="float-right">{{ getFormattedNumber(resources.stone) }} <img class="resource-icon" src="img/stone.png"></div>
Stones
</div>
<div class="col-md-12" v-if="resources.coal > 0">
<div class="float-right">{{ getFormattedNumber(resources.coal) }} <img class="resource-icon" src="img/coal.png"></div>
Coal
</div>
<div class="col-md-12" v-if="resources.iron > 0">
<div class="float-right">{{ getFormattedNumber(resources.iron) }} <img class="resource-icon" src="img/iron.png"></div>
Iron
</div>
<div class="col-md-12" v-if="resources.corn > 0">
<div class="float-right">{{ getFormattedNumber(resources.corn) }} <img class="resource-icon" src="img/corn.png"></div>
Corn
</div>
<div class="col-md-12" v-if="resources.bricks > 0">
<div class="float-right">{{ getFormattedNumber(resources.bricks) }} <img class="resource-icon" src="img/bricks.png"></div>
Bricks
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="card"> <div class="card">
<a class="card-header" data-toggle="collapse" href="#collapseQuest" role="button" aria-expanded="true" aria-controls="collapseQuest"> <a class="card-header" data-toggle="collapse" href="#collapseQuest" role="button" aria-expanded="true" aria-controls="collapseQuest">
@ -68,37 +41,24 @@
<div class="card-body" id="collapseQuest"> <div class="card-body" id="collapseQuest">
<div v-if="currentQuest"> <div v-if="currentQuest">
Items needed: <br/> Items needed: <br/>
<span v-if="currentQuest.wood > 0" :style="'color: ' + getColorForQuestResource(currentQuest.wood, resources.wood)"> <span v-for="resource in resources" v-if="currentQuest[resource.name.toLowerCase()] > 0" :style="'color: ' + getColorForQuestResource(currentQuest[resource.name.toLowerCase()], resource.amount)">
<img title="wood" class="resource-icon" src="img/wood.png"> {{ currentQuest.wood }} <img :title="resource.name" class="resource-icon" :src="resource.icon"> {{ currentQuest[resource.name.toLowerCase()] }}
</span>
<span v-if="currentQuest.planks > 0" :style="'color: ' + getColorForQuestResource(currentQuest.planks, resources.planks)">
<img title="wood" class="resource-icon" src="img/planks.png"> {{ currentQuest.planks }}
</span>
<span v-if="currentQuest.stone > 0" :style="'color: ' + getColorForQuestResource(currentQuest.stone, resources.stone)">
<img title="stone" class="resource-icon" src="img/stone.png"> {{ currentQuest.stone }}
</span>
<span v-if="currentQuest.coal > 0" :style="'color: ' + getColorForQuestResource(currentQuest.coal, resources.coal)">
<img title="coal" class="resource-icon" src="img/coal.png"> {{ currentQuest.coal }}
</span>
<span v-if="currentQuest.iron > 0" :style="'color: ' + getColorForQuestResource(currentQuest.iron, resources.iron)">
<img title="iron" class="resource-icon" src="img/iron.png"> {{ currentQuest.iron }}
</span>
<span v-if="currentQuest.bricks > 0" :style="'color: ' + getColorForQuestResource(currentQuest.bricks, resources.bricks)">
<img title="bricks" class="resource-icon" src="img/bricks.png"> {{ currentQuest.bricks }}
</span>
<span v-if="currentQuest.corn > 0" :style="'color: ' + getColorForQuestResource(currentQuest.corn, resources.corn)">
<img title="corn" class="resource-icon" src="img/corn.png"> {{ currentQuest.corn }}
</span> </span>
<br/> <br/>
<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 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()"><i class="fas fa-question"></i> Get a new quest</a>
</div> </div>
<div v-else> <div v-else>
<a class="btn btn-sm btn-info" @click="generateQuestWithRandomItems()"><i class="fas fa-question"></i> Get a new quest</a> You don't have a quest at the moment. <br/>
<br/>
<br/>
<a class="btn btn-sm btn-info float-right" @click="generateQuestWithRandomItems()"><i class="fas fa-question"></i> Get a new quest</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div class="card"> <div class="card">
<a class="card-header" data-toggle="collapse" href="#collapseOwned" role="button" aria-expanded="true" aria-controls="collapseOwned"> <a class="card-header" data-toggle="collapse" href="#collapseOwned" role="button" aria-expanded="true" aria-controls="collapseOwned">
@ -163,47 +123,72 @@
<div class="col-md-12"> <div class="col-md-12">
<div class="card"> <div class="card">
<div class="card-header">Sandbox</div> <a class="card-header" data-toggle="collapse" href="#collapseDebug" role="button" aria-expanded="true" aria-controls="collapseDebug">
<h3>Debug</h3>
</a>
<div class="card-body" id="collapseDebug">
<a href="https://git.luna-development.net/neroignis/idle-buildup/issues"><i class="fas fa-bug"></i> Found a bug?</a><br/>
<br/>
<input type="checkbox" v-model="debug.levelSandbox"> Buildings-Sandbox<br/>
<input type="checkbox" v-model="debug.buildingsSandbox"> Resource-Sandbox<br/>
<a class="btn btn-sm btn-danger" style="margin: 0.5em;" href="javascript:" @click="resources = {gold: 500,wood: 50,stone: 50,iron: 50,bricks: 50,corn: 50,coal: 50,planks: 50}">Reset resources</a>
<a class="btn btn-sm btn-danger" style="margin: 0.5em;" href="javascript:" @click="reset()">Soft reset (everything except resources)</a><br/>
<a class="btn btn-sm btn-danger" style="margin: 0.5em;" href="javascript:" @click="reset(true)">Hard reset (everything)</a><br/>
</div>
</div>
</div>
<div class="col-md-12" v-if="debug.levelSandbox">
<div class="card">
<div class="card-header">Buildings Sandbox</div>
<div class="card-body"> <div class="card-body">
<template v-for="building in buildings" v-if="building.amountPerLevel || building.intervalPerLevel || building.pricePerLevel"> <template v-for="building in buildings" v-if="building.amountPerLevel || building.intervalPerLevel || building.pricePerLevel">
<h3><strong>{{ building.name }}</strong></h3> <h3><strong>{{ building.name }}</strong></h3>
Amout per Level:<br/> Amout per Level:<br/>
<input class="form-control form-control-sandbox" type="text" v-for="amount in building.amountPerLevel" @change="saveBuildingsToStorage()" :value="amount"><br/> <input class="form-control form-control-sandbox" type="text" v-for="amount in building.amountPerLevel" :value="amount"><br/>
Interval per Level:<br/> Interval per Level:<br/>
<input class="form-control form-control-sandbox" type="text" v-for="interval in building.intervalPerLevel" @change="saveBuildingsToStorage()" :value="interval"><br/> <input class="form-control form-control-sandbox" type="text" v-for="interval in building.intervalPerLevel" :value="interval"><br/>
Price per Level:<br/> Price per Level:<br/>
<input class="form-control form-control-sandbox" type="text" v-for="price in building.pricePerLevel" @change="saveBuildingsToStorage()" :value="price"><br/> <input class="form-control form-control-sandbox" type="text" v-for="price in building.pricePerLevel" :value="price"><br/>
<hr/><br/> <hr/><br/>
</template> </template>
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12" v-if="debug.buildingsSandbox">
<div class="card"> <div class="card">
<a class="card-header" data-toggle="collapse" href="#collapseDebug" role="button" aria-expanded="true" aria-controls="collapseDebug"> <div class="card-header">Resource Sandbox</div>
<h3>Debug</h3> <div class="card-body">
</a> <template v-for="resource in resources">
<div class="card-body" id="collapseDebug"> <h3><strong>{{ resource.name }}</strong></h3>
<h3>Known bugs</h3><br/> <div class="row">
<ul class="list-group"> <div class="col-md-3">
<li class="list-group-item"> <div class="form-group">
Blacksmith is broken at the moment and corrupts the resource-storage. <br/> <label for="">Name</label>
<a class="btn btn-sm btn-danger" href="javascript:" @click="removeBlackSmith()">Click here to fix it for now</a> <input class="form-control" type="text" v-model="resource.name">
</li> </div>
</ul> </div>
<br/> <div class="col-md-3">
<hr/> <div class="form-group">
<br/> <label for="">Worth</label>
<a href="https://git.luna-development.net/neroignis/idle-buildup/issues"><i class="fas fa-bug"></i> Found a bug?</a> <input class="form-control" type="text" v-model="resource.worth">
<br/> </div>
<hr/> </div>
<br/> <div class="col-md-3">
<a class="btn btn-sm btn-danger" href="javascript:" @click="resources = {gold: 500,wood: 50,stone: 50,iron: 50,bricks: 50,corn: 50,coal: 50,planks: 50}">Reset resources</a> <div class="form-group">
<br/> <label for="">Amount</label>
<br/> <input class="form-control" type="text" v-model="resource.amount">
<a class="btn btn-sm btn-danger" href="javascript:" @click="reset()">Soft reset (everything except resources)</a><br/> </div>
<a class="btn btn-sm btn-danger" href="javascript:" @click="reset(true)">Hard reset (everything)</a><br/> </div>
<div class="col-md-3">
<div class="form-group">
<label for="">Unlocked</label><br/>
<input type="checkbox" v-model="resource.unlocked">
</div>
</div>
</div>
</template>
</div> </div>
</div> </div>
</div> </div>

231
js/app.js

@ -1,25 +1,68 @@
let game = new Vue({ let game = new Vue({
el: '#root', el: '#root',
data: { data: {
version: 0.5, version: 0.6,
debug: {
levelSandbox: false,
buildingsSandbox: false
},
resources: { resources: {
gold: 0, gold: {
wood: 0, amount: 500,
stone: 0, name: 'Gold',
iron: 0, worth: 100,
bricks: 0, icon: 'img/gold.png',
corn: 0, unlocked: true
coal: 0, },
planks: 0 wood: {
}, amount: 0,
hadResource: { name: 'Wood',
wood: false, worth: 10,
stone: false, icon: 'img/wood.png',
iron: false, unlocked: false
bricks: false, },
corn: false, stone: {
coal: false, amount: 0,
planks: false name: 'Stone',
worth: 25,
icon: 'img/stone.png',
unlocked: false
},
iron: {
amount: 0,
name: 'Iron',
worth: 100,
icon: 'img/iron.png',
unlocked: false
},
bricks: {
amount: 0,
name: 'Bricks',
worth: 200,
icon: 'img/bricks.png',
unlocked: false
},
corn: {
amount: 0,
name: 'Corn',
worth: 75,
icon: 'img/corn.png',
unlocked: false
},
coal: {
amount: 0,
name: 'Coal',
worth: 25,
icon: 'img/coal.png',
unlocked: false
},
planks: {
amount: 0,
name: 'Planks',
worth: 100,
icon: 'img/planks.png',
unlocked: false
}
}, },
storageNames: null, storageNames: null,
buildings: [ buildings: [
@ -145,7 +188,6 @@ let game = new Vue({
this.storageNames = { this.storageNames = {
lastVersion: 'lastVersion', lastVersion: 'lastVersion',
resources: 'resources' + this.version, resources: 'resources' + this.version,
hadResource: 'hadResource' + this.version,
buildings: 'buildings' + this.version, buildings: 'buildings' + this.version,
currentQuest: 'currentQuest' + this.version currentQuest: 'currentQuest' + this.version
} }
@ -153,7 +195,6 @@ let game = new Vue({
this.checkVersion(); this.checkVersion();
this.checkBuildings(); this.checkBuildings();
this.loadHadResourceFromStorage();
this.loadResourcesFromStorage(); this.loadResourcesFromStorage();
this.currentQuest = JSON.parse(localStorage.getItem(this.storageNames.currentQuest)); this.currentQuest = JSON.parse(localStorage.getItem(this.storageNames.currentQuest));
@ -221,70 +262,58 @@ let game = new Vue({
} }
}, },
// Save resources a user ever had to generate quests
saveHadResourceToStorage() {
localStorage.setItem(this.storageNames.hadResource, JSON.stringify(this.hadResource));
},
loadHadResourceFromStorage: function () {
let savedHadResource = JSON.parse(localStorage.getItem(this.storageNames.hadResource));
if (savedHadResource) {
this.hadResource = savedHadResource;
}
},
// Resource-Management // Resource-Management
add(amount = 0, resource = 'gold') { add(amount = 0, resource = 'gold') {
switch (resource) { switch (resource) {
case 'wood': case 'wood':
this.sendResourceMessage(amount, 'wood'); this.sendResourceMessage(amount, 'wood');
this.resources.wood += amount; console.log(this.resources.wood.amount, amount);
this.hadResource.wood = true; this.resources.wood.amount += amount;
this.resources.wood.unlocked = true;
break; break;
case 'planks': case 'planks':
this.sendResourceMessage(amount, 'planks'); this.sendResourceMessage(amount, 'planks');
this.resources.planks += amount; this.resources.planks.amount += amount;
this.hadResource.planks = true; this.resources.planks.unlocked = true;
break; break;
case 'stone': case 'stone':
this.sendResourceMessage(amount, 'stone'); this.sendResourceMessage(amount, 'stone');
this.resources.stone += amount; this.resources.stone.amount += amount;
this.hadResource.stone = true; this.resources.stone.unlocked = true;
break; break;
case 'bricks': case 'bricks':
this.sendResourceMessage(amount, 'bricks'); this.sendResourceMessage(amount, 'bricks');
this.resources.bricks += amount; this.resources.bricks.amount += amount;
this.hadResource.bricks = true; this.resources.bricks.unlocked = true;
break; break;
case 'coal': case 'coal':
this.sendResourceMessage(amount, 'coal'); this.sendResourceMessage(amount, 'coal');
this.resources.coal += amount; this.resources.coal.amount += amount;
this.hadResource.coal = true; this.resources.coal.unlocked = true;
break; break;
case 'iron': case 'iron':
this.sendResourceMessage(amount, 'iron'); this.sendResourceMessage(amount, 'iron');
this.resources.iron += amount; this.resources.iron.amount += amount;
this.hadResource.iron = true; this.resources.iron.unlocked = true;
break; break;
case 'corn': case 'corn':
this.sendResourceMessage(amount, 'corn'); this.sendResourceMessage(amount, 'corn');
this.resources.corn += amount; this.resources.corn.amount += amount;
this.hadResource.corn = true; this.resources.corn.unlocked = true;
break; break;
case 'gold': case 'gold':
this.sendResourceMessage(amount, 'gold'); this.sendResourceMessage(amount, 'gold');
this.resources.gold += amount; this.resources.gold.amount += amount;
this.hadResource.gold = true; this.resources.gold.unlocked = true;
break; break;
} }
this.saveHadResourceToStorage(); this.$forceUpdate();
this.saveResourcesToStorage(); this.saveResourcesToStorage();
}, },
sub(amount = 0, resource = false) { sub(amount = 0, resource = false) {
this.resources.gold -= amount; this.resources.gold.amount -= amount;
return this.saveResourcesToStorage(); return this.saveResourcesToStorage();
}, },
@ -294,6 +323,9 @@ let game = new Vue({
this.buildings.forEach((building) => { this.buildings.forEach((building) => {
if (building.isOwned && !building.hasMissingResources) { if (building.isOwned && !building.hasMissingResources) {
building.price = building.pricePerLevel[building.level -1];
building.amount = building.amountPerLevel[building.level -1];
building.interval = building.intervalPerLevel[building.level -1];
vue.initiateIntervals(building); vue.initiateIntervals(building);
} }
}); });
@ -337,9 +369,12 @@ let game = new Vue({
}, },
buyBuilding(building) { buyBuilding(building) {
if (this.resources.gold >= building.price) { if (this.resources.gold.amount >= building.price) {
this.sub(building.price); this.sub(building.price);
building.isOwned = true; building.isOwned = true;
building.price = building.pricePerLevel[0];
building.amount = building.amountPerLevel[0];
building.interval = building.intervalPerLevel[0];
this.upgradeBuilding(building, true); this.upgradeBuilding(building, true);
this.saveBuildingsToStorage(); this.saveBuildingsToStorage();
@ -349,12 +384,12 @@ let game = new Vue({
}, },
buyUpgrade(building) { buyUpgrade(building) {
if (building.level === 'X') { if (building.level === building.maxLevel) {
this.sendWarning('Already at MAX-Level'); this.sendWarning('Already at MAX-Level');
return false; return false;
} }
if (this.resources.gold >= building.price) { if (this.resources.gold.amount >= building.price) {
this.sub(building.price); this.sub(building.price);
this.upgradeBuilding(building); this.upgradeBuilding(building);
} else { } else {
@ -376,9 +411,9 @@ let game = new Vue({
} }
building.price = building.pricePerLevel[building.level - 1]; building.price = building.pricePerLevel[building.level - 1];
building.amount = building.amountPerLevel[building.level - 1];
if (first === false) { if (first === false) {
building.amount = building.amountPerLevel[building.level - 1];
building.intervalInSeconds = building.intervalPerLevel[building.level - 1]; building.intervalInSeconds = building.intervalPerLevel[building.level - 1];
} }
@ -397,12 +432,12 @@ let game = new Vue({
buildingHasEnoughResourcesToStart(building) { buildingHasEnoughResourcesToStart(building) {
if (building.requires) { if (building.requires) {
return ( return (
building.requires.wood > this.resources.wood || building.requires.wood > this.resources.wood.amount ||
building.requires.stone > this.resources.stone || building.requires.stone > this.resources.stone.amount ||
building.requires.iron > this.resources.iron || building.requires.iron > this.resources.iron.amount ||
building.requires.bricks > this.resources.bricks || building.requires.bricks > this.resources.bricks.amount ||
building.requires.coal > this.resources.coal || building.requires.coal > this.resources.coal.amount ||
building.requires.corn > this.resources.corn building.requires.corn > this.resources.corn.amount
); );
} else { } else {
return true; return true;
@ -426,39 +461,39 @@ let game = new Vue({
let rewardSum = 0; let rewardSum = 0;
if (this.hadResource.wood > 0) { if (this.resources.wood.unlocked > 0) {
randomWood = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomWood = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomWood * 5); rewardSum += (randomWood * this.resources.wood.worth);
} }
if (this.hadResource.stone > 0) { if (this.resources.stone.unlocked > 0) {
randomStone = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomStone = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomStone * 7); rewardSum += (randomStone * this.resources.stone.worth);
} }
if (this.hadResource.iron > 0) { if (this.resources.iron.unlocked > 0) {
randomIron = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomIron = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomIron * 200); rewardSum += (randomIron * this.resources.iron.worth);
} }
if (this.hadResource.bricks > 0) { if (this.resources.bricks.unlocked > 0) {
randomBricks = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomBricks = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomBricks * 25); rewardSum += (randomBricks * this.resources.bricks.worth);
} }
if (this.hadResource.corn > 0) { if (this.resources.corn.unlocked > 0) {
randomCorn = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomCorn = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomCorn * 30); rewardSum += (randomCorn * this.resources.corn.worth);
} }
if (this.hadResource.coal > 0) { if (this.resources.coal.unlocked > 0) {
randomCoal = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomCoal = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomCoal * 10); rewardSum += (randomCoal * this.resources.coal.worth);
} }
if (this.hadResource.planks > 0) { if (this.resources.planks.unlocked > 0) {
randomPlanks = this.getRandomElementForQuestResource(possibleAmountsForQuest); randomPlanks = this.getRandomElementForQuestResource(possibleAmountsForQuest);
rewardSum += (randomPlanks * 5); rewardSum += (randomPlanks * this.resources.planks.worth);
} }
if (rewardSum > 0) { if (rewardSum > 0) {
@ -486,12 +521,12 @@ let game = new Vue({
}, },
isQuestRedeemable() { isQuestRedeemable() {
let enoughWood = this.resources.wood >= this.currentQuest.wood; let enoughWood = this.resources.wood.amount >= this.currentQuest.wood;
let enoughStone = this.resources.stone >= this.currentQuest.stone; let enoughStone = this.resources.stone.amount >= this.currentQuest.stone;
let enoughIron = this.resources.iron >= this.currentQuest.iron; let enoughIron = this.resources.iron.amount >= this.currentQuest.iron;
let enoughBricks = this.resources.bricks >= this.currentQuest.bricks; let enoughBricks = this.resources.bricks.amount >= this.currentQuest.bricks;
let enoughCorn = this.resources.corn >= this.currentQuest.corn; let enoughCorn = this.resources.corn.amount >= this.currentQuest.corn;
let enoughCoal = this.resources.coal >= this.currentQuest.coal; let enoughCoal = this.resources.coal.amount >= this.currentQuest.coal;
if (enoughWood && enoughStone && enoughIron && enoughBricks && enoughCorn && enoughCoal) { if (enoughWood && enoughStone && enoughIron && enoughBricks && enoughCorn && enoughCoal) {
return true; return true;
@ -502,13 +537,13 @@ let game = new Vue({
redeemReward() { redeemReward() {
if (this.isQuestRedeemable()) { if (this.isQuestRedeemable()) {
this.resources.gold += this.currentQuest.reward; this.resources.gold.amount += this.currentQuest.reward;
this.resources.wood -= this.currentQuest.wood; this.resources.wood.amount -= this.currentQuest.wood;
this.resources.stone -= this.currentQuest.stone; this.resources.stone.amount -= this.currentQuest.stone;
this.resources.iron -= this.currentQuest.iron; this.resources.iron.amount -= this.currentQuest.iron;
this.resources.bricks -= this.currentQuest.bricks; this.resources.bricks.amount -= this.currentQuest.bricks;
this.resources.corn -= this.currentQuest.corn; this.resources.corn.amount -= this.currentQuest.corn;
this.resources.coal -= this.currentQuest.coal; this.resources.coal.amount -= this.currentQuest.coal;
this.sendRewardMessage(this.currentQuest.reward); this.sendRewardMessage(this.currentQuest.reward);
this.generateQuestWithRandomItems(); this.generateQuestWithRandomItems();
@ -519,12 +554,12 @@ let game = new Vue({
}, },
useRequiredResources(building) { useRequiredResources(building) {
this.resources.wood -= building.requires.wood; this.resources.wood.amount -= (building.requires.wood ? building.requires.wood : 0);
this.resources.stone -= building.requires.stone; this.resources.stone.amount -= (building.requires.stone ? building.requires.stone : 0);
this.resources.iron -= building.requires.iron; this.resources.iron.amount -= (building.requires.iron ? building.requires.iron : 0);
this.resources.bricks -= building.requires.bricks; this.resources.bricks.amount -= (building.requires.bricks ? building.requires.bricks : 0);
this.resources.corn -= building.requires.corn; this.resources.corn.amount -= (building.requires.corn ? building.requires.corn : 0);
this.resources.coal -= building.requires.coal; this.resources.coal.amount -= (building.requires.coal ? building.requires.coal : 0);
}, },
// Templating // Templating
@ -623,16 +658,8 @@ let game = new Vue({
}); });
}, },
// Debug & Testing
removeBlackSmith() {
this.buildings[5].isOwned = false;
this.saveBuildingsToStorage();
location.reload();
},
reset(hard = false) { reset(hard = false) {
localStorage.removeItem('buildings' + this.version); localStorage.removeItem('buildings' + this.version);
localStorage.removeItem('hadResource' + this.version);
localStorage.removeItem('currentQuest' + this.version); localStorage.removeItem('currentQuest' + this.version);
if (hard) { if (hard) {

Loading…
Cancel
Save