mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2026-04-06 05:07:16 +02:00
feat: replace ENABLE_SMART_LANDS env var with per-build checkbox in New Deck modal (#64)
This commit is contained in:
parent
94765622ba
commit
b808f411ea
13 changed files with 1209 additions and 5046 deletions
|
|
@ -126,6 +126,7 @@ async def build_new_modal(request: Request) -> HTMLResponse:
|
|||
"use_owned_only": bool(sess.get("use_owned_only")),
|
||||
"prefer_owned": bool(sess.get("prefer_owned")),
|
||||
"swap_mdfc_basics": bool(sess.get("swap_mdfc_basics")),
|
||||
"enable_smart_lands": bool(sess.get("enable_smart_lands", True)),
|
||||
# Add ideal values from session (will be None on first load, triggering defaults)
|
||||
"ramp": sess.get("ideals", {}).get("ramp"),
|
||||
"lands": sess.get("ideals", {}).get("lands"),
|
||||
|
|
@ -417,6 +418,7 @@ async def build_new_submit(
|
|||
use_owned_only: bool = Form(False),
|
||||
prefer_owned: bool = Form(False),
|
||||
swap_mdfc_basics: bool = Form(False),
|
||||
enable_smart_lands: bool = Form(False),
|
||||
# Integrated Multi-Copy (optional)
|
||||
multi_choice_id: str | None = Form(None),
|
||||
multi_count: int | None = Form(None),
|
||||
|
|
@ -472,6 +474,7 @@ async def build_new_submit(
|
|||
"use_owned_only": bool(use_owned_only),
|
||||
"prefer_owned": bool(prefer_owned),
|
||||
"swap_mdfc_basics": bool(swap_mdfc_basics),
|
||||
"enable_smart_lands": bool(enable_smart_lands),
|
||||
"include_cards": include_cards or "",
|
||||
"exclude_cards": exclude_cards or "",
|
||||
"enforcement_mode": enforcement_mode or "warn",
|
||||
|
|
@ -819,6 +822,10 @@ async def build_new_submit(
|
|||
sess["swap_mdfc_basics"] = bool(swap_mdfc_basics)
|
||||
except Exception:
|
||||
sess["swap_mdfc_basics"] = False
|
||||
try:
|
||||
sess["enable_smart_lands"] = bool(enable_smart_lands)
|
||||
except Exception:
|
||||
sess["enable_smart_lands"] = True
|
||||
# Combos config from modal
|
||||
try:
|
||||
if combo_count is not None:
|
||||
|
|
|
|||
|
|
@ -185,6 +185,7 @@ def start_ctx_from_session(sess: dict, *, set_on_session: bool = True) -> Dict[s
|
|||
include_cards=sess.get("include_cards"),
|
||||
exclude_cards=sess.get("exclude_cards"),
|
||||
swap_mdfc_basics=bool(sess.get("swap_mdfc_basics")),
|
||||
enable_smart_lands=bool(sess.get("enable_smart_lands", True)),
|
||||
partner_feature_enabled=partner_enabled,
|
||||
secondary_commander=secondary_commander,
|
||||
background_commander=background_choice,
|
||||
|
|
|
|||
|
|
@ -2516,6 +2516,7 @@ def start_build_ctx(
|
|||
include_cards: List[str] | None = None,
|
||||
exclude_cards: List[str] | None = None,
|
||||
swap_mdfc_basics: bool | None = None,
|
||||
enable_smart_lands: bool | None = None,
|
||||
partner_feature_enabled: bool | None = None,
|
||||
secondary_commander: str | None = None,
|
||||
background_commander: str | None = None,
|
||||
|
|
@ -2682,6 +2683,8 @@ def start_build_ctx(
|
|||
pass
|
||||
# Smart land analysis — mirrors run_deck_build_step2() so web builds get profiles too
|
||||
try:
|
||||
if enable_smart_lands is not None:
|
||||
b.enable_smart_lands = bool(enable_smart_lands)
|
||||
b.run_land_analysis()
|
||||
except Exception:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -104,6 +104,10 @@
|
|||
<input type="checkbox" name="swap_mdfc_basics" id="swap-mdfc-chk" value="1" {% if form and form.swap_mdfc_basics %}checked{% endif %} />
|
||||
<span>Swap basics for MDFC lands</span>
|
||||
</label>
|
||||
<label for="smart-lands-chk" class="form-checkbox-label" title="When enabled, the builder automatically adjusts the land count and mana-base profile based on your commander's speed and color complexity.">
|
||||
<input type="checkbox" name="enable_smart_lands" id="smart-lands-chk" value="1" {% if form and form.enable_smart_lands %}checked{% endif %} />
|
||||
<span>Smart Land Bases</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue