diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 92d5ab672603fd111d6a221872b99c38d7bcc9ef..b03535331a87ea9c3931646492ddd0e5e292d127 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -684,8 +684,11 @@ App.Data.resetOnNGPlus = { farmyardKennels: 0, farmyardCages: 0, active: { + /** @type {App.Entity.Animal} */ canine: null, + /** @type {App.Entity.Animal} */ hooved: null, + /** @type {App.Entity.Animal} */ feline: null, }, canines: [], diff --git a/src/facilities/farmyard/animals/animals.js b/src/facilities/farmyard/animals/animals.js index 369fb83aa71cb90a9a2d5f809b7b93f4caca04ff..a97954cfa37f092c9e4f87d98c422e9baa0f8a7c 100644 --- a/src/facilities/farmyard/animals/animals.js +++ b/src/facilities/farmyard/animals/animals.js @@ -1,3 +1,4 @@ + /** The base animal class. */ App.Entity.Animal = class { /** @@ -23,6 +24,8 @@ App.Entity.Animal = class { } App.Facilities.Farmyard.animals = function() { + App.Facilities.Farmyard.animals.init(); + const frag = new DocumentFragment(); const domesticDiv = App.UI.DOM.appendNewElement("div", frag, '', "farmyard-domestic"); @@ -82,7 +85,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", canineDiv, 'Dogs', "farmyard-animal-type"); - canineDiv.append(hr, animalList("canine", "domestic", 5000, "canine")); + canineDiv.append(hr, animalList("canines", "domestic", 5000, "canine")); return canineDiv; } @@ -108,7 +111,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", felineDiv, 'Cats', "farmyard-animal-type"); - felineDiv.append(hr, animalList("feline", "domestic", 1000, "activeFeline")); + felineDiv.append(hr, animalList("felines", "domestic", 1000, "activeFeline")); return felineDiv; } @@ -125,7 +128,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", canineDiv, 'Canines', "farmyard-animal-type"); - canineDiv.append(hr, animalList("canine", "exotic", 50000, "canine")); + canineDiv.append(hr, animalList("canines", "exotic", 50000, "canine")); return canineDiv; } @@ -151,7 +154,7 @@ App.Facilities.Farmyard.animals = function() { App.UI.DOM.appendNewElement("span", felineDiv, 'Felines', "farmyard-animal-type"); - felineDiv.append(hr, animalList("feline", "exotic", 100000, "activeFeline")); + felineDiv.append(hr, animalList("felines", "exotic", 100000, "activeFeline")); return felineDiv; } @@ -164,7 +167,7 @@ App.Facilities.Farmyard.animals = function() { * Creates either a link or note text depending on parameters given * @callback SetActiveHandler * @callback PurchaseHandler - * @param {string} animal + * @param {App.Entity.Animal} animal * @param {string} active * @param {string} type * @param {number} price @@ -174,28 +177,28 @@ App.Facilities.Farmyard.animals = function() { */ function animalLink(animal, active, type, price, setActiveHandler, purchaseHandler) { if (animal.purchased) { - if (_.isEqual(V.active[active], animal)) { + if (V.active[active].name === animal.name) { return App.UI.DOM.makeElement("span", `Set as active ${type}`, "note"); } else { - return App.UI.DOM.passageLink(`Set as active ${type}`, "Farmyard Animals", setActiveHandler); + return App.UI.DOM.link(`Set as active ${type}`, setActiveHandler); } } else { - return App.UI.DOM.passageLink(`Purchase for ${cashFormat(price)}`, "Farmyard Animals", purchaseHandler); + return App.UI.DOM.link(`Purchase for ${cashFormat(price)}`, purchaseHandler); } } /** - * Creates a list of the specified animal type from the main animal array - * @param {string} type One of "canine", "hooved", or "feline", also used determine the active animal type - * @param {string} rarity One of "domestic" or "exotic" + * 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} rarity One of "domestic" or "exotic". * @param {number} price - * @param {string} active The name of the current active animal of the given type + * @param {string} active The name of the current active animal of the given type. * @returns {HTMLDivElement} */ function animalList(type, rarity, price, active) { const mainDiv = document.createElement("div"), - filteredArray = App.Data.animals + filteredArray = App.Data.animals.filter(animal => animal.rarity === rarity && animal.type === type); for (const i in filteredArray) { const diff --git a/src/facilities/pit/pit.js b/src/facilities/pit/pit.js index ba17574612cf23d030a4fbab01e097f80f3449f0..8d9f2cd48b85d77b81bc5f3fc844575e271204d5 100644 --- a/src/facilities/pit/pit.js +++ b/src/facilities/pit/pit.js @@ -143,18 +143,18 @@ App.Facilities.Pit.pit = function() { App.UI.DOM.replace(mainDiv, fighters); })); - // if (V.active.canine || V.active.hooved || V.active.feline) { - // links.push(App.UI.DOM.link("Have a slave fight an animal", () => { - // V.pit.bodyguardFights = false; - // V.pit.animal = null; - - // if (V.pit.fighterIDs.includes(V.BodyguardID)) { - // V.pit.fighterIDs.delete(V.BodyguardID); - // } - - // App.UI.DOM.replace(mainDiv, fighters); - // })); - // } + if (V.active.canine || V.active.hooved || V.active.feline) { + links.push(App.UI.DOM.link("Have a slave fight an animal", () => { + V.pit.bodyguardFights = false; + V.pit.animal = null; + + if (V.pit.fighterIDs.includes(V.BodyguardID)) { + V.pit.fighterIDs.splice(V.pit.fighterIDs.indexOf(V.BodyguardID), 0); + } + + App.UI.DOM.replace(mainDiv, fighters); + })); + } } else { if (V.pit.animal) { mainDiv.append(`A random slave will fight an animal.`); @@ -190,7 +190,7 @@ App.Facilities.Pit.pit = function() { links.push( App.UI.DOM.link("Have a slave fight an animal", () => { V.pit.bodyguardFights = false; - V.pit.animal = new App.Entity.Animal(); + V.pit.animal = V.active.canine; App.UI.DOM.replace(mainDiv, fighters); }) diff --git a/src/npc/interaction/fAnimal.js b/src/npc/interaction/fAnimal.js index b7950e2af041ab4531112d74f56705b9ebb4efd9..4efc367e5c5480903ccfd1072d2f2936a074b1b0 100644 --- a/src/npc/interaction/fAnimal.js +++ b/src/npc/interaction/fAnimal.js @@ -697,7 +697,7 @@ App.Interact.fAnimal = function(slave, type) { function sexEffects() { const mainSpan = App.UI.DOM.makeElement("span", '', ["flaw", "gain"]); - if (random(1, 100) > 100 + slave.devotion) { + if (jsRandom(1, 100) > 100 + slave.devotion) { switch (act) { case oral: if (slave.energy < 95 && slave.sexualFlaw !== "hates oral") {