mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-17 08:00:13 +01:00
web: DRY Step 5 and alternatives (partial+macro), centralize start_ctx/owned_set, adopt builder_*
This commit is contained in:
parent
fe9aabbce9
commit
014bcc37b7
24 changed files with 1200 additions and 766 deletions
32
code/web/services/summary_utils.py
Normal file
32
code/web/services/summary_utils.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Dict
|
||||
from deck_builder import builder_constants as bc
|
||||
from .build_utils import owned_set as owned_set_helper
|
||||
from .combo_utils import detect_for_summary as _detect_for_summary
|
||||
|
||||
|
||||
def summary_ctx(
|
||||
*,
|
||||
summary: dict | None,
|
||||
commander: str | None = None,
|
||||
tags: list[str] | None = None,
|
||||
include_versions: bool = True,
|
||||
) -> Dict[str, Any]:
|
||||
"""Build a unified context payload for deck summary panels.
|
||||
|
||||
Provides owned_set, game_changers, combos/synergies, and detector versions.
|
||||
"""
|
||||
det = _detect_for_summary(summary, commander_name=commander or "") if summary else {"combos": [], "synergies": [], "versions": {}}
|
||||
combos = det.get("combos", [])
|
||||
synergies = det.get("synergies", [])
|
||||
versions = det.get("versions", {} if include_versions else None)
|
||||
return {
|
||||
"owned_set": owned_set_helper(),
|
||||
"game_changers": bc.GAME_CHANGERS,
|
||||
"combos": combos,
|
||||
"synergies": synergies,
|
||||
"versions": versions,
|
||||
"commander": commander,
|
||||
"tags": tags or [],
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue