Spaces:
Runtime error
Runtime error
Download scene_assets.py from comp5423/NewProject: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/spaces/comp5423/NewProject/resolve/main/scene_assets.py
- Command line
-
hf download hf://spaces/comp5423/NewProject/scene_assets.py
-
curl -L -o scene_assets.py https://huggingface.co/spaces/comp5423/NewProject/resolve/main/scene_assets.py
802 Bytes
| from __future__ import annotations | |
| from pathlib import Path | |
| IMAGE_DIR = Path(__file__).resolve().parent / "image" | |
| def _candidate_path(name: str | None) -> Path | None: | |
| if not name: | |
| return None | |
| candidate = IMAGE_DIR / f"{name}.png" | |
| if candidate.exists(): | |
| return candidate | |
| return None | |
| def get_scene_image_path(game_state, focus_npc: str | None = None) -> str | None: | |
| npc_candidate = _candidate_path(focus_npc) | |
| if npc_candidate is not None: | |
| return str(npc_candidate) | |
| for name in ( | |
| getattr(game_state.world, "current_scene", None), | |
| getattr(game_state.player, "location", None), | |
| ): | |
| scene_candidate = _candidate_path(name) | |
| if scene_candidate is not None: | |
| return str(scene_candidate) | |
| return None | |