brad-did-something / game /context.py
qFelix's picture
Brad Did Something - Gradio/FastAPI Space on HF
78c0f6e
Raw
History Blame Contribute Delete
2.09 kB
"""Global context builder β€” state β†’ the exact context object in SCHEMAS.md."""
from __future__ import annotations
from .schemas import APPROVED_CLIENTS, NPC_IDS
from .state import GameState
def build_context(state: GameState) -> dict:
return {
"game_config": {
"company": "Veloura Technologies",
"player_title": "Head of Sales and Partnerships",
"crisis_number": state.crisis_number,
"total_crises": 15,
"tone": "comedic corporate satire β€” The Office meets Silicon Valley",
"approved_clients": APPROVED_CLIENTS,
},
"financial_state": {
"revenue": state.revenue,
"target": state.target,
"company_budget": state.company_budget,
"bonuses_issued": state.bonuses_issued,
"total_bonus_spend": state.total_bonus_spend,
"pocket_money": state.pocket_money,
"bribes_accepted": state.bribes_accepted,
},
"team_state": {
"morale": state.morale,
"npcs": {
n: {
"relationship": s.relationship,
"gifts_received": s.gifts_received,
"mood": s.mood,
"incident_count": s.incident_count,
"personal_situation": s.personal_situation,
"recent_events": s.recent_events[-3:],
}
for n, s in state.npcs.items()
},
},
"constraint_state": {
"budget_warning": state.company_budget < 5_000,
"board_scrutiny": state.board_scrutiny,
"consecutive_praise": {n: state.npc(n).consecutive_praise for n in NPC_IDS},
"consecutive_harsh": state.consecutive_harsh,
"consecutive_fine_whatever": state.consecutive_fine_whatever,
"hr_alert": state.hr_alert,
"extended_presentation": bool(
state.presentation and state.presentation.get("extended")),
},
"event_log": list(state.event_log),
}