Skip to content
Snippets Groups Projects
Commit b34891fa authored by DCoded's avatar DCoded
Browse files

Added food consumption to Farmyard food report

parent c83c8413
No related branches found
No related tags found
1 merge request!10962Added food consumption to Farmyard food report
App.UI.foodReport = function() { App.UI.foodReport = function() {
const text = []; const text = [];
const farmhands = App.Entity.facilities.farmyard.hostedSlaves;
const slaveAmount = App.Entity.facilities.farmyard.employees().reduce((acc, cur) => acc + App.Facilities.Farmyard.foodAmount(cur), 0);
const menialAmount = V.farmMenials * App.Facilities.Farmyard.foodAmount();
const total = slaveAmount + menialAmount;
text.push(`${V.arcologies[0].name} produced ${massFormat(total)} of food this week.`); text.push(
production(),
consumption(),
);
if (slaveAmount > 0) { return text.join(' ');
text.push(`${V.farmMenials ? capFirstChar(massFormat(slaveAmount)) : `All of it`} was produced by your ${num(farmhands)} farmhands`);
} function production() {
if (menialAmount > 0) { const text = [];
text.push(`${slaveAmount > 0 ? text.pop() + `, and ${massFormat(total - slaveAmount)}` : `All of it`} was produced by ${num(V.farmMenials)} menial slaves`); const production = App.Facilities.Farmyard.foodProduction();
const farmhands = App.Entity.facilities.farmyard.hostedSlaves;
const slaveAmount = App.Entity.facilities.farmyard.employees()
.reduce((acc, cur) => acc + App.Facilities.Farmyard.foodAmount(cur), 0);
const menialAmount = V.farmMenials * App.Facilities.Farmyard.foodAmount();
text.push(`${V.arcologies[0].name} produced ${massFormat(production)} of food this week.`);
if (slaveAmount > 0) {
text.push(`${V.farmMenials ? capFirstChar(massFormat(slaveAmount)) : `All of it`} was produced by your ${num(farmhands)} farmhands`);
}
if (menialAmount > 0) {
text.push(`${slaveAmount > 0 ? text.pop() + `, and ${massFormat(production - slaveAmount)}` : `All of it`} was produced by ${num(V.farmMenials)} menial slaves`);
}
text.push(text.pop() + `.`);
return text.join(' ');
} }
text.push(text.pop() + `.`); function consumption() {
const text = [];
const production = App.Facilities.Farmyard.foodProduction();
const consumption = App.Facilities.Farmyard.foodConsumption();
const deficit = Math.abs(consumption - production);
const cost = deficit * V.mods.food.cost;
const storage = V.mods.food.amount;
return text.join(' '); if (production > consumption) {
text.push(`${capFirstChar(massFormat(consumption))} of it was consumed, with a spare ${massFormat(production - consumption)} moved into long-term storage.`);
} else {
if (storage > deficit) {
text.push(`Unfortunately, this wasn't enough to cover needs of your hungry arcology, and ${massFormat(deficit)} had to be brought up from storage.`);
} else if (V.cash > cost) {
text.push(`Unfortunately, this wasn't enough to cover needs of your hungry arcology, and because you didn't have enough food in storage, you has to purchase and additional ${massFormat(deficit - storage)} for ${cashFormat()}.`);
}
}
return text.join(' ');
}
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment