From 8fbf658a2773ecb9e408e36d837b0032cb686b24 Mon Sep 17 00:00:00 2001 From: Julian Tabel Date: Sun, 8 Feb 2026 10:40:18 +0100 Subject: [PATCH] Hide Pinwheel Clause rule toggle for games without pinwheel zones Fetches routes for the selected game during run creation and hides the Pinwheel Clause option when no routes have pinwheel zone data. Co-Authored-By: Claude Opus 4.6 --- ...el-clause-when-game-has-no-pinwheel-zon.md | 5 ++-- .../src/components/RulesConfiguration.tsx | 13 ++++++---- frontend/src/pages/NewRun.tsx | 24 +++++++++++++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.beans/nuzlocke-tracker-v04g--hide-pinwheel-clause-when-game-has-no-pinwheel-zon.md b/.beans/nuzlocke-tracker-v04g--hide-pinwheel-clause-when-game-has-no-pinwheel-zon.md index 651547b..aa3a7b7 100644 --- a/.beans/nuzlocke-tracker-v04g--hide-pinwheel-clause-when-game-has-no-pinwheel-zon.md +++ b/.beans/nuzlocke-tracker-v04g--hide-pinwheel-clause-when-game-has-no-pinwheel-zon.md @@ -1,10 +1,11 @@ --- # nuzlocke-tracker-v04g title: Hide Pinwheel Clause when game has no pinwheel zones -status: todo +status: completed type: bug +priority: normal created_at: 2026-02-07T21:08:27Z -updated_at: 2026-02-07T21:08:27Z +updated_at: 2026-02-08T09:37:48Z --- The Pinwheel Clause rule option is currently shown for all games, even those that have no locations using pinwheel zones (i.e. no routes with pinwheel_zone IDs). It should only be displayed when the selected game actually has routes with pinwheel zone data. \ No newline at end of file diff --git a/frontend/src/components/RulesConfiguration.tsx b/frontend/src/components/RulesConfiguration.tsx index e619e0e..94bd735 100644 --- a/frontend/src/components/RulesConfiguration.tsx +++ b/frontend/src/components/RulesConfiguration.tsx @@ -6,15 +6,20 @@ interface RulesConfigurationProps { rules: NuzlockeRules onChange: (rules: NuzlockeRules) => void onReset?: () => void + hiddenRules?: Set } export function RulesConfiguration({ rules, onChange, onReset, + hiddenRules, }: RulesConfigurationProps) { - const coreRules = RULE_DEFINITIONS.filter((r) => r.category === 'core') - const difficultyRules = RULE_DEFINITIONS.filter( + const visibleRules = hiddenRules + ? RULE_DEFINITIONS.filter((r) => !hiddenRules.has(r.key)) + : RULE_DEFINITIONS + const coreRules = visibleRules.filter((r) => r.category === 'core') + const difficultyRules = visibleRules.filter( (r) => r.category === 'difficulty' ) @@ -27,8 +32,8 @@ export function RulesConfiguration({ onReset?.() } - const enabledCount = Object.values(rules).filter(Boolean).length - const totalCount = Object.keys(rules).length + const enabledCount = visibleRules.filter((r) => rules[r.key]).length + const totalCount = visibleRules.length return (
diff --git a/frontend/src/pages/NewRun.tsx b/frontend/src/pages/NewRun.tsx index 33eda9b..90e7fd9 100644 --- a/frontend/src/pages/NewRun.tsx +++ b/frontend/src/pages/NewRun.tsx @@ -1,10 +1,11 @@ -import { useState } from 'react' +import { useMemo, useState } from 'react' import { useNavigate } from 'react-router-dom' import { GameGrid, RulesConfiguration, StepIndicator } from '../components' -import { useGames } from '../hooks/useGames' +import { useGames, useGameRoutes } from '../hooks/useGames' import { useCreateRun, useRuns } from '../hooks/useRuns' import type { Game, NuzlockeRules } from '../types' import { DEFAULT_RULES } from '../types' +import { RULE_DEFINITIONS } from '../types/rules' const DEFAULT_COLOR = '#6366f1' @@ -18,6 +19,16 @@ export function NewRun() { const [selectedGame, setSelectedGame] = useState(null) const [rules, setRules] = useState(DEFAULT_RULES) const [runName, setRunName] = useState('') + const { data: routes } = useGameRoutes(selectedGame?.id ?? null) + + const hiddenRules = useMemo(() => { + const hidden = new Set() + const hasPinwheelZones = routes?.some((r) => r.pinwheelZone != null) + if (!hasPinwheelZones) { + hidden.add('pinwheelClause') + } + return hidden.size > 0 ? hidden : undefined + }, [routes]) const handleGameSelect = (game: Game) => { if (selectedGame?.id === game.id) { @@ -38,8 +49,11 @@ export function NewRun() { ) } - const enabledRuleCount = Object.values(rules).filter(Boolean).length - const totalRuleCount = Object.keys(rules).length + const visibleRuleKeys = RULE_DEFINITIONS + .filter((r) => !hiddenRules?.has(r.key)) + .map((r) => r.key) + const enabledRuleCount = visibleRuleKeys.filter((k) => rules[k]).length + const totalRuleCount = visibleRuleKeys.length return (
@@ -121,7 +135,7 @@ export function NewRun() { {step === 2 && (
- +