Enhance MTGA Deck Builder: Collection Filter Toggle
Introduction
In this article, we'll delve into a proposed enhancement for the MTGA Deck Builder: the addition of a collection filter toggle. This feature aims to streamline the deck-building process by allowing players to easily filter card search results to display only cards they currently own in their collection. This enhancement promises to make deck construction more efficient and user-friendly, especially for players who want to build decks using the resources they already have.
Understanding the Need for a Collection Filter
When diving into the world of Magic: The Gathering Arena (MTGA), one of the most engaging activities is crafting the perfect deck. However, the current deck-building process can sometimes feel cumbersome, especially for players with extensive collections. Sifting through numerous cards to find those you actually possess can be time-consuming and frustrating. The introduction of a collection filter toggle directly addresses this issue by providing a quick and efficient way to narrow down card search results. This not only saves time but also enhances the overall deck-building experience, making it more enjoyable and less tedious.
User Story: A Deck Builder's Perspective
Imagine you're a deck builder eager to create a new strategy. You have a specific idea in mind, but you want to leverage the cards already in your collection. Without a collection filter, you must manually search for each card, check if you own it, and then decide whether to include it in your deck. This process is inefficient and can disrupt your creative flow. With a collection filter toggle, you can instantly view only the cards you own, allowing you to focus on building the best possible deck with your available resources. This feature empowers players to make informed decisions and construct decks tailored to their collections.
UI Changes: Enhancing User Experience
To seamlessly integrate the collection filter toggle, several user interface (UI) enhancements are necessary. These changes are designed to be intuitive and non-intrusive, ensuring that the deck-building process remains smooth and efficient.
Toggle Switch Implementation
The primary UI change involves adding a toggle switch within the CardSearch component. This toggle will allow users to switch between viewing all MTGA cards and viewing only the cards in their collection. The toggle could be designed as a simple "Show: All Cards | My Collection" option, providing a clear and straightforward way to filter search results. The visual design of the toggle should align with the overall aesthetic of the MTGA interface, ensuring a cohesive and professional look.
Persistence and Visual Indicators
To enhance user convenience, the state of the toggle should persist across searches within the same session. This means that if a user selects "My Collection," the filter will remain active until they explicitly switch back to "All Cards." Additionally, a visual indicator should clearly show when the collection filter is active. This could be a change in color or the addition of an icon next to the toggle, providing immediate feedback to the user. When the collection filter is enabled, each card displayed should also show the quantity owned by the user, further aiding in the deck-building process.
Backend Integration: Connecting Card Search to Collection Data
The functionality of the collection filter toggle relies heavily on seamless backend integration. This involves connecting the CardSearch component to the CollectionRepository to filter search results based on the cards a user owns.
Filtering Search Results
When the collection filter is active, the backend must filter search results to include only cards with a quantity greater than zero in the user's collection. This ensures that only owned cards are displayed, providing an accurate representation of available resources. The owned quantity of each card should also be displayed on the card result, giving users immediate information about their collection.
Displaying Owned Quantity
For each card displayed in the filtered search results, the backend should provide information about the quantity owned. This could be displayed as "4x owned" or a similar format, allowing users to quickly assess their available resources and make informed decisions about deck construction. The display of owned quantities adds a layer of convenience and efficiency to the deck-building process.
Handling Edge Cases: Ensuring a Smooth User Experience
To ensure a robust and user-friendly experience, several edge cases must be addressed. These include handling empty collections, dealing with a disconnected daemon, and managing draft decks.
Empty Collection Handling
If a user has an empty collection, the collection filter should gracefully handle this scenario. Instead of displaying an error or no results, a message such as "No cards in collection" should be shown. This provides clear feedback to the user and prevents confusion.
Daemon Disconnection
In cases where the daemon is not connected, the collection filter should be disabled. A tooltip or message should be displayed to inform the user that the filter is unavailable due to the disconnected daemon. This prevents users from attempting to use the filter when it cannot function properly.
Draft Deck Considerations
Draft decks should default to the draft pool rather than the user's collection. This ensures that players can build draft decks using the cards available in the draft, regardless of their personal collection. This distinction is crucial for maintaining the integrity of the draft format.
Mockup: Visualizing the Feature
To illustrate the proposed changes, consider the following mockup:
┌─────────────────────────────────────────┐
│ Card Search │
├─────────────────────────────────────────┤
│ [🔍 Search cards...] │
│ │
│ Show: (○) All Cards (●) My Collection │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ Lightning Bolt ⚡ 1R │ │
│ │ Instant 4x owned │ │
│ └─────────────────────────────────────┘ │
│ ┌─────────────────────────────────────┐ │
│ │ Counterspell 💧 UU │ │
│ │ Instant 2x owned │ │
│ └─────────────────────────────────────┘
Files Affected: Implementation Details
The implementation of the collection filter toggle will affect several files within the MTGA codebase. These include:
frontend/src/components/CardSearch.tsx: This file will be modified to add the toggle switch and handle user interaction.frontend/src/components/CardSearch.css: This file will be updated to style the toggle switch and ensure it integrates seamlessly with the existing UI.frontend/src/pages/DeckBuilder.tsx: This file will be updated to integrate the CardSearch component with the collection filter functionality.internal/gui/deck_facade.go(or new collection facade): This file will be updated to handle the backend logic for filtering card search results based on the user's collection.
Acceptance Criteria: Ensuring Quality and Functionality
To ensure the collection filter toggle meets the required standards of quality and functionality, the following acceptance criteria must be met:
- The toggle must be visible in the Deck Builder card search.
- The "My Collection" filter must show only owned cards.
- The owned quantity must be displayed on filtered results.
- The toggle state must persist during the deck-building session.
- The system must gracefully handle situations where the collection is unavailable.
Related Information
This enhancement is part of the v1.3.1 daemon integration and depends on the completion of #598, #599, #600, and #601 (collection data layer).
Conclusion
The addition of a collection filter toggle to the MTGA Deck Builder represents a significant improvement in user experience and efficiency. By allowing players to quickly and easily filter card search results to show only cards they own, this feature streamlines the deck-building process and empowers players to make informed decisions about their deck construction. This enhancement promises to make deck building more enjoyable and less time-consuming, ultimately benefiting the entire MTGA community.
For more information on MTGA and deck building strategies, visit the official MTG website.