diff --git a/src/facilities/farmyard/animals/animals.js b/src/facilities/farmyard/animals/animals.js index 5e867b92e54e4456fca3697ce18933c0bdf62ee5..eae64df26cfa23528cfe16bc6bb49b7fd33f98c4 100644 --- a/src/facilities/farmyard/animals/animals.js +++ b/src/facilities/farmyard/animals/animals.js @@ -195,7 +195,14 @@ App.Facilities.Farmyard.animals = function() { }; App.Facilities.Farmyard.animals.init = function() { + /** The base animal class. */ class Animal { + /** + * @param {string} name + * @param {string} species + * @param {string} type + * @param {string} rarity + */ constructor(name, species, type, rarity) { this.name = name; this.species = species; @@ -212,435 +219,62 @@ App.Facilities.Farmyard.animals.init = function() { } } - /** @type {Animal[]} */ - const canine = []; - const hooved = []; - const feline = []; - - App.Data.animals.canine.domestic.forEach(c => { - canine.push(new Animal(c.name, c.species, "canines", "domestic")); - }); - - canine.forEach(c => { - c.purchase(); - }); - - console.log(canine, canine[0].purchased); -}; + const dog = 'dog'; + const cat = 'cat'; + const canine = 'canines'; + const hooved = 'hooved' + const feline = 'felines'; + const domestic = 'domestic'; + const exotic = 'exotic'; -App.Data.animals = { - canine: { - domestic: [ - { - name: "beagle", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "bulldog", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "French bulldog", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "German shepherd", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "golden retriever", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "labrador retriever", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "poodle", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "rottweiler", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "Siberian husky", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "Yorkshire terrier", - species: "dog", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - ], - exotic: [ - { - name: "dingo", - species: "dingo", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "fox", - species: "fox", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "jackal", - species: "jackal", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - { - name: "wolf", - species: "wolf", - - get purchased() { - return V.canines.includes(this); - }, - purchase() { - V.canines.push(this.name); - } - }, - ], - }, - hooved: { - domestic: [ - { - name: "bull", - species: "bull", - - get purchased() { - return V.hooved.includes(this); - }, - purchase() { - V.hooved.push(this.name); - } - }, - { - name: "horse", - species: "horse", - - get purchased() { - return V.hooved.includes(this); - }, - purchase() { - V.hooved.push(this.name); - } - }, - { - name: "pig", - species: "pig", - - get purchased() { - return V.hooved.includes(this); - }, - purchase() { - V.hooved.push(this.name); - } - }, - ], - exotic: [ - { - name: "zebra", - species: "zebra", - - get purchased() { - return V.hooved.includes(this); - }, - purchase() { - V.hooved.push(this.name); - } - }, - { - name: "elephant", - species: "elephant", - - get purchased() { - return V.hooved.includes(this); - }, - purchase() { - V.hooved.push(this.name); - } - }, - ], - }, - feline: { - domestic: [ - { - name: "Abbysinian", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Bengal", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Birman", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Maine coon", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Oriental shorthair", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Persian", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Ragdoll", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Russian blue", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Siamese", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "Sphynx", - species: "cat", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - ], - exotic: [ - { - name: "cougar", - species: "cougar", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "jaguar", - species: "jaguar", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "leopard", - species: "leopard", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "lion", - species: "lion", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "lynx", - species: "lynx", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "puma", - species: "puma", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - { - name: "tiger", - species: "tiger", - - get purchased() { - return V.felines.includes(this); - }, - purchase() { - V.felines.push(this.name); - } - }, - ], - }, + /** @type {Animal[]} */ + const canineList = [ + new Animal("beagle", dog, canine, domestic), + new Animal("bulldog", dog, canine, domestic), + new Animal("French bulldog", dog, canine, domestic), + new Animal("German shepherd", dog, canine, domestic), + new Animal("golden retriever", dog, canine, domestic), + new Animal("labrador retriever", dog, canine, domestic), + new Animal("poodle", dog, canine, domestic), + new Animal("rottweiler", dog, canine, domestic), + new Animal("Siberian husky", dog, canine, domestic), + new Animal("Yorkshire terrier", dog, canine, domestic), + + new Animal("dingo", "dingo", canine, exotic), + new Animal("fox", "fox", canine, exotic), + new Animal("jackal", "jackal", canine, exotic), + new Animal("wolf", "wolf", canine, exotic), + ]; + /** @type {Animal[]} */ + const hoovedList = [ + new Animal("bull", "bull", hooved, domestic), + new Animal("horse", "horse", hooved, domestic), + new Animal("pig", "pig", hooved, domestic), + + new Animal("zebra", "zebra", hooved, exotic), + new Animal("elephant", "elephant", hooved, exotic), + ]; + /** @type {Animal[]} */ + const felineList = [ + new Animal("Abbysinian",cat, feline, domestic), + new Animal("Bengal", cat, feline, domestic), + new Animal("Birman", cat, feline, domestic), + new Animal("Maine coon", cat, feline, domestic), + new Animal("Oriental shorthair", cat, feline, domestic), + new Animal("Persian",cat, feline, domestic), + new Animal("Ragdoll",cat, feline, domestic), + new Animal("Russian blue",cat, feline, domestic), + new Animal("Siamese",cat, feline, domestic), + new Animal("Sphynx",cat, feline, domestic), + + new Animal("cougar", "cougar", feline, exotic), + new Animal("jaguar", "jaguar", feline, exotic), + new Animal("leopard", "leopard", feline, exotic), + new Animal("lion", "lion", feline, exotic), + new Animal("lynx", "lynx", feline, exotic), + new Animal("puma", "puma", feline, exotic), + new Animal("tiger", "tiger", feline, exotic), + ]; + + App.Data.animals = [...canineList, ...hoovedList, ...felineList]; };