diff --git a/src/facilities/farmyard/animals/animals.js b/src/facilities/farmyard/animals/animals.js index 3317ed910867e035cc1a945e578a084d8089b710..4b9449d1c48e55eea902f6d1ea12b1d76ebbfce7 100644 --- a/src/facilities/farmyard/animals/animals.js +++ b/src/facilities/farmyard/animals/animals.js @@ -122,8 +122,19 @@ App.Facilities.Farmyard.animals = function() { hr.style.margin = hrMargin; App.UI.DOM.appendNewElement("span", div, 'Dogs', ['bold']); + div.append(hr, animalList('canine', 'domestic', 5000, 'canine', 'dog')); - div.append(hr, animalList('canine', 'domestic', 5000, 'canine')); + if ([...App.Data.animals].some(animal => + animal.type === 'canine' && + animal.rarity === 'domestic' && + animal.species !== 'dog')) { + const hr = document.createElement("hr"); + + hr.style.margin = hrMargin; + + App.UI.DOM.appendNewElement("span", div, 'Other Canines', ['bold']); + div.append(hr, animalList('canine', 'domestic', 5000, 'canine', null, 'dog')); + } return div; } @@ -139,7 +150,6 @@ App.Facilities.Farmyard.animals = function() { hr.style.margin = hrMargin; App.UI.DOM.appendNewElement("span", div, 'Hooved Animals', ['bold']); - div.append(hr, animalList('hooved', 'domestic', 20000, 'hooved')); return div; @@ -156,8 +166,19 @@ App.Facilities.Farmyard.animals = function() { hr.style.margin = hrMargin; App.UI.DOM.appendNewElement("span", div, 'Cats', ['bold']); + div.append(hr, animalList('feline', 'domestic', 1000, 'feline', 'cat')); - div.append(hr, animalList('feline', 'domestic', 1000, 'feline')); + if ([...App.Data.animals].some(animal => + animal.type === 'feline' && + animal.rarity === 'domestic' && + animal.species !== 'cat')) { + const hr = document.createElement("hr"); + + hr.style.margin = hrMargin; + + App.UI.DOM.appendNewElement("span", div, 'Other Felines', ['bold']); + div.append(hr, animalList('feline', 'domestic', 5000, 'feline', null, 'cat')); + } return div; } @@ -270,13 +291,19 @@ App.Facilities.Farmyard.animals = function() { * @param {'domestic'|'exotic'} 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} [species] Any specific species to filter by, + * @param {string} [exclude] Any species to exclude. * @returns {DocumentFragment} */ - function animalList(type, rarity, price, active) { + function animalList(type, rarity, price, active, species, exclude) { const frag = new DocumentFragment(); [...App.Data.animals] - .filter(animal => animal.rarity === rarity && animal.type === type) + .filter(animal => animal.rarity === rarity && animal.type === type && animal.species !== exclude) .forEach(animal => { + if (species && animal.species !== species) { + return frag; + } + const animalDiv = document.createElement("div"); const optionSpan = document.createElement("span");