Commit b2ba605d authored by Matthew Odle's avatar Matthew Odle

convert remaining uses of villageStore to objects

parent ac396253
......@@ -189,26 +189,25 @@ export class Village extends React.Component {
};
getTool = (villager) => {
const villageStore = this.state.villageStore.slice();
let tools = villageStore.find( material => material.name === 'tool')
if (tools.count > 0) {
const villageStore = this.state.villageStore;
if (villageStore['tool'].count > 0) {
villager.toolDurability = 100;
villager.hasTool = true;
tools.count -= 1;
villageStore['tool'].count -= 1;
}
}
checkVillagerTool = (villager) => {
villager.hasTool = villager.toolDurability > 0 ? true : false;
// only equip tools to villagers that are assigned to a building
villager.toolDurability <= 0 && villager.assignment !== "IDLE" ? villager = this.getTool(villager) : null;
!villager.hasTool && villager.assignment !== "IDLE" ? this.getTool(villager) : null;
}
getWarm = (villager) => {
const villageStore = this.state.villageStore.slice();
let firewood = villageStore.find( material => material.name === 'firewood')
if (firewood.count > 0) {
const villageStore = this.state.villageStore;
if (villageStore['firewood'].count > 0) {
villager.warmth += this.props.knobsAndLevers.warmthPerFirewood;
firewood.count -= 1;
villageStore['firewood'].count -= 1;
}
}
......@@ -231,12 +230,11 @@ export class Village extends React.Component {
}
getClothing = (villager) => {
const villageStore = this.state.villageStore.slice();
let clothing = villageStore.find( material => material.name === 'clothing')
if (clothing.count > 0) {
const villageStore = this.state.villageStore;
if (villageStore['clothing'].count > 0) {
villager.clothingDurability = 100;
villager.clothed = true;
clothing.count -= 1;
villageStore['clothing'].count -= 1;
}
}
......@@ -247,11 +245,10 @@ export class Village extends React.Component {
}
getFood = (villager) => {
const villageStore = this.state.villageStore.slice();
let food = villageStore.find( material => material.name === 'food')
if (food.count > 0) {
const villageStore = this.state.villageStore;
if (villageStore['food'].count > 0) {
villager.energy += this.props.knobsAndLevers.energyPerFood;
food.count -= 1;
villageStore['food'].count -= 1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment