"""SVG avatar sigils for entities — ornate monogram emblems per type. Real photographic creature art can't be matched reliably to abstract, quirky entities (a "Joke Dragon" is not a stock phoenix), so portraits use an elegant type-coloured sigil with the entity's monogram. This reads as a deliberate heraldic mark rather than a mismatched photo. """ from __future__ import annotations TYPE_PALETTES = { "character": {"bg": "#1f3a2c", "ring": "#d4a84b", "accent": "#8fbc8f", "mark": "✦"}, "creature": {"bg": "#3a281c", "ring": "#e07b4a", "accent": "#f0c878", "mark": "❧"}, "object": {"bg": "#1c2c3a", "ring": "#7fa8d0", "accent": "#a8c8e8", "mark": "◈"}, "place": {"bg": "#1c3a2c", "ring": "#60a060", "accent": "#90d090", "mark": "▲"}, } LOCATION_TINTS = { "library": "#c8a040", "sea": "#7090b0", "clock-forest": "#b06020", "moon-market": "#8060b0", "valley": "#506050", "crossroads": "#c04020", "mirror-bogs": "#406858", "hollow-mountain": "#808890", } def render_avatar(entity: dict, size: int = 80, location_slug: str | None = None) -> str: etype = entity.get("type", "character") palette = TYPE_PALETTES.get(etype, TYPE_PALETTES["character"]) tint = LOCATION_TINTS.get(location_slug or "", palette["ring"]) name = entity.get("display_name") or entity.get("name", "?") initial = name.replace("The ", "")[0].upper() if name else "?" uid = (entity.get("id") or "00000000")[:8] return f""" {initial} {palette['mark']} """