diff --git a/devTools/types/FC/facilities.d.ts b/devTools/types/FC/facilities.d.ts index 16db5832ff9cc11f6d01a087f40095e604f03a7b..dec9362873958ebf6a4eb24192dbe078275502aa 100644 --- a/devTools/types/FC/facilities.d.ts +++ b/devTools/types/FC/facilities.d.ts @@ -26,6 +26,8 @@ declare namespace FC { note?: string; /** Any additional nodes to attach. */ nodes?: Array<string|HTMLElement|DocumentFragment> + /** Any object the upgrade property is part of, if not the default `V`. */ + object?: Object; } interface Rule { diff --git a/src/004-base/facilityFramework.js b/src/004-base/facilityFramework.js index 6dddb065804a00042c0ccd83ae054946b6ce8dfe..2d17b422e11eb578fd2a5a6a4856fe9ec29cb468 100644 --- a/src/004-base/facilityFramework.js +++ b/src/004-base/facilityFramework.js @@ -33,6 +33,8 @@ App.Facilities.Facility = class { () => this._expand(expandArgs), () => this._makeUpgrades(), () => this._makeRules(), + () => this._makeCustomNodes(), + () => this._menials(), () => this._stats(), () => this._slaves(), () => this._rename(), @@ -179,13 +181,19 @@ App.Facilities.Facility = class { if (upgrade.prereqs.every(prereq => prereq())) { upgrade.cost = upgrade.cost || 0; - if (V[upgrade.property] === upgrade.value) { + if ((upgrade.object && upgrade.object[upgrade.property] === upgrade.value) + || V[upgrade.property] === upgrade.value) { App.UI.DOM.appendNewElement("div", div, upgrade.upgraded); } else { App.UI.DOM.appendNewElement("div", div, upgrade.base); App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(upgrade.link, () => { cashX(forceNeg(upgrade.cost), "capEx"); - V[upgrade.property] = upgrade.value; + + if (upgrade.object) { + upgrade.object[upgrade.property] = upgrade.value; + } else { + V[upgrade.property] = upgrade.value; + } if (upgrade.handler) { upgrade.handler(); @@ -243,9 +251,45 @@ App.Facilities.Facility = class { return div; } + /** + * Creates any custom nodes and adds them to the facility. + * + * Custom nodes are always placed between the rules section and the menial slaves section (or where they would be). + * + * @private + * @returns {HTMLDivElement} + */ + _makeCustomNodes() { + const div = document.createElement("div"); + + if (this.customNodes.length > 0) { + this.customNodes.forEach(node => div.append(node)); + } + + return div; + } + + /** + * Allows menial slaves to be bought, sold, and assigned to the facility. + * + * @private + * @returns {HTMLDivElement} + */ + _menials() { + const div = document.createElement("div"); + + if (this.menials) { + App.UI.DOM.appendNewElement("h2", div, `Menials`); + App.UI.DOM.appendNewElement("div", div, this.menials, ['margin-bottom']); + } + + return div; + } + /** * Displays a table with statistics relating to the facility. * + * @private * @returns {HTMLDivElement} */ _stats() { @@ -325,6 +369,15 @@ App.Facilities.Facility = class { return []; } + /** + * Any menials that are able to be assigned. + * + * @returns {HTMLDivElement} + */ + get menials() { + return null; + } + /** * Any statistics table to display. * @@ -333,4 +386,13 @@ App.Facilities.Facility = class { get stats() { return null; } + + /** + * Allows for the addition of any custom nodes to the facility. + * + * @returns {HTMLDivElement[]} + */ + get customNodes() { + return []; + } }; diff --git a/src/005-passages/facilitiesPassages.js b/src/005-passages/facilitiesPassages.js index 181f17f2f513474ca345dee1286086921c3f2f76..3522135fe60906b3a9302173b58d3df16688a809 100644 --- a/src/005-passages/facilitiesPassages.js +++ b/src/005-passages/facilitiesPassages.js @@ -3,7 +3,7 @@ new App.DomPassage("Arcade", () => { return new App.Facilities.Arcade.arcade().r new App.DomPassage("Clinic", () => { return new App.Facilities.Clinic.clinic().render(); }, ["jump-to-safe", "jump-from-safe"]); -new App.DomPassage("Farmyard", () => { return App.Facilities.Farmyard.farmyard(); }, ["jump-to-safe", "jump-from-safe"]); +new App.DomPassage("Farmyard", () => { return new App.Facilities.Farmyard.farmyard().render(); }, ["jump-to-safe", "jump-from-safe"]); new App.DomPassage("Incubator", () => { return App.UI.incubator(); }, ["jump-to-safe", "jump-from-safe"]); diff --git a/src/facilities/clinic/clinic.js b/src/facilities/clinic/clinic.js index e5083e9a85c760f74eeb2a88ed9b49764e0224ee..5e6dcb00e66653649417f157f043d0154b45bf04 100644 --- a/src/facilities/clinic/clinic.js +++ b/src/facilities/clinic/clinic.js @@ -11,12 +11,11 @@ App.Facilities.Clinic.clinic = class extends App.Facilities.Facility { V.clinicSpeedGestation = 0; }; const desc = `${clinic.nameCaps} has room to support ${V.clinic} slaves while they receive treatment. There ${clinic.hostedSlaves === 1 ? `is currently ${num(clinic.hostedSlaves)} slave` : `are currently ${num(clinic.hostedSlaves)} slaves`} receiving treatment in ${V.clinicName}.`; - const cost = V.clinic * 1000 * V.upgradeMultiplierArcology; super( clinic, decommissionHandler, - {desc, cost} + {desc} ); V.nextButton = "Back to Main"; diff --git a/src/facilities/farmyard/farmyard.js b/src/facilities/farmyard/farmyard.js index bb37e7d8ec4f0dd13e2d4e4b7e4fd63efd790c07..76b1fe374bac1b065fb1fa1f527be0593f7d149b 100644 --- a/src/facilities/farmyard/farmyard.js +++ b/src/facilities/farmyard/farmyard.js @@ -1,229 +1,286 @@ -App.Facilities.Farmyard.farmyard = function() { - const frag = new DocumentFragment(); - - const introDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const expandDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const menialsDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const rulesDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const upgradesDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const kennelsDiv = App.UI.DOM.makeElement("div"); - const stablesDiv = App.UI.DOM.makeElement("div"); - const cagesDiv = App.UI.DOM.makeElement("div"); - const removeHousingDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const renameDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - const slavesDiv = App.UI.DOM.makeElement("div", null, ['margin-bottom']); - - let farmyardNameCaps = capFirstChar(V.farmyardName); - - const count = App.Entity.facilities.farmyard.totalEmployeesCount; - - V.nextButton = "Back to Main"; - V.nextLink = "Main"; - V.returnTo = "Farmyard"; - V.encyclopedia = "Farmyard"; - - frag.append( - intro(), - expand(), - menials(), - rules(), - upgrades(), - kennels(), - stables(), - cages(), - removeHousing(), - rename(), - slaves(), - ); - - return frag; - - function intro() { - const text = []; +App.Facilities.Farmyard.farmyard = class extends App.Facilities.Facility { + constructor() { + const farmyard = App.Entity.facilities.farmyard; + const decommissionHandler = () => { + if (V.farmMenials) { + V.menials += V.farmMenials; + V.farmMenials = 0; + } - text.push(`${farmyardNameCaps} is an oasis of growth in the midst of the jungle of steel and concrete that is ${V.arcologies[0].name}. Animals are kept in pens, tended to by your slaves, while ${V.farmyardUpgrades.hydroponics - ? `rows of hydroponics equipment` - : `makeshift fields`} grow crops. `); - - switch (V.farmyardDecoration) { - case "Roman Revivalist": - text.push(`Its red tiles and white stone walls are the very picture of a Roman farm villa's construction, as are the marble statues and reliefs. Saturn and Ceres look over the prosperity of the fields${V.seeBestiality ? `. Mercury watches over the health of the animals, and Feronia ensures strong litters in your slaves.` : `, and Mercury watches over the health of the animals.`} The slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`); - break; - case "Neo-Imperialist": - text.push(`Its high-tech, sleek black design invocates an embracement of the future, tempered by the hanging banners displaying your family crest as the rightful lord and master of these farms. Serf-like peasants work tirelessly in the fields, both to grow crops and oversee the slaves beneath them. Despite the harsh nature of the fieldwork, the slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`); - break; - case "Aztec Revivalist": - text.push(`It can't completely recreate the floating farms in the ancient Aztec fashion, but it comes as close as it can, shallow pseudo-canals dividing each field into multiple sections. Smooth stone and colorful murals cover the walls, depicting bloody stories of gods and mortals alike.`); - break; - case "Egyptian Revivalist": - text.push(`It does its best to capture the wide open nature of ancient Egyptian farms, including mimicking the irrigation systems fed by the Nile. The stone walls are decorated with murals detailing its construction and your prowess in general, ${V.seeBestiality ? `with animal-bloated slaves featured prominently.` : `hieroglyphs spelling out volumes of praise.`}`); - break; - case "Edo Revivalist": - text.push(`It does its best to mimic the rice patties and thatch roofed buildings of the Edo period despite the wide variety of crops tended by various slaves. Not every crop can thrive in flooded fields, but the ones that can take advantage of your attention to detail.`); - break; - case "Arabian Revivalist": - text.push(`Large plots of olive trees and date palms line the outer edges of the main crop area, while a combination of wheat, flax, and barley occupies the interior space. Irrigation canals snake through the area, ensuring every inch of cropland is well-watered.`); - break; - case "Chinese Revivalist": - text.push(`It does its best to capture the terraces that covered the ancient Chinese hills and mountains, turning every floor into ribbons of fields following a slight incline. Slaves wade through crops that can handle flooding and splash through the irrigation of the others when they aren't tending to${V.seeBestiality ? ` or breeding with` : ``} your animals.`); - break; - case "Chattel Religionist": - text.push(`It runs like a well oiled machine, slaves bent in humble service as they tend crops grown on the Prophet's command, or see to the animals' needs. Their clothing is tucked up and out of the way as they see to their tasks, keeping them clean as they work ${V.seeBestiality ? `around animal-bloated bellies ` : ``}as divine will dictates.`); - break; - case "Degradationist": - text.push(`It is constructed less as a converted warehouse and more as something to visit, allowing guests to enjoy the spectacle of slaves ${V.seeBestiality ? `being pounded by eager animals` : `elbow deep in scrubbing animal waste`} to their satisfaction.`); - break; - case "Repopulationist": - text.push(`It teems with life, both in the belly of every animal and the belly of every slave, though the latter makes tending the fields difficult. They're ordered to take care, as they carry the future ${V.seeBestiality ? `of this farm` : `of the arcology`} in their bellies.`); - break; - case "Eugenics": - text.push(`It holds a wide variety of crops and animals, but the best of the best is easy to find. They're set apart from the others, given only the best care and supplies${V.seeBestiality ? ` and bred with only the highest quality slaves` : ``}, while the sub-par stock is neglected off to the side.`); - break; - case "Asset Expansionist": - text.push(`It is not easy to look after animals and till fields with such enormous body parts, but your slaves are diligent regardless, working hard to provide food and livestock for the arcology.`); - break; - case "Transformation Fetishist": - // text.push(`TODO:`); - break; - case "Gender Radicalist": - // text.push(`TODO:`); - break; - case "Gender Fundamentalist": - // text.push(`TODO:`); - break; - case "Physical Idealist": - text.push(`Its animals are in exceptional shape, their coats unable to hide how muscular they are, requiring your slaves to be equally toned to control them. There's plenty of space for their exercise as well${V.seeBestiality ? ` and an abundance of curatives for the slaves full of their fierce, kicking offspring` : ``}.`); - break; - case "Supremacist": - text.push(`It is a clean and orderly operation, stables and cages mucked by a multitude of inferior slaves, along with grooming your animals and harvesting your crops.`); - break; - case "Subjugationist": - text.push(`It is a clean and orderly operation, stables and cages mucked by a multitude of ${V.arcologies[0].FSSubjugationistRace} slaves, while the others are tasked with grooming your animals and harvesting your crops.`); - break; - case "Paternalist": - text.push(`It's full of healthy animals, crops, and slaves, the former's every need diligently looked after by the latter. The fields flourish to capacity under such care, and the animals give the distinct impression of happiness${V.seeBestiality ? ` — some more than others if the growing bellies of your slaves are anything to go by, the only indication that such rutting takes place` : ``}.`); - break; - case "Pastoralist": - // text.push(`TODO:`); - break; - case "Maturity Preferentialist": - // text.push(`TODO:`); - break; - case "Youth Preferentialist": - // text.push(`TODO:`); - break; - case "Body Purist": - // text.push(`TODO:`); - break; - case "Slimness Enthusiast": - text.push(`It features trim animals and slaves alike, not a pound of excess among them. The feed for both livestock and crops are carefully maintained to ensure optimal growth without waste, letting them flourish without being weighed down.`); - break; - case "Hedonistic": - text.push(`It features wider gates and stalls, for both the humans visiting or tending the occupants, and the animals starting to mimic their handlers${V.seeBestiality ? ` and company` : ``}, with plenty of seats along the way.`); - break; - case "Slave Professionalism": - // text.push(`TODO:`); - break; - case "Intellectual Dependency": - // text.push(`TODO:`); - break; - default: - text.push(`It is very much a converted warehouse still, sectioned off in various 'departments'${V.farmyardUpgrades.machinery ? ` with machinery placed where it can be` : V.farmyardUpgrades.hydroponics ? ` and plumbing for the hydroponics system running every which way` : ``}.`); - break; - } + V.farmyardName = "the Farmyard"; + V.farmyard = 0; + V.farmyardDecoration = "standard"; - if (count > 2) { - text.push(`${farmyardNameCaps} is bustling with activity. Farmhands are hurrying about, on their way to feed animals and maintain farming equipment.`); - } else if (count) { - text.push(`${farmyardNameCaps} is working steadily. Farmhands are moving about, looking after the animals and crops.`); - } else if (S.Farmer) { - text.push(`${S.Farmer.slaveName} is alone in ${V.farmyardName}, and has nothing to do but look after the animals and crops.`); - } else { - text.push(`${farmyardNameCaps} is empty and quiet.`); - } + V.farmMenials = 0; + V.farmMenialsSpace = 0; - App.UI.DOM.appendNewElement("div", introDiv, text.join(' '), ['scene-intro']); + V.farmyardShows = 0; + V.farmyardBreeding = 0; + V.farmyardCrops = 0; - if (count === 0) { - App.UI.DOM.appendNewElement("div", introDiv, App.UI.DOM.passageLink(`Decommission ${V.farmyardName}`, "Main", () => { - if (V.farmMenials) { - V.menials += V.farmMenials; - V.farmMenials = 0; - } + V.farmyardKennels = 0; + V.farmyardStables = 0; + V.farmyardCages = 0; - V.farmyardName = "the Farmyard"; - V.farmyard = 0; - V.farmyardDecoration = "standard"; + if (V.pit) { + V.pit.animal = null; + } - V.farmMenials = 0; - V.farmMenialsSpace = 0; + V.farmyardUpgrades = { + pump: 0, + fertilizer: 0, + hydroponics: 0, + machinery: 0, + seeds: 0 + }; - V.farmyardShows = 0; - V.farmyardBreeding = 0; - V.farmyardCrops = 0; - - V.farmyardKennels = 0; - V.farmyardStables = 0; - V.farmyardCages = 0; + V.canine = []; + V.hooved = []; + V.feline = []; - if (V.pit) { - V.pit.animal = null; - } - - V.farmyardUpgrades = { - pump: 0, - fertilizer: 0, - hydroponics: 0, - machinery: 0, - seeds: 0 - }; - - clearAnimalsPurchased(); - App.Arcology.cellUpgrade(V.building, App.Arcology.Cell.Manufacturing, "Farmyard", "Manufacturing"); - }), ['indent']); - } + V.active.canine = null; + V.active.hooved = null; + V.active.feline = null; - return introDiv; + App.Arcology.cellUpgrade(V.building, App.Arcology.Cell.Manufacturing, "Farmyard", "Manufacturing"); + }; + const desc = `It can support ${num(V.farmyard)} farmhands. There ${farmyard.hostedSlaves === 1 ? `is currently ${farmyard.hostedSlaves} farmhand` : `are currently ${farmyard.hostedSlaves} farmhands`} in ${V.farmyardName}.`; + + super( + farmyard, + decommissionHandler, + {desc} + ); + + V.nextButton = "Back to Main"; + V.nextLink = "Main"; + V.returnTo = "Farmyard"; + V.encyclopedia = "Farmyard"; } - function expand() { - const cost = Math.trunc(V.farmyard * 1000 * V.upgradeMultiplierArcology); + /** @returns {string} */ + get intro() { + const text = []; - expandDiv.append(`It can support ${num(V.farmyard)} farmhands. There ${count === 1 ? `is currently ${count} farmhand` : `are currently ${count} farmhands`} in ${V.farmyardName}.`); + text.push( + `${this.facility.nameCaps} is an oasis of growth in the midst of the jungle of steel and concrete that is ${V.arcologies[0].name}. Animals are kept in pens, tended to by your slaves, while ${V.farmyardUpgrades.hydroponics + ? `rows of hydroponics equipment` + : `makeshift fields`} grow crops.`, + this.decorations, + ); + + if (this.facility.hostedSlaves > 2) { + text.push(`${this.facility.nameCaps} is bustling with activity. Farmhands are hurrying about, on their way to feed animals and maintain farming equipment.`); + } else if (this.facility.hostedSlaves) { + text.push(`${this.facility.nameCaps} is working steadily. Farmhands are moving about, looking after the animals and crops.`); + } else if (S.Farmer) { + text.push(`${S.Farmer.slaveName} is alone in ${V.farmyardName}, and has nothing to do but look after the animals and crops.`); + } else { + text.push(`${this.facility.nameCaps} is empty and quiet.`); + } - App.UI.DOM.appendNewElement("div", expandDiv, App.UI.DOM.link(`Expand ${V.farmyardName}`, () => { - cashX(forceNeg(cost), "capEx"); - V.farmyard += 5; - V.PC.skill.engineering += .1; + return text.join(' '); + } - App.UI.DOM.replace(expandDiv, expand); - }, - [], '', `Costs ${cashFormat(cost)} and increases the capacity of ${V.farmyardName} by 5.`), ['indent']); + /** @returns {string} */ + get decorations() { + /** @type {FC.Facilities.Decoration} */ + const FS = { + "Roman Revivalist": `Its red tiles and white stone walls are the very picture of a Roman farm villa's construction, as are the marble statues and reliefs. Saturn and Ceres look over the prosperity of the fields${V.seeBestiality ? `. Mercury watches over the health of the animals, and Feronia ensures strong litters in your slaves.` : `, and Mercury watches over the health of the animals.`} The slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`, + "Neo-Imperialist": `Its high-tech, sleek black design invocates an embracement of the future, tempered by the hanging banners displaying your family crest as the rightful lord and master of these farms. Serf-like peasants work tirelessly in the fields, both to grow crops and oversee the slaves beneath them. Despite the harsh nature of the fieldwork, the slaves here are all looked after well, as they have one of the most important jobs in ${V.arcologies[0].name}.`, + "Aztec Revivalist": `It can't completely recreate the floating farms in the ancient Aztec fashion, but it comes as close as it can, shallow pseudo-canals dividing each field into multiple sections. Smooth stone and colorful murals cover the walls, depicting bloody stories of gods and mortals alike.`, + "Egyptian Revivalist": `It does its best to capture the wide open nature of ancient Egyptian farms, including mimicking the irrigation systems fed by the Nile. The stone walls are decorated with murals detailing its construction and your prowess in general, ${V.seeBestiality ? `with animal-bloated slaves featured prominently.` : `hieroglyphs spelling out volumes of praise.`}`, + "Edo Revivalist": `It does its best to mimic the rice patties and thatch roofed buildings of the Edo period despite the wide variety of crops tended by various slaves. Not every crop can thrive in flooded fields, but the ones that can take advantage of your attention to detail.`, + "Arabian Revivalist": `Large plots of olive trees and date palms line the outer edges of the main crop area, while a combination of wheat, flax, and barley occupies the interior space. Irrigation canals snake through the area, ensuring every inch of cropland is well-watered.`, + "Chinese Revivalist": `It does its best to capture the terraces that covered the ancient Chinese hills and mountains, turning every floor into ribbons of fields following a slight incline. Slaves wade through crops that can handle flooding and splash through the irrigation of the others when they aren't tending to${V.seeBestiality ? ` or breeding with` : ``} your animals.`, + "Chattel Religionist": `It runs like a well oiled machine, slaves bent in humble service as they tend crops grown on the Prophet's command, or see to the animals' needs. Their clothing is tucked up and out of the way as they see to their tasks, keeping them clean as they work ${V.seeBestiality ? `around animal-bloated bellies ` : ``}as divine will dictates.`, + "Degradationist": `It is constructed less as a converted warehouse and more as something to visit, allowing guests to enjoy the spectacle of slaves ${V.seeBestiality ? `being pounded by eager animals` : `elbow deep in scrubbing animal waste`} to their satisfaction.`, + "Repopulationist": `It teems with life, both in the belly of every animal and the belly of every slave, though the latter makes tending the fields difficult. They're ordered to take care, as they carry the future ${V.seeBestiality ? `of this farm` : `of the arcology`} in their bellies.`, + "Eugenics": `It holds a wide variety of crops and animals, but the best of the best is easy to find. They're set apart from the others, given only the best care and supplies${V.seeBestiality ? ` and bred with only the highest quality slaves` : ``}, while the sub-par stock is neglected off to the side.`, + "Asset Expansionist": `It is not easy to look after animals and till fields with such enormous body parts, but your slaves are diligent regardless, working hard to provide food and livestock for the arcology.`, + "Transformation Fetishist": `The plants and animals here all look slightly unnatural, as though they were engineered in a lab to be stronger or larger – which, of course, they were.`, + "Gender Radicalist": `The plants and animals here all look slightly unnatural, as though they were treated with hormones to be stronger or larger – which, of course, they were.`, + "Gender Fundamentalist": `The majority of the population of ${V.farmyardName} is pregnant, and the space is outfitted with childbearing in mind.`, + "Physical Idealist": `Its animals are in exceptional shape, their coats unable to hide how muscular they are, requiring your slaves to be equally toned to control them. There's plenty of space for their exercise as well${V.seeBestiality ? ` and an abundance of curatives for the slaves full of their fierce, kicking offspring` : ``}.`, + "Supremacist": `It is a clean and orderly operation, stables and cages mucked by a multitude of inferior slaves, along with grooming your animals and harvesting your crops.`, + "Subjugationist": `It is a clean and orderly operation, stables and cages mucked by a multitude of ${V.arcologies[0].FSSubjugationistRace} slaves, while the others are tasked with grooming your animals and harvesting your crops.`, + "Paternalist": `It's full of healthy animals, crops, and slaves, the former's every need diligently looked after by the latter. The fields flourish to capacity under such care, and the animals give the distinct impression of happiness${V.seeBestiality ? ` — some more than others if the growing bellies of your slaves are anything to go by, the only indication that such rutting takes place` : ``}.`, + "Pastoralist": `The space is outfitted with milkers every so often so that lactating farmhands don't have to travel far to relieve themselves of their milk, and the animals are milked of what they can be as well.`, + "Maturity Preferentialist": `The majority of the population here is older and wiser, and the older animals are all treated with a bit more luxury than the younger ones.`, + "Youth Preferentialist": `The majority of the population here is full of youth and more energetic, and the younger animals are all treated with a bit more luxury than the older ones.`, + "Body Purist": `Organic crops and animals are the main feature here, and the animal manure is used as a natural fertilizer for the different plants.`, + "Slimness Enthusiast": `It features trim animals and slaves alike, not a pound of excess among them. The feed for both livestock and crops are carefully maintained to ensure optimal growth without waste, letting them flourish without being weighed down.`, + "Hedonistic": `It features wider gates and stalls, for both the humans visiting or tending the occupants, and the animals starting to mimic their handlers${V.seeBestiality ? ` and company` : ``}, with plenty of seats along the way.`, + "Intellectual Dependency": ``, // TODO: + "Slave Professionalism": ``, // TODO: + "Petite Admiration": ``, // TODO: + "Statuesque Glorification": ``, // TODO: + "standard": `It is very much a converted warehouse still, sectioned off in various 'departments'${V.farmyardUpgrades.machinery ? ` with machinery placed where it can be` : V.farmyardUpgrades.hydroponics ? ` and plumbing for the hydroponics system running every which way` : ``}.`, + "": ``, + }; - if (count > 0) { - App.UI.DOM.appendNewElement("div", expandDiv, removeFacilityWorkers("farmyard"), 'indent'); + if (!Object.keys(FS).includes(V.farmyardDecoration)) { + throw new Error(`Unknown V.farmyardDecoration value of '${V.farmyardDecoration}' found in decorations().`); } - return expandDiv; + return FS[V.farmyardDecoration]; } - function menials() { - menialsDiv.append(transferMenials(), buyMenials(), houseMenials()); + /** @returns {FC.Facilities.Upgrade[]} */ + get upgrades() { + return [ + { + property: "pump", + prereqs: [], + value: 1, + base: `${this.facility.nameCaps} is currently using the basic water pump that it came with.`, + upgraded: `The water pump in ${V.farmyardName} is a more efficient model, slightly improving the amount of crops it produces.`, + link: `Upgrade the water pump`, + cost: Math.trunc(5000 * V.upgradeMultiplierArcology), + handler: () => V.PC.skill.engineering += 0.1, + note: ` and slightly decreases upkeep costs`, + object: V.farmyardUpgrades, + }, + { + property: "fertilizer", + prereqs: [ + () => V.farmyardUpgrades.pump > 0, + ], + value: 1, + upgraded: `${this.facility.nameCaps} is using a higher-quality fertilizer, moderately increasing the amount of crops it produces and slightly raising upkeep costs.`, + link: `Use a higher-quality fertilizer`, + cost: Math.trunc(10000 * V.upgradeMultiplierArcology), + handler: () => V.PC.skill.engineering += 0.1, + note: `, moderately increases crop yield, and slightly increases upkeep costs`, + object: V.farmyardUpgrades, + }, + { + property: "hydroponics", + prereqs: [ + () => V.farmyardUpgrades.fertilizer > 0, + ], + value: 1, + upgraded: `${this.facility.nameCaps} is outfitted with an advanced hydroponics system, reducing the amount of water your crops consume and thus moderately reducing upkeep costs.`, + link: `Purchase an advanced hydroponics system`, + cost: Math.trunc(20000 * V.upgradeMultiplierArcology), + handler: () => V.PC.skill.engineering += 0.1, + note: ` and moderately decreases upkeep costs`, + object: V.farmyardUpgrades, + }, + { + property: "seeds", + prereqs: [ + () => V.farmyardUpgrades.hydroponics > 0, + ], + value: 1, + upgraded: `${this.facility.nameCaps} is using genetically modified seeds, significantly increasing the amount of crops it produces and moderately increasing upkeep costs.`, + link: `Purchase genetically modified seeds`, + cost: Math.trunc(25000 * V.upgradeMultiplierArcology), + handler: () => V.PC.skill.engineering += 0.1, + note: `, moderately increases crop yield, and slightly increases upkeep costs`, + object: V.farmyardUpgrades, + }, + { + property: "machinery", + prereqs: [ + () => V.farmyardUpgrades.seeds + > 0, + ], + value: 1, + upgraded: `The machinery in ${V.farmyardName} has been upgraded and is more efficient, significantly increasing crop yields and significantly decreasing upkeep costs.`, + link: `Upgrade the machinery`, + cost: Math.trunc(50000 * V.upgradeMultiplierArcology), + handler: () => V.PC.skill.engineering += 0.1, + note: `, moderately increases crop yield, and slightly increases upkeep costs`, + object: V.farmyardUpgrades, + }, + ]; + } - return menialsDiv; + /** @returns {FC.Facilities.Rule[]} */ + get rules() { + return [ + { + property: "farmyardShows", + prereqs: [ + () => this.facility.hostedSlaves > 0, + () => V.farmyardKennels > 0 || V.farmyardStables > 0 || V.farmyardCages > 0, + ], + options: [ + { + get text() { return `Slaves in ${V.farmyardName} are putting on shows with animals.`; }, + link: `Begin shows`, + value: 1, + }, + { + get text() { return `Slaves in ${V.farmyardName} are not putting on shows with animals.`; }, + link: `End shows`, + value: 0, + }, + ], + }, + { + property: "farmyardBreeding", + prereqs: [ + () => !!V.seeBestiality, + () => !!V.farmyardShows, + () => !!V.canine || !!V.hooved || !!V.feline, + ], + options: [ + { + get text() { return `Slaves in ${V.farmyardName} are being bred with animals.`; }, + link: `Begin breeding`, + value: 1, + }, + { + get text() { return `Slaves in ${V.farmyardName} are not being bred with animals.`; }, + link: `End breeding`, + value: 0, + }, + ], + }, + { + property: "farmyardRestraints", + prereqs: [ + () => !!V.farmyardBreeding, + ], + options: [ + { + get text() { return `All of the slaves are being restrained.`; }, + link: `Restrain all slaves`, + value: 1, + }, + { + get text() { return `Only disobedient slaves are being restrained.`; }, + link: `Restrain only disobedient slaves`, + value: 0, + }, + ], + }, + ]; } - function transferMenials() { - const frag = new DocumentFragment(); + /** @returns {HTMLDivElement} */ + get menials() { + const div = document.createElement("div"); - const links = []; + const popCap = menialPopCap(); + const bulkMax = popCap.value - V.menials - V.fuckdolls - V.menialBioreactors; + + const menialPrice = Math.trunc(menialSlaveCost()); + const maxMenials = Math.trunc(Math.clamp(V.cash / menialPrice, 0, bulkMax)); + const unitCost = Math.trunc(1000 * V.upgradeMultiplierArcology); + + let links = []; + + // Transferring if (V.farmMenials) { - frag.append(`Assigned to ${V.farmyardName} ${V.farmMenials === 1 ? `is` : `are`} ${V.farmMenials} menial ${V.farmMenials === 1 ? `slave` : `slaves`}, working to produce as much food for your arcology as they can. `); + div.append(`Assigned to ${V.farmyardName} ${V.farmMenials === 1 ? `is` : `are`} ${V.farmMenials} menial ${V.farmMenials === 1 ? `slave` : `slaves`}, working to produce as much food for your arcology as they can. `); } if (V.farmMenialsSpace) { - frag.append(`You ${V.menials ? `own ${num(V.menials)}` : `don't own any`} free menial slaves. ${farmyardNameCaps} can house ${V.farmMenialsSpace} menial slaves total, with ${V.farmMenialsSpace - V.farmMenials} free spots. `); + div.append(`You ${V.menials ? `own ${num(V.menials)}` : `don't own any`} free menial slaves. ${capFirstChar(V.farmyardName)} can house ${V.farmMenialsSpace} menial slaves total, with ${V.farmMenialsSpace - V.farmMenials} free spots. `); } if (V.farmMenialsSpace && V.farmMenials < V.farmMenialsSpace) { @@ -232,7 +289,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menials--; V.farmMenials++; - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } @@ -241,7 +298,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menials -= 10; V.farmMenials += 10; - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } @@ -250,7 +307,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menials -= 100; V.farmMenials += 100; - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } @@ -264,13 +321,13 @@ App.Facilities.Farmyard.farmyard = function() { V.menials = 0; } - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } } else if (!V.farmMenialsSpace) { - frag.append(`${farmyardNameCaps} cannot currently house any menial slaves. `); + div.append(`${capFirstChar(V.farmyardName)} cannot currently house any menial slaves. `); } else { - frag.append(`${farmyardNameCaps} has all the menial slaves it can currently house assigned to it. `); + div.append(`${capFirstChar(V.farmyardName)} has all the menial slaves it can currently house assigned to it. `); } if (V.farmMenials) { @@ -278,25 +335,15 @@ App.Facilities.Farmyard.farmyard = function() { V.menials += V.farmMenials; V.farmMenials = 0; - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } - App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.generateLinksStrip(links), ['indent']); - - return frag; - } - - function buyMenials() { - const frag = new DocumentFragment(); - - const links = []; + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.generateLinksStrip(links), ['indent']); - const popCap = menialPopCap(); - const bulkMax = popCap.value - V.menials - V.fuckdolls - V.menialBioreactors; + // Trading - const menialPrice = Math.trunc(menialSlaveCost()); - const maxMenials = Math.trunc(Math.clamp(V.cash / menialPrice, 0, bulkMax)); + links = []; if (V.farmMenialsSpace) { if (bulkMax > 0 || V.menials + V.fuckdolls + V.menialBioreactors === 0) { @@ -305,7 +352,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menialSupplyFactor--; cashX(forceNeg(menialPrice), "farmyard"); - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); links.push(App.UI.DOM.link(`Buy ${num(10)}`, () => { @@ -313,7 +360,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menialSupplyFactor -= 10; cashX(forceNeg(menialPrice * 10), "farmyard"); - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); links.push(App.UI.DOM.link(`Buy ${num(100)}`, () => { @@ -321,7 +368,7 @@ App.Facilities.Farmyard.farmyard = function() { V.menialSupplyFactor -= 100; cashX(forceNeg(menialPrice * 100), "farmyard"); - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); links.push(App.UI.DOM.link(`Buy maximum`, () => { @@ -329,154 +376,38 @@ App.Facilities.Farmyard.farmyard = function() { V.menialSupplyFactor -= maxMenials; cashX(forceNeg(maxMenials * menialPrice), "farmyard"); - App.UI.DOM.replace(menialsDiv, menials); + this.refresh(); })); } } if (V.farmMenials) { - App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.generateLinksStrip(links), ['indent']); + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.generateLinksStrip(links), ['indent']); } - return frag; - } - - function houseMenials() { - const frag = new DocumentFragment(); + // Housing - const unitCost = Math.trunc(1000 * V.upgradeMultiplierArcology); + links = []; if (V.farmMenialsSpace < 500) { - App.UI.DOM.appendNewElement("div", frag, `There is enough room in ${V.farmyardName} to build housing, enough to give ${V.farmMenialsSpace + 100} menial slaves a place to sleep and relax.`); + App.UI.DOM.appendNewElement("div", div, `There is enough room in ${V.farmyardName} to build housing, enough to give ${V.farmMenialsSpace + 100} menial slaves a place to sleep and relax.`); - App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.link(`Build a new housing unit`, () => { + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(`Build a new housing unit`, () => { cashX(forceNeg(unitCost), "farmyard"); V.farmMenialsSpace += 100; + + this.refresh(); }, [], '', `Costs ${cashFormat(unitCost)} and increases housing by 100.`), ['indent']); } - return frag; + return div; } - function rules() { - if (App.Entity.facilities.farmyard.employeesIDs().size > 0 && (V.farmyardKennels || V.farmyardStables || V.farmyardCages)) { // TODO: redo this with V.farmyardShowgirls - const options = new App.UI.OptionsGroup(); - - options.addOption(`Slaves ${V.farmyardShows ? `are` : `are not`} putting on shows.`, "farmyardShows") - .addValue(`Begin shows`, 1) - .addValue(`End shows`, 0); - - if (V.farmyardShows && (V.canine || V.hooved || V.feline)) { - if (V.seeBestiality) { - options.addOption(`Slaves ${V.farmyardBreeding ? `are` : `are not`} being bred with animals.`, "farmyardBreeding") - .addValue(`Begin breeding`, 1) - .addValue(`End breeding`, 0); + /** @returns {HTMLDivElement} */ + get kennels() { + const div = document.createElement("div"); - if (V.farmyardBreeding) { - options.addOption(`${V.farmyardRestraints ? `All of the slaves` : `Only disobedient slaves`} are being restrained.`, "farmyardRestraints") - .addValue(`Restrain all slaves`, 1) - .addValue(`Restrain only disobedient slaves`, 0); - } - } - } - - rulesDiv.append(options.render()); - } - - return rulesDiv; - } - - function upgrades() { - const farmyardUpgrades = V.farmyardUpgrades; - - const pumpCost = Math.trunc(5000 * V.upgradeMultiplierArcology); - const fertilizerCost = Math.trunc(10000 * V.upgradeMultiplierArcology); - const hydroponicsCost = Math.trunc(20000 * V.upgradeMultiplierArcology); - const seedsCost = Math.trunc(25000 * V.upgradeMultiplierArcology); - const machineryCost = Math.trunc(50000 * V.upgradeMultiplierArcology); - - if (!farmyardUpgrades.pump) { - App.UI.DOM.appendNewElement("div", upgradesDiv, `${farmyardNameCaps} is currently using the basic water pump that it came with.`); - - upgradesDiv.append(createUpgrade( - `Upgrade the water pump`, - pumpCost, - `slightly decreases upkeep costs`, - "pump" - )); - } else { - App.UI.DOM.appendNewElement("div", upgradesDiv, `The water pump in ${V.farmyardName} is a more efficient model, slightly improving the amount of crops it produces.`); - - if (!farmyardUpgrades.fertilizer) { - upgradesDiv.append(createUpgrade( - `Use a higher-quality fertilizer`, - fertilizerCost, - `moderately increases crop yield and slightly increases upkeep costs`, - "fertilizer" - )); - } else { - App.UI.DOM.appendNewElement("div", upgradesDiv, `${farmyardNameCaps} is using a higher-quality fertilizer, moderately increasing the amount of crops it produces and slightly raising upkeep costs.`); - - if (!farmyardUpgrades.hydroponics) { - upgradesDiv.append(createUpgrade( - `Purchase an advanced hydroponics system`, - hydroponicsCost, - `moderately decreases upkeep costs`, - "hydroponics" - )); - } else { - App.UI.DOM.appendNewElement("div", upgradesDiv, `${farmyardNameCaps} is outfitted with an advanced hydroponics system, reducing the amount of water your crops consume and thus moderately reducing upkeep costs.`); - - if (!farmyardUpgrades.seeds) { - upgradesDiv.append(createUpgrade( - `Purchase genetically modified seeds`, - seedsCost, - `moderately increases crop yield and slightly increases upkeep costs`, - "seeds" - )); - } else { - App.UI.DOM.appendNewElement("div", upgradesDiv, `${farmyardNameCaps} is using genetically modified seeds, significantly increasing the amount of crops it produces and moderately increasing upkeep costs.`); - - if (!farmyardUpgrades.machinery) { - upgradesDiv.append(createUpgrade( - `Upgrade the machinery`, - machineryCost, - `moderately increases crop yield and slightly increases upkeep costs`, - "machinery" - )); - } else { - App.UI.DOM.appendNewElement("div", upgradesDiv, `The machinery in ${V.farmyardName} has been upgraded and is more efficient, significantly increasing crop yields and significantly decreasing upkeep costs.`); - } - } - } - } - } - - /** - * @param {string} linkText The text to display. - * @param {number} price The price of the upgrade. - * @param {string} effect The change the upgrade causes. - * @param {"pump"|"fertilizer"|"hydroponics"|"machinery"|"seeds"} type The variable name of the upgrade. - */ - function createUpgrade(linkText, price, effect, type) { - const frag = new DocumentFragment(); - - App.UI.DOM.appendNewElement("div", frag, App.UI.DOM.link(linkText, () => { - cashX(forceNeg(price), "farmyard"); - farmyardUpgrades[type] = 1; - - App.UI.DOM.replace(upgradesDiv, upgrades); - }, - [], '', `Costs ${cashFormat(price)} and ${effect}.`), ['indent']); - - return frag; - } - - return upgradesDiv; - } - - function kennels() { const cost = Math.trunc(5000 * V.upgradeMultiplierArcology); const CL = V.canine.length; @@ -497,37 +428,41 @@ App.Facilities.Farmyard.farmyard = function() { : `all kinds of canines`; if (V.farmyardKennels === 0) { - App.UI.DOM.appendNewElement("div", kennelsDiv, App.UI.DOM.link(`Add kennels`, () => { + div.append(`There is enough room in ${V.farmyardName} to build kennels to house canines.`); + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link(`Add kennels`, () => { cashX(forceNeg(cost), "farmyard"); V.farmyardKennels = 1; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic canines.`), ['indent']); } else if (V.farmyardKennels === 1) { - kennelsDiv.append(App.UI.DOM.passageLink("Kennels", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${dogs}`}.`); + div.append(App.UI.DOM.passageLink("Kennels", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${dogs}`}.`); if (V.rep > 10000) { - App.UI.DOM.appendNewElement("div", kennelsDiv, App.UI.DOM.link("Upgrade kennels", () => { + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Upgrade kennels", () => { cashX(forceNeg(cost * 2), "farmyard"); V.farmyardKennels = 2; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost * 2)} will incur additional upkeep costs, and unlocks exotic canines.`), ['indent']); } else { - App.UI.DOM.appendNewElement("div", stablesDiv, App.UI.DOM.disabledLink("Upgrade kennels", + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade kennels", [`You must be more reputable to be able to house exotic canines.`]), ['indent']); } } else if (V.farmyardKennels === 2) { - kennelsDiv.append(App.UI.DOM.passageLink("Large kennels", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${canines}`}.`); + div.append(App.UI.DOM.passageLink("Large kennels", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${CL < 1 ? `empty` : `occupied by ${canines}`}.`); } - return kennelsDiv; + return div; } - function stables() { + /** @returns {HTMLDivElement} */ + get stables() { + const div = document.createElement("div"); + const cost = Math.trunc(5000 * V.upgradeMultiplierArcology); const HL = V.hooved.length; @@ -538,37 +473,41 @@ App.Facilities.Farmyard.farmyard = function() { : `all kinds of hooved animals`; if (V.farmyardStables === 0) { - App.UI.DOM.appendNewElement("div", stablesDiv, App.UI.DOM.link("Add stables", () => { + div.append(`There is enough room in ${V.farmyardName} to build a stables to house hooved animals.`); + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Add stables", () => { cashX(forceNeg(cost), "farmyard"); V.farmyardStables = 1; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic hooved animals.`), ['indent']); } else if (V.farmyardStables === 1) { - stablesDiv.append(App.UI.DOM.passageLink("Stables", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`); + div.append(App.UI.DOM.passageLink("Stables", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`); if (V.rep > 10000) { - App.UI.DOM.appendNewElement("div", stablesDiv, App.UI.DOM.link("Upgrade stables", () => { + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Upgrade stables", () => { cashX(forceNeg(cost * 2), "farmyard"); V.farmyardStables = 2; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost * 2)}, will incur additional upkeep costs, and unlocks exotic hooved animals.`), ['indent']); } else { - App.UI.DOM.appendNewElement("div", stablesDiv, App.UI.DOM.disabledLink("Upgrade stables", + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade stables", [`You must be more reputable to be able to house exotic hooved animals.`]), ['indent']); } } else if (V.farmyardStables === 2) { - stablesDiv.append(App.UI.DOM.passageLink("Large stables", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`); + div.append(App.UI.DOM.passageLink("Large stables", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${HL < 1 ? `empty` : `occupied by ${hooved}`}.`); } - return stablesDiv; + return div; } - function cages() { + /** @returns {HTMLDivElement} */ + get cages() { + const div = document.createElement("div"); + const cost = Math.trunc(5000 * V.upgradeMultiplierArcology); const FL = V.feline.length; @@ -589,41 +528,45 @@ App.Facilities.Farmyard.farmyard = function() { : `all kinds of felines`; if (V.farmyardCages === 0) { - App.UI.DOM.appendNewElement("div", cagesDiv, App.UI.DOM.link("Add cages", () => { + div.append(`There is enough room in ${V.farmyardName} to build cages to house felines.`); + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Add cages", () => { cashX(forceNeg(cost), "farmyard"); V.farmyardCages = 1; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost)}, will incur upkeep costs, and unlocks domestic felines.`), ['indent']); } else if (V.farmyardCages === 1) { - cagesDiv.append(App.UI.DOM.passageLink("Cages", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${cats}`}.`); + div.append(App.UI.DOM.passageLink("Cages", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${cats}`}.`); if (V.rep > 10000) { - App.UI.DOM.appendNewElement("div", cagesDiv, App.UI.DOM.link("Upgrade cages", () => { + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Upgrade cages", () => { cashX(forceNeg(cost * 2), "farmyard"); V.farmyardCages = 2; V.PC.skill.engineering += .1; - refresh(); + this.refresh(); }, [], '', `Costs ${cashFormat(cost * 2)}, will increase upkeep costs, and unlocks exotic felines.`), ['indent']); } else { - App.UI.DOM.appendNewElement("div", cagesDiv, App.UI.DOM.disabledLink("Upgrade cages", + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.disabledLink("Upgrade cages", [`You must be more reputable to be able to house exotic felines.`]), ['indent']); } } else if (V.farmyardCages === 2) { - cagesDiv.append(App.UI.DOM.passageLink("Large cages", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${felines}`}.`); + div.append(App.UI.DOM.passageLink("Large cages", "Farmyard Animals"), ` have been built in one corner of ${V.farmyardName}, and are currently ${FL < 1 ? `empty` : `occupied by ${felines}`}.`); } - return cagesDiv; + return div; } - function removeHousing() { + /** @returns {HTMLDivElement} */ + get removeAnimalHousing() { + const div = document.createElement("div"); + const cost = ((V.farmyardKennels + V.farmyardStables + V.farmyardCages) * 5000) * V.upgradeMultiplierArcology; if (V.farmyardKennels || V.farmyardStables || V.farmyardCages) { - App.UI.DOM.appendNewElement("div", removeHousingDiv, App.UI.DOM.link("Remove the animal housing", () => { + App.UI.DOM.appendNewElement("div", div, App.UI.DOM.link("Remove the animal housing", () => { V.farmyardKennels = 0; V.farmyardStables = 0; V.farmyardCages = 0; @@ -632,55 +575,37 @@ App.Facilities.Farmyard.farmyard = function() { V.farmyardBreeding = 0; V.farmyardRestraints = 0; - clearAnimalsPurchased(); cashX(forceNeg(cost), "farmyard"); - refresh(); + this.refresh(); }, [], '', `Will cost ${cashFormat(cost)}.`), ['indent']); } - return removeHousingDiv; + return div; } - function clearAnimalsPurchased() { - V.canine = []; - V.hooved = []; - V.feline = []; + /** @returns {HTMLDivElement} */ + get animals() { + const div = document.createElement("div"); - V.active.canine = null; - V.active.hooved = null; - V.active.feline = null; - } - - function rename() { - renameDiv.append(frag.appendChild(App.Facilities.rename(App.Entity.facilities.farmyard, () => { - farmyardNameCaps = capFirstChar(V.farmyardName); - - refresh(); - }))); - - return renameDiv; - } + App.UI.DOM.appendNewElement("h2", div, `Animals`); - function slaves() { - slavesDiv.append(App.UI.DOM.appendNewElement("div", frag, App.UI.SlaveList.stdFacilityPage(App.Entity.facilities.farmyard), 'margin-bottom')); + div.append( + this.kennels, + this.stables, + this.cages, + ); - return slavesDiv; + return div; } - function refresh() { - App.UI.DOM.replace(introDiv, intro); - App.UI.DOM.replace(expandDiv, expand); - App.UI.DOM.replace(menialsDiv, menials); - App.UI.DOM.replace(rulesDiv, rules); - App.UI.DOM.replace(upgradesDiv, upgrades); - App.UI.DOM.replace(kennelsDiv, kennels); - App.UI.DOM.replace(stablesDiv, stables); - App.UI.DOM.replace(cagesDiv, cages); - App.UI.DOM.replace(removeHousingDiv, removeHousing); - App.UI.DOM.replace(renameDiv, rename); - App.UI.DOM.replace(slavesDiv, slaves); + /** @returns {HTMLDivElement[]} */ + get customNodes() { + return [ + this.animals, + this.removeAnimalHousing, + ]; } };