fix(policy): unblock upgrade confirmation after card selection

This commit is contained in:
0xrsydn 2026-09-22 12:45:46 +07:00
commit 1e14680c39
2 changed files with 25 additions and 1 deletions

View file

@ -119,7 +119,12 @@ class PolicyContext:
if inventory_item(old) == inventory_item(new): if inventory_item(old) == inventory_item(new):
return return
elif action == "combat_select_card": elif action == "combat_select_card":
if len(screen.get("selected_cards") or []) <= len(pending.screen.get("selected_cards") or []): # Upgrade previews do not expose selected_cards. A ready upgrade
# confirmation is completion evidence for the accepted selection.
upgrade_ready = screen.get("mode") == "upgrade_select" and screen.get("can_confirm")
selection_grew = (len(screen.get("selected_cards") or [])
> len(pending.screen.get("selected_cards") or []))
if not upgrade_ready and not selection_grew:
return return
elif action == "select_bundle": elif action == "select_bundle":
if not screen.get("preview_showing") or not screen.get("can_confirm"): if not screen.get("preview_showing") or not screen.get("can_confirm"):

View file

@ -402,6 +402,25 @@ result = invoke(fake, "--no-jev", "--steps", "5", "--max-duplicate-waits", "0")
check("hand selection waits for selected count, not the separate selected-card index", check("hand selection waits for selected count, not the separate selected-card index",
[a[0][0] for a in fake.actions], ["combat_select_card", "combat_confirm_selection", "menu_select"]) [a[0][0] for a in fake.actions], ["combat_select_card", "combat_confirm_selection", "menu_select"])
# Upgrade previews do not populate SelectedHandCardContainer, so the mod
# reports upgrade_select + can_confirm without selected_cards (live floor 12).
upgrade_hand = dict(hand, hand_select=dict(hand["hand_select"],
prompt="Choose a card to Upgrade."))
upgrade_preview = dict(upgrade_hand, hand_select=dict(upgrade_hand["hand_select"],
mode="upgrade_select", prompt="Confirm Card to Upgrade", can_confirm=True))
upgrade_loading = dict(upgrade_preview, hand_select=dict(upgrade_preview["hand_select"],
can_confirm=False))
fake = FakeSts2([menu, upgrade_hand, upgrade_hand, upgrade_hand, upgrade_loading,
{"state_type": "overlay"}, upgrade_preview, upgrade_preview, menu],
action_ok=[False, True])
result = invoke(fake, "--no-jev", "--steps", "8", "--max-duplicate-waits", "0")
check("upgrade selection retries rejection, waits for ready preview, then confirms once",
fake.actions, [(("combat_select_card",), {"card_index": 2}),
(("combat_select_card",), {"card_index": 2}),
(("combat_confirm_selection",), {}),
(("menu_select",), {"option": "singleplayer"})])
check("upgrade preview transition completes without a timeout", result.rc, 0)
fake = FakeSts2([menu] + [dict(shop, animation_tick=i) for i in range(100)]) fake = FakeSts2([menu] + [dict(shop, animation_tick=i) for i in range(100)])
result = invoke(fake, "--steps", "100", "--stuck-seconds", "10", clock=itertools.count()) result = invoke(fake, "--steps", "100", "--stuck-seconds", "10", clock=itertools.count())
check("pending purchase times out despite unrelated observation changes", check("pending purchase times out despite unrelated observation changes",