| from backend.models.case import NPC, CaseFile, ClueState | |
| def build_authorized_context(npc: NPC, case: CaseFile) -> list[str]: | |
| """Returns the facts the NPC is allowed to reference this turn.""" | |
| ctx: list[str] = list(npc.authorized_reveals.always) | |
| if npc.emotional_state.anxiety > 50: | |
| ctx.extend(npc.authorized_reveals.anxiety_gt_50) | |
| if npc.emotional_state.anxiety > 75: | |
| ctx.extend(npc.authorized_reveals.anxiety_gt_75) | |
| discovered_ids = {c.id for c in case.clues if c.state != ClueState.hidden} | |
| for clue_id, reveals in npc.authorized_reveals.clue_found.items(): | |
| if clue_id in discovered_ids: | |
| ctx.extend(reveals) | |
| return ctx | |