feat: update deck builder auto-fill to add lands as individual cards for individual management

This commit is contained in:
2025-12-17 16:56:33 +01:00
parent a0c3b7c59a
commit db785537c9
3 changed files with 51 additions and 1 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -85,7 +85,38 @@ export const DeckBuilderView: React.FC<DeckBuilderViewProps> = ({ 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);
}
};