Add randomize encounters feature (per-route + bulk)

Per-route: Randomize/Re-roll button in EncounterModal picks a uniform
random pokemon from eligible (non-duped) encounters. Bulk: new
POST /runs/{run_id}/encounters/bulk-randomize endpoint fills all
remaining routes in order, respecting dupes clause cascading, pinwheel
zones, and route group locking. Frontend Randomize All button on the
run page triggers the bulk endpoint with a confirm dialog.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 13:14:43 +01:00
parent 6779e3effa
commit 46f246028f
7 changed files with 349 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import {
deleteEncounter,
fetchEvolutions,
fetchForms,
bulkRandomizeEncounters,
} from '../api/encounters'
import type { CreateEncounterInput, UpdateEncounterInput } from '../types/game'
@@ -59,3 +60,13 @@ export function useForms(pokemonId: number | null) {
enabled: pokemonId !== null,
})
}
export function useBulkRandomize(runId: number) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: () => bulkRandomizeEncounters(runId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['runs', runId] })
},
})
}