import type { NuzlockeRules } from '../types/rules' import { RULE_DEFINITIONS, DEFAULT_RULES } from '../types/rules' import { RuleToggle } from './RuleToggle' import { TypeBadge } from './TypeBadge' const POKEMON_TYPES = [ 'bug', 'dark', 'dragon', 'electric', 'fairy', 'fighting', 'fire', 'flying', 'ghost', 'grass', 'ground', 'ice', 'normal', 'poison', 'psychic', 'rock', 'steel', 'water', ] as const interface RulesConfigurationProps { rules: NuzlockeRules onChange: (rules: NuzlockeRules) => void onReset?: (() => void) | undefined hiddenRules?: Set | undefined } export function RulesConfiguration({ rules, onChange, onReset, hiddenRules, }: RulesConfigurationProps) { const visibleRules = hiddenRules ? RULE_DEFINITIONS.filter((r) => !hiddenRules.has(r.key)) : RULE_DEFINITIONS const coreRules = visibleRules.filter((r) => r.category === 'core') const playstyleRules = visibleRules.filter((r) => r.category === 'playstyle') const variantRules = visibleRules.filter((r) => r.category === 'variant') const handleRuleChange = (key: keyof NuzlockeRules, value: boolean) => { onChange({ ...rules, [key]: value }) } const handleResetToDefault = () => { onChange(DEFAULT_RULES) onReset?.() } const allowedTypes = rules.allowedTypes ?? [] const toggleType = (type: string) => { const next = allowedTypes.includes(type) ? allowedTypes.filter((t) => t !== type) : [...allowedTypes, type] onChange({ ...rules, allowedTypes: next }) } const enabledCount = visibleRules.filter((r) => rules[r.key]).length + (allowedTypes.length > 0 ? 1 : 0) const totalCount = visibleRules.length + 1 // +1 for type restriction return (

Rules Configuration

{enabledCount} of {totalCount} rules enabled

Core Rules

The fundamental rules of a Nuzlocke challenge

{coreRules.map((rule) => ( handleRuleChange(rule.key, value)} /> ))}

Playstyle

Describe how you're playing — doesn't affect tracker behavior

{playstyleRules.map((rule) => ( handleRuleChange(rule.key, value)} /> ))}

Run Variant

Changes which Pokémon can appear — affects the encounter selector

{variantRules.map((rule) => ( handleRuleChange(rule.key, value)} /> ))}

Type Restriction

Monolocke and variants. Select allowed types — a Pokémon qualifies if it shares at least one type. Leave all deselected to disable.

{POKEMON_TYPES.map((type) => ( ))}
{allowedTypes.length > 0 && ( )}
) }