Spaces:
Runtime error
Runtime error
File size: 802 Bytes
1b980f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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
|