mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
* not locking pre-owned gear - pin removed gear on revive * fix createAnimal (check for function) - hide pet-popover while dragging food * fix dragging popover text color * fix drop toasts * selectMembersModal: load members on item change
36 lines
951 B
JavaScript
36 lines
951 B
JavaScript
|
|
function getText (textOrFunction) {
|
|
if (textOrFunction instanceof Function) {
|
|
return textOrFunction();
|
|
} else {
|
|
return textOrFunction;
|
|
}
|
|
}
|
|
|
|
|
|
export default function createAnimal (egg, potion, type, content, userItems) {
|
|
let animalKey = `${egg.key}-${potion.key}`;
|
|
|
|
return {
|
|
key: animalKey,
|
|
class: type === 'pet' ? `Pet Pet-${animalKey}` : `Mount_Icon_${animalKey}`,
|
|
eggKey: egg.key,
|
|
eggName: getText(egg.text),
|
|
potionKey: potion.key,
|
|
potionName: getText(potion.text),
|
|
name: content[`${type}Info`][animalKey].text(),
|
|
isOwned () {
|
|
return userItems[`${type}s`][animalKey] > 0;
|
|
},
|
|
mountOwned () {
|
|
return userItems.mounts[this.key] > 0;
|
|
},
|
|
isAllowedToFeed () {
|
|
return type === 'pet' && this.isOwned() && !this.mountOwned();
|
|
},
|
|
isHatchable () {
|
|
return !this.isOwned() & userItems.eggs[egg.key] > 0 && userItems.hatchingPotions[potion.key] > 0;
|
|
},
|
|
};
|
|
}
|