4.9 KiB
Task 9: Fix Climb/Descend Controls - Context Summary
Status: Partially done (spam prevention and re-entry resume implemented, button rename incomplete)
1. Climbing/Descending State in store.ts
State Variables (lines 820, 2260):
spireMode: boolean- Whether player is in Spire ModeclearedFloors: Record<number, boolean>- Tracks cleared floors for respawningclimbDirection: 'up' | 'down' | null- Current climb direction (persisted for re-entry)isDescending: boolean- True when actively descending (prevents spam clicking)
Key Actions:
enterSpireMode()(line 2253): SetsspireMode: true,currentAction: 'climb',isDescending: falseclimbDownFloor()(line 2267):- Checks
isDescendingto prevent spam - Decrements floor by 1 (min floor 1)
- Sets
isDescending: trueduring descent - Uses
setTimeoutto resetisDescending: falseafter 500ms - Clears/resets floor state in
clearedFloors
- Checks
exitSpireMode()(line 2311): SetsspireMode: false,currentAction: 'meditate',isDescending: false
Spam Prevention (COMPLETED):
isDescendingflag prevents multiple rapid clicks- Button is disabled when
isDescendingis true - 500ms timeout resets the flag after descent completes
Re-entry Resume (COMPLETED):
climbDirectionis persisted in stateenterSpireMode()resumes fromclimbDirectionstateexitSpireMode()allows exit at any floor, re-entry resumes at same floor
2. Buttons in SpireTab Components and page.tsx
src/app/page.tsx (Spire Mode UI) - Lines 258-278:
Climbing Indicator Badge (line 263-266):
{store.currentAction === 'climb' && !store.isDescending && (
<Badge className="bg-green-900/50 text-green-300 border-green-600">
Climbing
</Badge>
)}
Descend/Climb Button (lines 267-278):
<Button
variant="outline"
className="border-blue-600/50 text-blue-400 hover:bg-blue-900/20"
onClick={() => store.climbDownFloor()}
disabled={store.isDescending}
>
<ChevronDown className="w-4 h-4 mr-2" />
{store.isDescending ? 'Descending…' :
store.currentAction === 'climb' ? 'Climbing' :
'Begin Descent'}
</Button>
Current Button Label Logic:
- When
isDescendingis true: Shows "Descending…" (with ellipsis) and button is disabled - When
currentAction === 'climb': Shows "Climbing" - Otherwise: Shows "Begin Descent"
Enter Spire Mode Button (lines 211-221):
<Button
className="w-full bg-gradient-to-r from-amber-600 to-orange-600..."
onClick={() => store.enterSpireMode()}
disabled={!canEnterSpireMode(store)}
>
<Mountain className="w-5 h-5 mr-2" />
Climb the Spire
</Button>
src/components/game/tabs/SpireTab.tsx:
- No climb/descend buttons - This component only displays floor info, spells, golems, and activity log
- Has "Enter Spire Mode" button (line 76) with label "Enter Spire Mode" (for non-Spire Mode view)
- Displays floor information, active spells, golems, and activity log in
simpleMode={true}
3. What Needs to Change for Button Rename
Requirement: idle: 'Begin Descent', descending: 'Descending' disabled, climbing: 'Climbing'
Current Issues:
-
"Descending…" vs "Descending": The button shows "Descending…" (with ellipsis) when descending, but requirement says "Descending" (without ellipsis)
-
Button label when climbing: The current logic shows "Climbing" when
currentAction === 'climb', but this is confusing because:- The button's action is to descend (calls
climbDownFloor()) - The "Climbing" Badge already serves as a separate indicator
- When climbing, users may want to descend, so the button should probably say "Begin Descent"
- The button's action is to descend (calls
-
Possible correct implementation:
- Remove the
currentAction === 'climb'check from button label - Button should always show "Begin Descent" when not descending
- Button shows "Descending" (disabled) when descending
- Keep the separate "Climbing" Badge as a status indicator
- Remove the
Suggested Button Code Fix (in page.tsx, lines 274-277):
{store.isDescending ? 'Descending' : 'Begin Descent'}
(Remove the store.currentAction === 'climb' ? 'Climbing' : 'Begin Descent' part)
4. Summary of Files to Modify
| File | Change Needed |
|---|---|
src/app/page.tsx |
Fix button label logic (lines 274-277) to match requirements |
src/lib/game/store.ts |
No changes needed (spam prevention and re-entry resume implemented) |
src/components/game/tabs/SpireTab.tsx |
No changes needed (no climb/descend buttons) |
5. Verification Steps
After making changes:
- Test spam prevention: Rapidly click descend button - should only descend once per 500ms
- Test re-entry resume: Exit Spire Mode at floor X, re-enter - should resume at floor X
- Test button labels:
- Idle (not climbing, not descending): Shows "Begin Descent"
- Descending: Shows "Descending" (disabled)
- Climbing: The separate Badge shows "Climbing", button shows "Begin Descent"