megadicing / modelling /row_schema.py
gloygum
Initial megadicing space
35465a0
Raw
History Blame Contribute Delete
2.88 kB
def __getattr__(name):
pass
def __dir__():
pass
from typing import Any, TypedDict, cast
class RollEventRow(TypedDict, total=False):
game_turn: Any
step_number: Any
player_id: Any
player_name: str
team_id: Any
dice_roller: Any
player_skills: list[Any]
target_player_id: Any
target_player_name: Any
target_player_skills: list[Any]
step_name: str
step_type: str
result_name: str
payload_type: str
roll_category: str
dice_values: list[Any]
dice_total: Any
difficulty: Any
roll_type: Any
outcome: Any
modifier_values: list[Any]
result_value: int
result_classification: str
report_result_classification: str
armour_holds: Any
probability_success: float
probability_neutral: float
probability_fail: float
raw: dict[str, Any]
exclude_from_surprise: bool
action_type: str
_REQUIRED_ROLL_EVENT_KEYS = {
"game_turn",
"step_number",
"player_id",
"player_name",
"team_id",
"dice_roller",
"result_name",
"payload_type",
"roll_category",
"dice_values",
"dice_total",
"difficulty",
"roll_type",
"outcome",
"modifier_values",
"result_value",
"result_classification",
"report_result_classification",
"probability_success",
"probability_neutral",
"probability_fail",
"raw",
}
def build_roll_event_row(event: dict[str, Any]) -> RollEventRow:
"""Validate required roll-event fields and return typed row."""
missing = sorted(key for key in _REQUIRED_ROLL_EVENT_KEYS if key not in event)
if missing:
raise ValueError(f"Roll event missing required keys: {', '.join(missing)}")
return cast(RollEventRow, event)
class ModeledReportRow(TypedDict, total=False):
step_number: Any
game_turn: Any
team_id: Any
dice_roller: Any
roll_category: str
probability_success: float
probability_neutral: float
probability_fail: float
result_value: int
report_result_classification: str
payload_type: str
class ModeledRowsPayload(TypedDict):
rows: list[ModeledReportRow]
kickoff_rows: list[ModeledReportRow]
sections: list[dict[str, Any]]
class UsableSurpriseRow(TypedDict):
turn: int
team_id: int
surprise: float
p_success: float
p_fail: float
class CumulativeTurnRow(TypedDict):
turn: int
usable_event_count: int
usable_event_count_turn: int
team0_event_count: int
team1_event_count: int
team0_event_count_turn: int
team1_event_count_turn: int
score_0_turn: float
score_1_turn: float
k1_0_turn: float
k1_1_turn: float
std_0_turn: float
std_1_turn: float
team0_centred_turn: float
team1_centred_turn: float
score_0_n: float
score_1_n: float
k1_0_n: float
k1_1_n: float
std_0_n: float
std_1_n: float