fix: special are not "AllowedToFeed" (#10808)

*  fix: special are not "AllowedToFeed"

* fix lint
This commit is contained in:
negue
2018-11-08 11:11:04 +01:00
committed by Matteo Pagliazzi
parent ee2858199b
commit 7fbc68511b

View File

@@ -1,4 +1,8 @@
import content from 'common/script/content';
const specialPets = Object.keys(content.specialPets);
function getText (textOrFunction) {
if (textOrFunction instanceof Function) {
return textOrFunction();
@@ -18,10 +22,12 @@ export function isHatchable (animal, userItems) {
}
export function isAllowedToFeed (animal, userItems) {
return isOwned('pet', animal, userItems) && !isOwned('mount', animal, userItems);
return !specialPets.includes(animal.key) &&
isOwned('pet', animal, userItems) &&
!isOwned('mount', animal, userItems);
}
export function createAnimal (egg, potion, type, content, userItems) {
export function createAnimal (egg, potion, type, _content, userItems) {
let animalKey = `${egg.key}-${potion.key}`;
return {
@@ -31,7 +37,7 @@ export function createAnimal (egg, potion, type, content, userItems) {
eggName: getText(egg.text),
potionKey: potion.key,
potionName: getText(potion.text),
name: content[`${type}Info`][animalKey].text(),
name: _content[`${type}Info`][animalKey].text(),
isOwned () {
return isOwned(type, this, userItems);
},
@@ -46,3 +52,4 @@ export function createAnimal (egg, potion, type, content, userItems) {
},
};
}