Implement Retire HoF (Gauntlet) rule enforcement for genlockes

When retireHoF is enabled, surviving HoF Pokemon and their evolutionary
families are retired at leg advancement and treated as duplicates in all
subsequent legs — both in the encounter modal and bulk randomize.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Julian Tabel
2026-02-09 10:05:03 +01:00
parent 3ff132f284
commit 48b56f9360
12 changed files with 218 additions and 40 deletions

View File

@@ -78,12 +78,29 @@ async def get_run(run_id: int, session: AsyncSession = Depends(get_session)):
.where(GenlockeLeg.genlocke_id == leg.genlocke_id)
)
total_legs = total_legs_result.scalar_one()
# Aggregate retired Pokemon IDs from prior legs (retireHoF rule)
retired_pokemon_ids: list[int] = []
if leg.genlocke.genlocke_rules.get("retireHoF", False) and leg.leg_order > 1:
prior_result = await session.execute(
select(GenlockeLeg.retired_pokemon_ids).where(
GenlockeLeg.genlocke_id == leg.genlocke_id,
GenlockeLeg.leg_order < leg.leg_order,
GenlockeLeg.retired_pokemon_ids.isnot(None),
)
)
cumulative: set[int] = set()
for (ids,) in prior_result:
cumulative.update(ids)
retired_pokemon_ids = sorted(cumulative)
genlocke_context = RunGenlockeContext(
genlocke_id=leg.genlocke_id,
genlocke_name=leg.genlocke.name,
leg_order=leg.leg_order,
total_legs=total_legs,
is_final_leg=leg.leg_order == total_legs,
retired_pokemon_ids=retired_pokemon_ids,
)
response = RunDetailResponse.model_validate(run)