Spaces:
Sleeping
Sleeping
Download game/state.py from byte-vortex/Myco: direct link, hf CLI and curl.
- Browser
- Download file 869 Bytes
-
https://huggingface.co/spaces/byte-vortex/Myco/resolve/5b6725d501a8e358094de1531e00a92e938dcfc9/game/state.py
- Command line
-
hf download hf://spaces/byte-vortex/Myco@5b6725d501a8e358094de1531e00a92e938dcfc9/game/state.py
-
curl -L -o state.py https://huggingface.co/spaces/byte-vortex/Myco/resolve/5b6725d501a8e358094de1531e00a92e938dcfc9/game/state.py
869 Bytes
| """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) | |