mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 23:27:26 +01:00
refactor(modals): More readable invalid hatch check
This commit is contained in:
@@ -115,12 +115,12 @@ habitrpg.controller("InventoryCtrl",
|
|||||||
var potName = Content.hatchingPotions[potion.key].text();
|
var potName = Content.hatchingPotions[potion.key].text();
|
||||||
if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return;
|
if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return;
|
||||||
|
|
||||||
var invalidPet = (user.items.pets[egg.key + '-' + potion.key] > 0) ||
|
var userHasPet = user.items.pets[egg.key + '-' + potion.key] > 0;
|
||||||
(Content.hatchingPotions[potion.key].premium && !Content.dropEggs[egg.key])
|
var isPremiumPet = Content.hatchingPotions[potion.key].premium && !Content.dropEggs[egg.key];
|
||||||
|
|
||||||
user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}});
|
user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}});
|
||||||
|
|
||||||
if (!user.preferences.suppressModals.hatchPet && !invalidPet) {
|
if (!user.preferences.suppressModals.hatchPet && !userHasPet && !isPremiumPet) {
|
||||||
$scope.hatchedPet = {
|
$scope.hatchedPet = {
|
||||||
egg: eggName,
|
egg: eggName,
|
||||||
potion: potName,
|
potion: potName,
|
||||||
|
|||||||
Reference in New Issue
Block a user