Skip to content

Commit 79c602f

Browse files
tr4nt0rjoostlek
andauthored
Fix available conditions for chilling frost and stealth in Habitica (#129234)
Co-authored-by: Joostlek <[email protected]>
1 parent 07c070e commit 79c602f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

homeassistant/components/habitica/button.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ class HabitipyButtonEntity(StrEnum):
121121
key=HabitipyButtonEntity.FROST,
122122
translation_key=HabitipyButtonEntity.FROST,
123123
press_fn=lambda coordinator: coordinator.api.user.class_.cast["frost"].post(),
124+
# chilling frost can only be cast once per day (streaks buff is false)
124125
available_fn=(
125126
lambda data: data.user["stats"]["lvl"] >= 14
126127
and data.user["stats"]["mp"] >= 40
128+
and not data.user["stats"]["buffs"]["streaks"]
127129
),
128130
class_needed=MAGE,
129131
entity_picture="shop_frost.png",
@@ -190,9 +192,21 @@ class HabitipyButtonEntity(StrEnum):
190192
press_fn=(
191193
lambda coordinator: coordinator.api.user.class_.cast["stealth"].post()
192194
),
195+
# Stealth buffs stack and it can only be cast if the amount of
196+
# unfinished dailies is smaller than the amount of buffs
193197
available_fn=(
194198
lambda data: data.user["stats"]["lvl"] >= 14
195199
and data.user["stats"]["mp"] >= 45
200+
and data.user["stats"]["buffs"]["stealth"]
201+
< len(
202+
[
203+
r
204+
for r in data.tasks
205+
if r.get("type") == "daily"
206+
and r.get("isDue") is True
207+
and r.get("completed") is False
208+
]
209+
)
196210
),
197211
class_needed=ROGUE,
198212
entity_picture="shop_stealth.png",
@@ -204,8 +218,10 @@ class HabitipyButtonEntity(StrEnum):
204218
available_fn=(
205219
lambda data: data.user["stats"]["lvl"] >= 11
206220
and data.user["stats"]["mp"] >= 15
221+
and data.user["stats"]["hp"] < 50
207222
),
208223
class_needed=HEALER,
224+
entity_picture="shop_heal.png",
209225
),
210226
HabiticaButtonEntityDescription(
211227
key=HabitipyButtonEntity.BRIGHTNESS,

0 commit comments

Comments
 (0)