"""State helpers for Myco's first playable loop.""" from models.mushroom import Mushroom WELCOME_MESSAGE = "Hello! I'm Myco. Let's explore the forest." EMPTY_DEX = "Your MycoDex is empty. Discover a mushroom, then add it here." ChatHistory = list[dict[str, str]] MushroomState = dict[str, str] CollectionState = list[MushroomState] def welcome_history() -> ChatHistory: """Return the opening Myco companion message.""" return [{"role": "assistant", "content": WELCOME_MESSAGE}] def mushroom_from_state(current: MushroomState) -> Mushroom: """Hydrate a mushroom from Gradio state.""" return Mushroom.from_dict(current) def collection_contains(collection: CollectionState, mushroom_name: str) -> bool: """Return whether the MycoDex already has a mushroom by name.""" return any(entry.get("name") == mushroom_name for entry in collection)