Add type restriction rule (monolocke)
Adds allowedTypes: string[] to NuzlockeRules. When set, the encounter selector hides non-matching Pokemon and the routes endpoint filters out routes with no matching encounters, so only eligible locations appear. Type picker UI in RulesConfiguration; active restriction shown in RuleBadges. Backend accepts allowed_types query param and joins through RouteEncounter.pokemon to filter by type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,7 @@ interface EncounterModalProps {
|
||||
isPending: boolean
|
||||
useAllPokemon?: boolean | undefined
|
||||
staticClause?: boolean | undefined
|
||||
allowedTypes?: string[] | undefined
|
||||
}
|
||||
|
||||
const statusOptions: {
|
||||
@@ -201,6 +202,7 @@ export function EncounterModal({
|
||||
isPending,
|
||||
useAllPokemon,
|
||||
staticClause = true,
|
||||
allowedTypes,
|
||||
}: EncounterModalProps) {
|
||||
const { data: routePokemon, isLoading: loadingPokemon } = useRoutePokemon(
|
||||
useAllPokemon ? null : route.id,
|
||||
@@ -267,8 +269,10 @@ export function EncounterModal({
|
||||
[routePokemon]
|
||||
)
|
||||
|
||||
const filteredPokemon = routePokemon?.filter((rp) =>
|
||||
rp.pokemon.name.toLowerCase().includes(search.toLowerCase())
|
||||
const filteredPokemon = routePokemon?.filter(
|
||||
(rp) =>
|
||||
rp.pokemon.name.toLowerCase().includes(search.toLowerCase()) &&
|
||||
(!allowedTypes?.length || rp.pokemon.types.some((t) => allowedTypes.includes(t)))
|
||||
)
|
||||
|
||||
const groupedPokemon = useMemo(
|
||||
@@ -446,9 +450,13 @@ export function EncounterModal({
|
||||
}
|
||||
onClick={() => {
|
||||
if (routePokemon) {
|
||||
const eligible = staticClause
|
||||
? routePokemon
|
||||
: routePokemon.filter((rp) => rp.encounterMethod !== 'static')
|
||||
const eligible = routePokemon
|
||||
.filter((rp) => staticClause || rp.encounterMethod !== 'static')
|
||||
.filter(
|
||||
(rp) =>
|
||||
!allowedTypes?.length ||
|
||||
rp.pokemon.types.some((t) => allowedTypes.includes(t))
|
||||
)
|
||||
setSelectedPokemon(pickRandomPokemon(eligible, dupedPokemonIds))
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user