Commit bfe83d01 authored by Matthew Odle's avatar Matthew Odle

calculate villager store usage rates

parent 446e3e03
......@@ -54,4 +54,33 @@ update:
2017-11-08
TODO
* Add varying production amounts, rather than just having each building produce 1 of each of its goods each round. This will make it so the gatherer's hut isn't useless by allowing it to produce 2 food. (this could be accomplished by just adding food to the gatherer's hut twice. This would have to be accounted for in the displaying of the goods in the gatherer's hut building element.
\ No newline at end of file
* Add varying production amounts, rather than just having each building produce 1 of each of its goods each round. This will make it so the gatherer's hut isn't useless by allowing it to produce 2 food. (this could be accomplished by just adding food to the gatherer's hut twice. This would have to be accounted for in the displaying of the goods in the gatherer's hut building element.
2017-11-25
Adding good production rate tooltips
create store copy
reset store rates
loop through buildings
determine building rate in ticks
K&L.productionComplete / building.productionRate
look at materials needed
store.material.rate -= buildingRate * material.qty
look at goods produced
store.material.rate += buildingRate * good.qty
loop through the villagers
determine villager food per tick
energyPerFood / villager.energyDecay
store.food.rate -= villager.foodPerTick
determine villager firewood per tick
warmthPerFirewood / villager.warmthDecay
store.firewood.rate -= villager.firewoodPerTick
determine villager tool per tick
toolDurability / villager.toolDecay
store.tool.rate -= villager.toolPerTick
determine villager clothing per tick
clothingDurability / villager.clothingDecay
store.clothing.rate -= villager.clothingPerTick
update store
\ No newline at end of file
......@@ -9,12 +9,16 @@ const addVillager = () => {
hasTool: KNOBS_AND_LEVERS.villagerHasTool,
toolDurability: KNOBS_AND_LEVERS.toolDurability,
assignment: "IDLE",
warmth: 100,
energy: 100,
warmth: KNOBS_AND_LEVERS.villagerStartingWarmth,
energy: KNOBS_AND_LEVERS.villagerStartingEnergy,
clothed: KNOBS_AND_LEVERS.villagerClothed,
clothingDurability: 100,
clothingDurability: KNOBS_AND_LEVERS.clothingDurability,
// clothed: nextId % 2 === 0 ? knobsAndLevers.villagerClothed : false,
// clothingDurability: nextId % 2 === 0 ? 100 : 0,
foodPerTick: KNOBS_AND_LEVERS.baseEnergyDegradeRate / 100,
firewoodPerTick: (KNOBS_AND_LEVERS.villagerClothed ? KNOBS_AND_LEVERS.baseWarmthDecayRate - KNOBS_AND_LEVERS.clothingWarmthDecayReduction : KNOBS_AND_LEVERS.baseWarmthDecayRate) / 100,
toolPerTick: 0,
clothingPerTick: KNOBS_AND_LEVERS.clothingDegradeRate / KNOBS_AND_LEVERS.clothingDurability,
};
villagers.push(villager);
if (villagers.length < KNOBS_AND_LEVERS['startingVillagers']) {
......
......@@ -7,6 +7,8 @@ const knobsAndLevers = {
villagerDeathValue: -50,
villagerWarningValue: 0,
villagerStartingWarmth: 100,
villagerStartingEnergy: 100,
villagerHasTool: true,
toolMultiplier: 4,
......@@ -14,17 +16,20 @@ const knobsAndLevers = {
toolDegradeRate: 1,
villagerClothed: true,
// villagerClothed: false,
clothingDegradeRate: 1,
clothingWarmthDecayReduction: 2,
clothingDurability: 100,
// clothingDurability: 0,
baseWarmthDecayRate: 3,
warmthReplenishThreshold: 10,
warmthPerFirewood: 80,
warmthReplenishThreshold: 0,
warmthPerFirewood: 100,
baseEnergyDegradeRate: 1,
// baseEnergyDegradeRate: 100,
// baseEnergyDegradeRate: 20,
assignmentEnergyMultiplier: 2,
energyReplenishThreshold: 10,
energyPerFood: 80,
energyReplenishThreshold: 0,
energyPerFood: 100,
productionComplete: 100,
defaultCapacity: 20,
......@@ -32,13 +37,13 @@ const knobsAndLevers = {
// defaultToolStores: 0,
// defaultFirewoodStores: 0,
// defaultFoodStores: 0,
// defaultClothingStores: 0,
// defaultFoodStores: 5,
defaultClothingStores: 0,
defaultToolStores: 25,
defaultFirewoodStores: 50,
defaultFoodStores: 50,
defaultClothingStores: 25,
// defaultClothingStores: 25,
defaultHideStores: 1,
......
......@@ -230,7 +230,7 @@ export class Village extends React.Component {
}
}
checkVillagerTool = (villager) => {
manageVillagerTool = (villager) => {
villager.hasTool = villager.toolDurability > 0 ? true : false;
// only equip tools to villagers that are assigned to a building
!villager.hasTool && villager.assignment !== "IDLE" ? this.getTool(villager) : null;
......@@ -253,7 +253,7 @@ export class Village extends React.Component {
this.getWarm(villager);
}
checkVillagerWarmth = (villager) => {
manageVillagerWarmth = (villager) => {
const baseWarmthDecayRate = KNOBS_AND_LEVERS.baseWarmthDecayRate;
const clothingWarmthDecayReduction = KNOBS_AND_LEVERS.clothingWarmthDecayReduction;
const villagerDeathValue = KNOBS_AND_LEVERS.villagerDeathValue;
......@@ -297,7 +297,7 @@ export class Village extends React.Component {
this.getFood(villager);
}
checkVillagerEnergy = (villager) => {
manageVillagerEnergy = (villager) => {
const baseEnergyDegradeRate = KNOBS_AND_LEVERS.baseEnergyDegradeRate;
const assignmentEnergyMultiplier = KNOBS_AND_LEVERS.assignmentEnergyMultiplier;
const villagerDeathValue = KNOBS_AND_LEVERS.villagerDeathValue;
......@@ -328,6 +328,26 @@ export class Village extends React.Component {
this.setVillagerStatus(villagerStatus);
}
manageVillagerRates = (villager) => {
const energyDecayRate = villager.assignment === 'IDLE'
? KNOBS_AND_LEVERS.baseEnergyDegradeRate
: KNOBS_AND_LEVERS.baseEnergyDegradeRate * KNOBS_AND_LEVERS.assignmentEnergyMultiplier
villager.foodPerTick = energyDecayRate / 100;
const warmthDecayRate = villager.clothed
? KNOBS_AND_LEVERS.baseWarmthDecayRate - KNOBS_AND_LEVERS.clothingWarmthDecayReduction
: KNOBS_AND_LEVERS.baseWarmthDecayRate;
villager.firewoodPerTick = warmthDecayRate / 100;
const toolDecayRate = villager.assignment === 'IDLE'
? 0
: KNOBS_AND_LEVERS.toolDegradeRate
villager.toolPerTick = toolDecayRate / 100;
const clothingDecayRate = KNOBS_AND_LEVERS.clothingDegradeRate
villager.clothingPerTick = clothingDecayRate / 100;
}
bringOutYourDead = (villager) => {
const timeToDieValue = KNOBS_AND_LEVERS.villagerDeathValue;
if (villager.assignment !== 'DEAD') {
......@@ -346,10 +366,11 @@ export class Village extends React.Component {
const villagers = this.state.villagers.slice();
villagers.map( villager => {
if (villager.assignment !== 'DEAD') {
this.checkVillagerTool(villager);
this.checkVillagerWarmth(villager);
this.manageVillagerRates(villager);
this.manageVillagerTool(villager);
this.manageVillagerWarmth(villager);
this.manageVillagerClothing(villager);
this.checkVillagerEnergy(villager);
this.manageVillagerEnergy(villager);
this.bringOutYourDead(villager);
};
});
......@@ -373,8 +394,8 @@ export class Village extends React.Component {
villagers.map(villager => {
!villager.hasTool && villager.assignment !== 'DEAD' ? (villagerStatus.toolless.count += 1, this.setBadThingClass('toolless')) : null;
!villager.clothed && villager.assignment !== 'DEAD' ? (villagerStatus.naked.count += 1, this.setBadThingClass('naked')) : null;
villager.energy <= warningValue && villager.assignment !== 'DEAD' ? (villagerStatus.starving.count += 1, this.setBadThingClass('starving')) : null;
villager.warmth <= warningValue && villager.assignment !== 'DEAD' ? (villagerStatus.freezing.count += 1, this.setBadThingClass('freezing')) : null;
villager.energy < warningValue && villager.assignment !== 'DEAD' ? (villagerStatus.starving.count += 1, this.setBadThingClass('starving')) : null;
villager.warmth < warningValue && villager.assignment !== 'DEAD' ? (villagerStatus.freezing.count += 1, this.setBadThingClass('freezing')) : null;
});
this.setVillagerStatus(villagerStatus);
}
......
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