From 79c602f59c0db4f0515515457bc7a282e433fb4a Mon Sep 17 00:00:00 2001 From: Manu <4445816+tr4nt0r@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:24:23 +0100 Subject: [PATCH] Fix available conditions for chilling frost and stealth in Habitica (#129234) Co-authored-by: Joostlek --- homeassistant/components/habitica/button.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/homeassistant/components/habitica/button.py b/homeassistant/components/habitica/button.py index b254a828049..8b41fb8c987 100644 --- a/homeassistant/components/habitica/button.py +++ b/homeassistant/components/habitica/button.py @@ -121,9 +121,11 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( key=HabitipyButtonEntity.FROST, translation_key=HabitipyButtonEntity.FROST, press_fn=lambda coordinator: coordinator.api.user.class_.cast["frost"].post(), + # chilling frost can only be cast once per day (streaks buff is false) available_fn=( lambda data: data.user["stats"]["lvl"] >= 14 and data.user["stats"]["mp"] >= 40 + and not data.user["stats"]["buffs"]["streaks"] ), class_needed=MAGE, entity_picture="shop_frost.png", @@ -190,9 +192,21 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( press_fn=( lambda coordinator: coordinator.api.user.class_.cast["stealth"].post() ), + # Stealth buffs stack and it can only be cast if the amount of + # unfinished dailies is smaller than the amount of buffs available_fn=( lambda data: data.user["stats"]["lvl"] >= 14 and data.user["stats"]["mp"] >= 45 + and data.user["stats"]["buffs"]["stealth"] + < len( + [ + r + for r in data.tasks + if r.get("type") == "daily" + and r.get("isDue") is True + and r.get("completed") is False + ] + ) ), class_needed=ROGUE, entity_picture="shop_stealth.png", @@ -204,8 +218,10 @@ CLASS_SKILLS: tuple[HabiticaButtonEntityDescription, ...] = ( available_fn=( lambda data: data.user["stats"]["lvl"] >= 11 and data.user["stats"]["mp"] >= 15 + and data.user["stats"]["hp"] < 50 ), class_needed=HEALER, + entity_picture="shop_heal.png", ), HabiticaButtonEntityDescription( key=HabitipyButtonEntity.BRIGHTNESS,