1.3 KiB
1.3 KiB
Implement dnd-kit for Game View
Status: Planned
Date: 2025-12-18
Description:
Replace the standard HTML5 Drag and Drop API in GameView.tsx with @dnd-kit/core to ensure a consistent, high-performance, and touch-friendly user experience similar to the Deck Builder.
Technical Reference:
- DeckBuilderView.tsx: Uses
DndContext,useDraggable, anduseDroppablefor managing card movements. - GameView.tsx: Currently uses
onDragStart,onDrop, etc.
Plan:
- Install/Verify Dependencies:
@dnd-kit/coreand@dnd-kit/utilitiesare already installed. - Create Draggable Wrapper: Create a
DraggableCardcomponent that usesuseDraggableto wrapCardComponent. - Create Droppable Zones: Define
DroppableZonecomponents for Battlefield, Hand, Graveyard, Exile, etc. - Implement Context: Wrap the main game area in
DndContext. - Handle Drag Events: Implement
onDragEndinGameViewto handle logic previously inhandleZoneDropandhandleCardDrop.- Battlefield Drop ->
PLAY_LAND/CAST_SPELL(positionless). - Card on Card Drop ->
DECLARE_BLOCKERS/CAST_SPELL(Targeting).
- Battlefield Drop ->
- Refactor Rendering: Update the rendering of cards in
GameViewto use the newDraggableCardwrapper.