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

Added target selectors to foodProduction() and foodConsumption()

parent 6289adab
No related branches found
No related tags found
1 merge request!10962Added food consumption to Farmyard food report
......@@ -109,8 +109,12 @@ App.Facilities.Farmyard.foodAmount = function(slave) {
}
};
/** The total amount of food produced in a given week. */
App.Facilities.Farmyard.foodProduction = function() {
/**
* The total amount of food produced in a given week.
*
* @param {'menials'|'slaves'|'both'} target Whose production to target.
*/
App.Facilities.Farmyard.foodProduction = function(target = 'both') {
function menialProduction() {
return V.farmMenials * App.Facilities.Farmyard.foodAmount();
}
......@@ -119,11 +123,18 @@ App.Facilities.Farmyard.foodProduction = function() {
return App.Entity.facilities.farmyard.employees().reduce((acc, cur) => acc + App.Facilities.Farmyard.foodAmount(cur), 0);
}
if (target === 'menials') { return menialProduction(); }
if (target === 'slaves') { return slaveProduction(); }
return menialProduction() + slaveProduction();
};
/** The total amount of food consumed in a given week. */
App.Facilities.Farmyard.foodConsumption = function() {
/**
* The total amount of food consumed in a given week.
*
* @param {'citizens'|'slaves'|'both'} target Whose consumption to target.
*/
App.Facilities.Farmyard.foodConsumption = function(target = 'both') {
function citizenConsumption() {
return (
(V.lowerClass * V.mods.food.rate.lower) +
......@@ -155,5 +166,8 @@ App.Facilities.Farmyard.foodConsumption = function() {
return total;
}
if (target === 'citizens') { return citizenConsumption; }
if (target === 'slaves') { return slaveConsumption(); }
return citizenConsumption() + slaveConsumption();
};
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