From db785537c9f57ea6f9d453f60201ec2ee8a42d46 Mon Sep 17 00:00:00 2001 From: dnviti Date: Wed, 17 Dec 2025 16:56:33 +0100 Subject: [PATCH] feat: update deck builder auto-fill to add lands as individual cards for individual management --- docs/development/CENTRAL.md | 1 + .../2025-12-17-165500_update_deck_autofill.md | 18 ++++++++++ .../src/modules/draft/DeckBuilderView.tsx | 33 ++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 docs/development/devlog/2025-12-17-165500_update_deck_autofill.md diff --git a/docs/development/CENTRAL.md b/docs/development/CENTRAL.md index 94d409e..159d27b 100644 --- a/docs/development/CENTRAL.md +++ b/docs/development/CENTRAL.md @@ -83,3 +83,4 @@ - [Deck Builder Magnified View](./devlog/2025-12-17-160500_deck_builder_magnified_view.md): Completed. Added magnified card preview sidebar to deck builder. - [Gameplay Magnified View & Timeout](./devlog/2025-12-17-161500_gameplay_magnified_view_and_timeout.md): Completed. Added magnified view with full card details (Oracle text, type, mana) to gameplay and disabled timeout. - [Test Deck Feature](./devlog/2025-12-17-162500_test_deck_feature.md): Completed. Implemented "Test Solo" button in Cube Manager to instantly start a solo game with a randomized deck from generated packs. +- [Update Deck Auto-Fill](./devlog/2025-12-17-165500_update_deck_autofill.md): Completed. Updated deck builder "Auto-Fill" to add lands as individual cards to the deck list for easier management. diff --git a/docs/development/devlog/2025-12-17-165500_update_deck_autofill.md b/docs/development/devlog/2025-12-17-165500_update_deck_autofill.md new file mode 100644 index 0000000..dda3d40 --- /dev/null +++ b/docs/development/devlog/2025-12-17-165500_update_deck_autofill.md @@ -0,0 +1,18 @@ +# Update Deck Auto-Fill Logic + +## Request +The user requested that the "Auto-Fill" (Add Lands) button in the Deck Builder behave exactly like clicking individual lands in the Land Station. Specifically, lands should be added as individual card entries in the deck list so they can be viewed and removed one by one, rather than just updating a counter. + +## Implementation Plan +1. Modify `applySuggestion` function in `src/client/src/modules/draft/DeckBuilderView.tsx`. +2. Check if `availableBasicLands` is populated (indicating the graphical Land Station is active). +3. If active, iterate through the suggested land counts. +4. For each count, find the corresponding land card object in `availableBasicLands`. +5. Generate unique card objects (with unique IDs) for each land instance, replicating the logic of `addLandToDeck`. +6. Add these new land objects to the `deck` state. +7. Retain the old counter-based logic as a fallback if `availableBasicLands` is empty. + +## Status +- [x] Analyzed `DeckBuilderView.tsx` to understand current `applySuggestion` vs `addLandToDeck` logic. +- [x] Refactored `applySuggestion` to implement the new behavior. +- [x] Verified ID generation and state updates match existing patterns. diff --git a/src/client/src/modules/draft/DeckBuilderView.tsx b/src/client/src/modules/draft/DeckBuilderView.tsx index c4bc27e..2410bbc 100644 --- a/src/client/src/modules/draft/DeckBuilderView.tsx +++ b/src/client/src/modules/draft/DeckBuilderView.tsx @@ -85,7 +85,38 @@ export const DeckBuilderView: React.FC = ({ initialPool, a }, [deck]); const applySuggestion = () => { - if (landSuggestion) { + if (!landSuggestion) return; + + // Check if we have available basic lands to add as real cards + if (availableBasicLands && availableBasicLands.length > 0) { + const newLands: any[] = []; + + Object.entries(landSuggestion).forEach(([type, count]) => { + if (count <= 0) return; + + // Find matching land in availableBasicLands + // We look for strict name match first, then potential fallback (e.g. snow lands) + const landCard = availableBasicLands.find(l => l.name === type) || + availableBasicLands.find(l => l.name.includes(type)); + + if (landCard) { + for (let i = 0; i < count; i++) { + const newLand = { + ...landCard, + // Ensure unique ID with index + id: `land-${landCard.scryfallId}-${Date.now()}-${Math.random().toString(36).substr(2, 5)}-${i}`, + image_uris: landCard.image_uris || { normal: landCard.image } + }; + newLands.push(newLand); + } + } + }); + + if (newLands.length > 0) { + setDeck(prev => [...prev, ...newLands]); + } + } else { + // Fallback: If no basic lands loaded (counter mode), use the old counter logic setLands(landSuggestion); } };