diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index b03535331a87ea9c3931646492ddd0e5e292d127..a24d8d9f218369d11b6b0b1cd26ebddd070307d5 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -691,9 +691,9 @@ App.Data.resetOnNGPlus = { /** @type {App.Entity.Animal} */ feline: null, }, - canines: [], + canine: [], hooved: [], - felines: [], + feline: [], farmyardName: "the Farmyard", HGSuite: 0, diff --git a/src/arcologyBuilding/manufacturing.js b/src/arcologyBuilding/manufacturing.js index 3e285e2392be96fb36e0c610c3a635ad645db876..74c53ea210b7212ddf19dc4b51263fc8f2149f71 100644 --- a/src/arcologyBuilding/manufacturing.js +++ b/src/arcologyBuilding/manufacturing.js @@ -203,6 +203,7 @@ App.Arcology.Cell.Manufacturing = class extends App.Arcology.Cell.BaseCell { () => { V.farmyard = 5; thisCell.type = "Farmyard"; + App.Facilities.Farmyard.animals.init(); }, cost, "and will incur upkeep costs" )); } diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js index d1ae4db683e72406cd566f00ea223be589407238..7700aa314ba758ca110785d04a4aa6bc3ea577cc 100644 --- a/src/data/backwardsCompatibility/backwardsCompatibility.js +++ b/src/data/backwardsCompatibility/backwardsCompatibility.js @@ -296,6 +296,20 @@ App.Update.globalVariables = function(node) { delete V.animalsBought; } + if (!App.Data.animals || App.Data.animals.length === 0) { + App.Facilities.Farmyard.animals.init(); + } + + if (V.canines) { + V.canine = Array.from(V.canines); + delete V.canines; + } + + if (V.felines) { + V.feline = Array.from(V.felines); + delete V.felines; + } + // Pit if (typeof V.pit === "number") { V.pit = V.pit ? {} : null; diff --git a/src/facilities/farmyard/animals/animals.js b/src/facilities/farmyard/animals/animals.js index aadc29501966bd1348f1ad8fc5ead9f769878e70..52d6beaff5132e19e0ec92a3880590e6b0ceef30 100644 --- a/src/facilities/farmyard/animals/animals.js +++ b/src/facilities/farmyard/animals/animals.js @@ -14,12 +14,23 @@ App.Entity.Animal = class { this.rarity = rarity; } + /** @returns {boolean} */ get purchased() { - return V[this.type].includes(this); + return V[this.type].includes(this.name); } + /** @returns {boolean} */ + get isActive() { + return V.active[this.type].replace(/s$/, '').name === this.name; + } + + /** @type {function():void} */ purchase() { - V[this.type].push(this); + V[this.type].push(this.name); + } + + setActive() { + V.active[this.type].replace(/s$/, '') } } @@ -91,7 +102,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", canineDiv, 'Dogs', "farmyard-animal-type"); - canineDiv.append(hr, animalList("canines", domestic, 5000, canine)); + canineDiv.append(hr, animalList("canine", domestic, 5000, canine)); return canineDiv; } @@ -117,7 +128,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", felineDiv, 'Cats', "farmyard-animal-type"); - felineDiv.append(hr, animalList("felines", domestic, 1000, feline)); + felineDiv.append(hr, animalList("feline", domestic, 1000, feline)); return felineDiv; } @@ -134,7 +145,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", canineDiv, 'Canines', "farmyard-animal-type"); - canineDiv.append(hr, animalList("canines", exotic, 50000, canine)); + canineDiv.append(hr, animalList("canine", exotic, 50000, canine)); return canineDiv; } @@ -160,7 +171,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", felineDiv, 'Felines', "farmyard-animal-type"); - felineDiv.append(hr, animalList("felines", exotic, 100000, feline)); + felineDiv.append(hr, animalList("feline", exotic, 100000, feline)); return felineDiv; } @@ -196,7 +207,7 @@ App.Facilities.Farmyard.animals = function() { /** * Creates a list of the specified animal type from the main animal array. - * @param {string} type One of "canines", "hooved", or "felines", also used determine the active animal type. + * @param {string} type One of "canine", "hooved", or "feline", also used determine the active animal type. * @param {string} rarity One of domestic or exotic. * @param {number} price * @param {string} active The name of the current active animal of the given type. @@ -206,6 +217,8 @@ App.Facilities.Farmyard.animals = function() { const mainDiv = document.createElement("div"); let filteredArray = App.Data.animals.filter(animal => animal.rarity === rarity && animal.type === type); + console.log(filteredArray); + for (const i in filteredArray) { const animalDiv = document.createElement("div"); const optionSpan = document.createElement("span"); @@ -233,7 +246,7 @@ App.Facilities.Farmyard.animals = function() { mainDiv.appendChild(animalDiv); } - filteredArray = []; + // filteredArray = []; return mainDiv; } @@ -244,9 +257,9 @@ App.Facilities.Farmyard.animals.init = function() { const dog = 'dog'; const cat = 'cat'; - const canine = 'canines'; + const canine = 'canine'; const hooved = 'hooved' - const feline = 'felines'; + const feline = 'feline'; const domestic = 'domestic'; const exotic = 'exotic'; diff --git a/src/facilities/farmyard/farmyard.js b/src/facilities/farmyard/farmyard.js index 91b39ba751f6d316f9165b656545d242b910ac1f..67cb088e0026e5b45ea5c1c92c018f555161bec1 100644 --- a/src/facilities/farmyard/farmyard.js +++ b/src/facilities/farmyard/farmyard.js @@ -364,7 +364,7 @@ App.Facilities.Farmyard.farmyard = function() { const frag = new DocumentFragment(); if (App.Entity.facilities.farmyard.employeesIDs().size > 0) { // TODO: redo this with V.farmyardShowgirls - if (V.farmyardShows && (V.canines || V.hooved || V.felines)) { + if (V.farmyardShows && (V.canine || V.hooved || V.feline)) { const rule = makeRule( ['Slaves', 'are putting on shows with animals'], 'are', @@ -607,31 +607,28 @@ App.Facilities.Farmyard.farmyard = function() { // MARK: Kennels - const - CL = V.canines.length, - - dogs = CL === 1 ? V.canines[0] : CL < 3 ? - `several different breeds of dogs` : - `all kinds of dogs`, - canines = CL === 1 ? V.canines[0].species === "dog" ? - V.canines[0].breed : V.canines[0].speciesPlural : CL < 3 ? - `several different ${V.canines.every( - c => c.species === "dog") ? - `breeds of dogs` : `species of canines`}` : - `all kinds of canines`, - - kennels = document.createElement("div"), - kennelsUpgrade = App.UI.DOM.makeElement("div", '', "indent"), - kennelsNote = App.UI.DOM.makeElement("span", '', "note"), - kennelsCost = App.UI.DOM.makeElement("span", '', "yellowgreen"); + const CL = V.canine.length; + + const dogs = CL === 1 ? `${V.canine[0].name}s` : CL < 3 ? + `several different breeds of dogs` : + `all kinds of dogs`; + const canines = CL === 1 ? V.canine[0].species === "dog" ? + V.canine[0].breed : V.canine[0].speciesPlural : CL < 3 ? + `several different ${V.canine.every( + c => c.species === "dog") ? + `breeds of dogs` : `species of canines`}` : + `all kinds of canines`; + + const kennels = document.createElement("div"); + const kennelsUpgrade = App.UI.DOM.makeElement("div", '', "indent"); + const kennelsNote = App.UI.DOM.makeElement("span", '', "note"); + const kennelsCost = App.UI.DOM.makeElement("span", '', "yellowgreen"); if (farmyardKennels === 0) { kennels.append(App.UI.DOM.passageLink("Add kennels", "Farmyard", () => { cashX(forceNeg(baseCost), "farmyard"); V.farmyardKennels = 1; - - App.Facilities.Farmyard.animals.init(); })); kennelsCost.append(cashFormat(baseCost)); @@ -647,8 +644,6 @@ App.Facilities.Farmyard.farmyard = function() { () => { cashX(forceNeg(upgradedCost), "farmyard"); V.farmyardKennels = 2; - - App.Facilities.Farmyard.animals.init(); })); kennelsCost.append(cashFormat(upgradedCost)); @@ -683,8 +678,6 @@ App.Facilities.Farmyard.farmyard = function() { () => { cashX(forceNeg(baseCost), "farmyard"); V.farmyardStables = 1; - - App.Facilities.Farmyard.animals.init(); })); stablesCost.append(cashFormat(baseCost)); @@ -700,8 +693,6 @@ App.Facilities.Farmyard.farmyard = function() { () => { cashX(forceNeg(upgradedCost), "farmyard"); V.farmyardStables = 2; - - App.Facilities.Farmyard.animals.init(); })); stablesCost.append(cashFormat(upgradedCost)); @@ -719,31 +710,28 @@ App.Facilities.Farmyard.farmyard = function() { // MARK: Cages - const - FL = V.felines.length, + const FL = V.feline.length; - cats = FL === 1 ? V.felines[0] : FL < 3 ? + const cats = FL === 1 ? V.feline[0] : FL < 3 ? `several different breeds of cats` : - `all kinds of cats`, - felines = FL === 1 ? V.felines[0].species === "cat" ? - V.felines[0].breed : V.felines[0].speciesPlural : FL < 3 ? - `several different ${V.felines.every( + `all kinds of cats`; + const felines = FL === 1 ? V.feline[0].species === "cat" ? + V.feline[0].breed : V.feline[0].speciesPlural : FL < 3 ? + `several different ${V.feline.every( c => c.species === "cat") ? `breeds of cats` : `species of felines`}` : - `all kinds of felines`, + `all kinds of felines`; - cages = document.createElement("div"), - cagesUpgrade = App.UI.DOM.makeElement("div", '', "indent"), - cagesNote = App.UI.DOM.makeElement("span", '', "note"), - cagesCost = App.UI.DOM.makeElement("span", '', "yellowgreen"); + const cages = document.createElement("div"); + const cagesUpgrade = App.UI.DOM.makeElement("div", '', "indent"); + const cagesNote = App.UI.DOM.makeElement("span", '', "note"); + const cagesCost = App.UI.DOM.makeElement("span", '', "yellowgreen"); if (farmyardCages === 0) { cages.append(App.UI.DOM.passageLink("Add cages", "Farmyard", () => { cashX(forceNeg(baseCost), "farmyard"); V.farmyardCages = 1; - - App.Facilities.Farmyard.animals.init(); })); cagesCost.append(cashFormat(baseCost)); @@ -759,8 +747,6 @@ App.Facilities.Farmyard.farmyard = function() { () => { cashX(forceNeg(upgradedCost), "farmyard"); V.farmyardCages = 2; - - App.Facilities.Farmyard.animals.init(); })); cagesCost.append(cashFormat(upgradedCost)); @@ -798,9 +784,9 @@ App.Facilities.Farmyard.farmyard = function() { V.farmyardBreeding = 0; V.farmyardRestraints = 0; - V.canines = []; + V.canine = []; V.hooved = []; - V.felines = []; + V.feline = []; App.Data.animals = []; @@ -839,9 +825,9 @@ App.Facilities.Farmyard.farmyard = function() { } function clearAnimalsPurchased() { - V.canines = []; + V.canine = []; V.hooved = []; - V.felines = []; + V.feline = []; V.active.canine = null; V.active.hooved = null; diff --git a/src/facilities/farmyard/reports/farmyardReport.js b/src/facilities/farmyard/reports/farmyardReport.js index 66becce59d7533bb51426c3c169840454ec22fb9..0829134a76c7b922db2a933351a5ac165636d4ca 100644 --- a/src/facilities/farmyard/reports/farmyardReport.js +++ b/src/facilities/farmyard/reports/farmyardReport.js @@ -482,7 +482,7 @@ App.Facilities.Farmyard.farmyardReport = function farmyardReport() { r.push(`${farmyardNameCaps}'s customer's enjoyed`); - if (V.seeBestiality && V.policies.bestialityOpenness && (V.canines || V.hooved || V.felines)) { + if (V.seeBestiality && V.policies.bestialityOpenness && (V.canine || V.hooved || V.feline)) { r.push(`<span class="green">watching farmhands fuck animals in ${V.farmyardDecoration} surroundings.</span>`); } else if (V.farmyardShows) { r.push(`<span class="green">watching farmhands put on shows in ${V.farmyardDecoration} surroundings.</span>`); diff --git a/src/js/birth/birth.js b/src/js/birth/birth.js index 5352d71408195bfce3e0eef68bbe63567dae93b4..36ed3807be138d9abda03417ec27bc59df43a107 100644 --- a/src/js/birth/birth.js +++ b/src/js/birth/birth.js @@ -4869,8 +4869,6 @@ globalThis.birth = function(slave, {birthStorm = false, cSection = false} = {}) const el = document.createElement("p"); let He2, he2, his2; const r = []; - let animals = []; - let roll; const HGL = App.Entity.facilities.headGirlSuite.hostedSlaves; const babies = slave.pregType > 1 ? `babies` : `baby`; const children = slave.pregType > 1 ? `children` : `child`; @@ -5063,24 +5061,26 @@ globalThis.birth = function(slave, {birthStorm = false, cSection = false} = {}) break; case Job.FARMYARD: - animals = []; - roll; - if (V.canines.length > 0) { - roll = random(0, V.canines.length); - animals.push(V.canines[roll]); + /** @type {App.Entity.Animal[]} */ + const animals = []; + let roll; + + if (V.canine.length > 0) { + roll = jsRandom(0, V.canine.length); + animals.push(V.canine[roll]); } if (V.hooved.length > 0) { - roll = random(0, V.hooved.length); + roll = jsRandom(0, V.hooved.length); animals.push(V.hooved[roll]); } - if (V.canines.length > 0) { - roll = random(0, V.canines.length); - animals.push(V.canines[roll]); + if (V.canine.length > 0) { + roll = jsRandom(0, V.canine.length); + animals.push(V.canine[roll]); } if (slave.fetish === "mindbroken") { if (V.farmyardShows && V.seeBestiality) { - roll = random(0, animals.length); - r.push(`${He} shows no interest in ${his} coming birth as ${he} continues being rutted by a ${animals[roll].species}, so`); + roll = jsRandom(0, animals.length); + r.push(`${He} shows no interest in ${his} coming birth as ${he} continues being rutted by a ${animals[roll].name}, so`); if (S.Farmer) { r.push(S.Farmer.slaveName); } else { @@ -5094,7 +5094,7 @@ globalThis.birth = function(slave, {birthStorm = false, cSection = false} = {}) } r.push(`to come out, or when ${he} is subsequently hosed off before being led back to ${V.farmyardName}.`); } else { - r.push(`${He} shows no interest in ${his} coming birth as ${he} continues either("loading hay bales", "milking a cow", "pulling weeds"), until ${his} contractions become so strong that ${he} collapses to ${his} knees.`); + r.push(`${He} shows no interest in ${his} coming birth as ${he} continues ${jsEither(["loading hay bales", "milking a cow", "pulling weeds"])}, until ${his} contractions become so strong that ${he} collapses to ${his} knees.`); if (S.Farmer) { r.push(S.Farmer.slaveName); } else { @@ -5104,7 +5104,7 @@ globalThis.birth = function(slave, {birthStorm = false, cSection = false} = {}) } } else { if (V.farmyardShows && V.seeBestiality) { - roll = random(0, animals.length); + roll = jsRandom(0, animals.length); if (S.Farmer) { r.push(S.Farmer.slaveName); } else { @@ -5118,7 +5118,7 @@ globalThis.birth = function(slave, {birthStorm = false, cSection = false} = {}) } else { r.push(`${He} returns to ${his} bed and strips before slipping into it.`); } - r.push(`${He} makes ${himself} comfortable and begins working on birthing ${his} ${babies}. ${His} ${childrenAre} promptly taken and ${he} rests awhile before returning to ${V.farmyardName} to continue ${either("loading hay bales", "milking cows", "pulling weeds")}.`); + r.push(`${He} makes ${himself} comfortable and begins working on birthing ${his} ${babies}. ${His} ${childrenAre} promptly taken and ${he} rests awhile before returning to ${V.farmyardName} to continue ${jsEither(["loading hay bales", "milking cows", "pulling weeds"])}.`); } } break; diff --git a/src/js/vignettes.js b/src/js/vignettes.js index b706a14be5bb563d826b4aad30d189d5b0d539c4..15e8a0d553794f362a2a88b9c5dc5fa449841a8e 100644 --- a/src/js/vignettes.js +++ b/src/js/vignettes.js @@ -4645,7 +4645,7 @@ globalThis.GetVignette = function(slave) { effect: -1 }); - if ((V.canines.length > 0) && hasAnyNaturalLegs(slave)) { + if ((V.canine.length > 0) && hasAnyNaturalLegs(slave)) { r.push({ text: `an over-excited dog left scratch marks on ${his} leg,`, type: "health", @@ -4661,7 +4661,7 @@ globalThis.GetVignette = function(slave) { }); } - if (V.felines.length > 0) { + if (V.feline.length > 0) { r.push({ text: `${he} managed to take two tigers at once, aweing the crowd,`, type: "cash", diff --git a/src/npc/interaction/passage/fAnimalImpreg.tw b/src/npc/interaction/passage/fAnimalImpreg.tw index a1eb7a8b4b6a52586be7357b851673425ce00892..3132a6973e53927841363eee766c7516434fb0af 100644 --- a/src/npc/interaction/passage/fAnimalImpreg.tw +++ b/src/npc/interaction/passage/fAnimalImpreg.tw @@ -2,7 +2,7 @@ <<set $nextButton = "Back", $nextLink = "Slave Interact", $impregnatrix = 0, $eligibility = 0>> -<<set _CL = $canines.length, _HL = $hooved.length, _FL = $felines.length>> +<<set _CL = $canine.length, _HL = $hooved.length, _FL = $feline.length>> <br><br> @@ -13,13 +13,13 @@ __Select an eligible animal to knock $him up:__ /* FIXME: this might not work */ <<for _c = 0; _c < _CL; _c++>> - <<if canBreed(getSlave($AS), $canines[_c])>> - <<if $canines[_c].species != "dog">> - <<set _canine = $canines[_c].species>> + <<if canBreed(getSlave($AS), $canine[_c])>> + <<if $canine[_c].species != "dog">> + <<set _canine = $canine[_c].species>> <<else>> - <<set _canine = $canines[_c].breed>> + <<set _canine = $canine[_c].breed>> <</if>> - <br><<link "Have a _canine knock $him up" "FAnimalImpreg Consummate">><<set $impregnatrix = $canines[_c]>><</link>> + <br><<link "Have a _canine knock $him up" "FAnimalImpreg Consummate">><<set $impregnatrix = $canine[_c]>><</link>> <<set $eligibility = 1>> <</if>> <</for>> @@ -31,13 +31,13 @@ __Select an eligible animal to knock $him up:__ <</if>> <</for>> <<for _f = 0; _f < _fL; _f++>> - <<if canBreed(getSlave($AS), $felines[_f])>> - <<if $felines[_f].species != "cat">> - <<set _feline = $felines[_f].species>> + <<if canBreed(getSlave($AS), $feline[_f])>> + <<if $feline[_f].species != "cat">> + <<set _feline = $feline[_f].species>> <<else>> - <<set _feline = $felines[_f].breed>> + <<set _feline = $feline[_f].breed>> <</if>> - <br><<link "Have a _feline knock $him up" "FAnimalImpreg Consummate">><<set $impregnatrix = $felines[_f]>><</link>> + <br><<link "Have a _feline knock $him up" "FAnimalImpreg Consummate">><<set $impregnatrix = $feline[_f]>><</link>> <<set $eligibility = 1>> <</if>> <</for>>