Restrict transfers to HoF team and prevent blocking starter route

Transfer modal now only appears when a Hall of Fame team is selected,
using the existing hofTeam data instead of the survivors endpoint.
Without a HoF selection, advance proceeds directly with no transfer step.

Transferred encounters are now a separate category: they appear in their
own "Transferred Pokemon" section, don't occupy route slots in the
encounter map, and don't block the route-lock check (excluded via
genlocke_transfers subquery). The run detail endpoint returns
transferEncounterIds so the frontend can distinguish them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Julian Tabel
2026-02-09 11:35:05 +01:00
parent e1dac10d27
commit c2e946f500
6 changed files with 115 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
import { useState, useMemo, useEffect, useCallback } from 'react'
import { useParams, Link, useNavigate } from 'react-router-dom'
import { useRun, useUpdateRun } from '../hooks/useRuns'
import { useAdvanceLeg, useLegSurvivors } from '../hooks/useGenlockes'
import { useAdvanceLeg } from '../hooks/useGenlockes'
import { useGameRoutes } from '../hooks/useGames'
import { useCreateEncounter, useUpdateEncounter, useBulkRandomize } from '../hooks/useEncounters'
import { usePokemonFamilies } from '../hooks/usePokemon'
@@ -397,11 +397,6 @@ export function RunEncounters() {
const { data: run, isLoading, error } = useRun(runIdNum)
const advanceLeg = useAdvanceLeg()
const [showTransferModal, setShowTransferModal] = useState(false)
const { data: survivors } = useLegSurvivors(
run?.genlocke?.genlockeId ?? 0,
run?.genlocke?.legOrder ?? 0,
showTransferModal && !!run?.genlocke,
)
const { data: routes, isLoading: loadingRoutes } = useGameRoutes(
run?.gameId ?? null,
)
@@ -455,19 +450,27 @@ export function RunEncounters() {
}, [routes])
// Split encounters into normal (non-shiny) and shiny
const { normalEncounters, shinyEncounters } = useMemo(() => {
if (!run) return { normalEncounters: [], shinyEncounters: [] }
const transferIdSet = useMemo(
() => new Set(run?.transferEncounterIds ?? []),
[run?.transferEncounterIds],
)
const { normalEncounters, shinyEncounters, transferEncounters } = useMemo(() => {
if (!run) return { normalEncounters: [], shinyEncounters: [], transferEncounters: [] }
const normal: EncounterDetail[] = []
const shiny: EncounterDetail[] = []
const transfer: EncounterDetail[] = []
for (const enc of run.encounters) {
if (enc.isShiny) {
if (transferIdSet.has(enc.id)) {
transfer.push(enc)
} else if (enc.isShiny) {
shiny.push(enc)
} else {
normal.push(enc)
}
}
return { normalEncounters: normal, shinyEncounters: shiny }
}, [run])
return { normalEncounters: normal, shinyEncounters: shiny, transferEncounters: transfer }
}, [run, transferIdSet])
// Map routeId → encounter for quick lookup (normal encounters only)
const encounterByRoute = useMemo(() => {
@@ -871,7 +874,25 @@ export function RunEncounters() {
</div>
{run.status === 'completed' && run.genlocke && !run.genlocke.isFinalLeg && (
<button
onClick={() => setShowTransferModal(true)}
onClick={() => {
if (hofTeam && hofTeam.length > 0) {
setShowTransferModal(true)
} else {
advanceLeg.mutate(
{ genlockeId: run.genlocke!.genlockeId, legOrder: run.genlocke!.legOrder },
{
onSuccess: (genlocke) => {
const nextLeg = genlocke.legs.find(
(l) => l.legOrder === run.genlocke!.legOrder + 1,
)
if (nextLeg?.runId) {
navigate(`/runs/${nextLeg.runId}`)
}
},
},
)
}
}}
disabled={advanceLeg.isPending}
className="px-4 py-2 text-sm font-medium rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 transition-colors"
>
@@ -1081,6 +1102,24 @@ export function RunEncounters() {
</div>
)}
{/* Transfer Encounters */}
{transferEncounters.length > 0 && (
<div className="mb-6">
<h2 className="text-sm font-medium text-indigo-600 dark:text-indigo-400 mb-2">
Transferred Pokemon
</h2>
<div className="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-6 gap-2">
{transferEncounters.map((enc) => (
<PokemonCard
key={enc.id}
encounter={enc}
onClick={isActive ? () => setSelectedTeamEncounter(enc) : undefined}
/>
))}
</div>
</div>
)}
{/* Progress bar */}
<div className="mb-4">
<div className="flex items-center justify-between mb-1">
@@ -1449,9 +1488,9 @@ export function RunEncounters() {
)}
{/* Transfer Modal */}
{showTransferModal && survivors && (
{showTransferModal && hofTeam && hofTeam.length > 0 && (
<TransferModal
survivors={survivors}
hofTeam={hofTeam}
onSubmit={(encounterIds) => {
advanceLeg.mutate(
{