"""Entity profile HTML component.""" from __future__ import annotations from ui import assets from world.events import get_interactions_for_entity from world.locations import get_location_by_id from world.relationships import get_relationships_enriched from ui.avatars import render_avatar REL_LABELS = { "allied": "Allied", "friends": "Friends", "rivals": "Rivals", "enemies": "Enemies", "mentor": "Mentor", "owes_debt": "Owes a debt", } TYPE_LABELS = { "character": "Character", "creature": "Creature", "object": "Object", "place": "Place", } STATUS_LABELS = { "active": "Active", "dormant": "Dormant", "legendary": "Legendary", } def render_entity_card(entity: dict) -> str: location = get_location_by_id(entity["location_id"]) loc_name = location["name"].replace("The ", "") if location else "Unknown" type_label = TYPE_LABELS.get(entity["type"], entity["type"].title()) status = STATUS_LABELS.get(entity["status"], entity["status"].title()) status_class = f"status-{entity['status']}" traits_html = "".join( f'{t}' for t in entity["personality_traits"] ) tags_html = "" if entity.get("tags"): tags_html = "".join( f'{t}' for t in entity["tags"] ) secret_html = "" if entity.get("secret_name"): secret_html = f"""
{entity['secret_name']}
{r["description"]}
{entity['primary_goal']}
{entity['secondary_goal']}
{entity['primary_fear']}
"{entity['greeting']}"{secret_html}
{memory}
Select a soul on the left leaf to unveil their story.
{entity['appearance']}
Seeks {entity['primary_goal']}
Fears {entity['primary_fear']}
"{entity['greeting']}"
{entity['memory_summary'] or 'They have only just arrived.'}
{loc_short}
{entity['appearance'][:120]}{'…' if len(entity['appearance']) > 120 else ''}