Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Fix issue #13
Browse files Browse the repository at this point in the history
+ Refactoring and minor improvements
+ ESLint
  • Loading branch information
suhrmann committed May 13, 2019
1 parent 0aa9780 commit b76f282
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 186 deletions.
5 changes: 4 additions & 1 deletion src/components/Home.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<template>
<div>

</div>
</template>

<script>
export default {
name: 'home',
};
</script>

<style>
Expand Down
25 changes: 13 additions & 12 deletions src/components/helperFunctionMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export const helperFunctionMixin = {
this.productionTimes = [];
const chainNodeMixin = this;
chainNodeMixin.iterateProductionChain(
productionChain,
(rootElement) => {
this.fetchProductionTime(rootElement);
},
(element) => {
this.fetchProductionTime(element);
},
false);
productionChain,
(rootElement) => {
this.fetchProductionTime(rootElement);
},
(element) => {
this.fetchProductionTime(element);
},
false
);
return this.productionTimes;
},

Expand Down Expand Up @@ -170,7 +171,7 @@ export const helperFunctionMixin = {
getSocialClassByID(id) {
const socialClasses = Object.values(SocialClasses);
const selectedSocialClass = socialClasses.filter(
(socialClass) => socialClass.id === id
(socialClass) => socialClass.id === id
)[0];
return selectedSocialClass;
},
Expand All @@ -184,9 +185,9 @@ export const helperFunctionMixin = {
* @return {string} The resulting, nicely rounded number.
*/
toFixedVariable(num, digits) {
return Number.isInteger(num) ?
num :
num.toFixed(digits);
return Number.isInteger(num)
? num
: num.toFixed(digits);
},

},
Expand Down
82 changes: 41 additions & 41 deletions src/components/production_chains/ResourcePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
</template>

<script>
import { helperFunctionMixin } from "../helperFunctionMixin.js";
import { chainNodeMixin } from "./chainNodeMixin.js";
import { helperFunctionMixin } from '../helperFunctionMixin.js';
import { chainNodeMixin } from './chainNodeMixin.js';
export default {
mixins: [chainNodeMixin, helperFunctionMixin],
props: {
chain: {
type: Object
}
type: Object,
},
},
data() {
return {
Expand All @@ -48,104 +48,104 @@ export default {
steel: 0,
window: 0,
concrete: 0,
influence: 0
}
influence: 0,
},
};
},
computed: {
costArray() {
let filteredArray = [];
const filteredArray = [];
if (this.requiredResources.cash !== 0) {
filteredArray.push({
amount: this.requiredResources.cash,
name: "Cash",
image: "icon-credits.webp",
imageFileFolder: "icons"
name: 'Cash',
image: 'icon-credits.webp',
imageFileFolder: 'icons',
});
}
if (this.requiredResources.cashUpkeep !== 0) {
filteredArray.push({
amount: this.requiredResources.cashUpkeep,
name: "Upkeep",
image: "balance.webp",
imageFileFolder: "icons"
name: 'Upkeep',
image: 'balance.webp',
imageFileFolder: 'icons',
});
}
if (this.requiredResources.wood !== 0) {
filteredArray.push({
amount: this.requiredResources.wood,
name: "Wood",
image: "wood.webp",
imageFileFolder: "buildings/farmers"
name: 'Wood',
image: 'wood.webp',
imageFileFolder: 'buildings/farmers',
});
}
if (this.requiredResources.bricks !== 0) {
filteredArray.push({
amount: this.requiredResources.bricks,
name: "Bricks",
image: "bricks.webp",
imageFileFolder: "buildings/workers"
name: 'Bricks',
image: 'bricks.webp',
imageFileFolder: 'buildings/workers',
});
}
if (this.requiredResources.steel !== 0) {
filteredArray.push({
amount: this.requiredResources.steel,
name: "Steel",
image: "steel.webp",
imageFileFolder: "buildings/workers"
name: 'Steel',
image: 'steel.webp',
imageFileFolder: 'buildings/workers',
});
}
if (this.requiredResources.window !== 0) {
filteredArray.push({
amount: this.requiredResources.window,
name: "Window",
image: "windows.webp",
imageFileFolder: "buildings/artisans"
name: 'Window',
image: 'windows.webp',
imageFileFolder: 'buildings/artisans',
});
}
if (this.requiredResources.concrete !== 0) {
filteredArray.push({
amount: this.requiredResources.concrete,
name: "Concrete",
image: "reinforced-concrete.webp",
imageFileFolder: "buildings/engineers"
name: 'Concrete',
image: 'reinforced-concrete.webp',
imageFileFolder: 'buildings/engineers',
});
}
if (this.requiredResources.influence !== 0) {
filteredArray.push({
amount: this.requiredResources.influence,
name: "Influence",
image: "influence.webp"
name: 'Influence',
image: 'influence.webp',
});
}
return filteredArray;
}
},
},
watch: {
chain(newChain) {
const chainNodeMixin = this;
this.resetRequiredResources();
chainNodeMixin.iterateProductionChain(
this.chain,
rootElement => this.getResourceReq(rootElement),
element => this.getResourceReq(element),
false
this.chain,
(rootElement) => this.getResourceReq(rootElement),
(element) => this.getResourceReq(element),
false
);
}
},
},
methods: {
getResourceReq(element) {
const helperFunctionMixin = this;
const building = helperFunctionMixin.getBuildingByName(
element.name,
element.worldID
element.name,
element.worldID
);
this.requiredResources.cash +=
Expand Down Expand Up @@ -173,10 +173,10 @@ export default {
steel: 0,
window: 0,
concrete: 0,
influence: 0
influence: 0,
};
}
}
},
},
};
</script>

Expand Down
Loading

0 comments on commit b76f282

Please sign in to comment.