5.8 KiB
5.8 KiB
Card System Integration and Testing Guide
Overview
This document outlines the integration between the data and UI layers of the Apple Hills card collection system, as well as the testing tools available for development purposes.
Architecture Summary
The card system follows a clean separation of concerns:
-
Data Layer (Assets/Scripts/Data/CardSystem/)
CardSystemManager: Singleton for managing card data, booster packs, and collectionCardInventory: Player's collection of cards and booster packsCardData: Runtime instance of a collected cardCardDefinition: ScriptableObject template defining card propertiesCardVisualConfig: Visual settings for cards based on rarity/zone
-
UI Layer (Assets/Scripts/UI/CardSystem/)
CardAlbumUI: Main controller for the card UI systemUIPageController: Stack-based navigation systemUIPage: Base class for UI pages with transition animations- Page Components:
CardMenuPage: Main menu for the card systemAlbumViewPage: Grid display of collected cards with filteringBoosterOpeningPage: Interactive card reveal experience
CardUIElement: Individual card visual representationBoosterNotificationDot: UI element showing booster pack counts
Integration Points
Initialization Process
CardSystemManagerinitializes during the bootstrap process usingBootCompletionService- UI components register with
BootCompletionService.RegisterInitAction()for post-boot initialization - UI components access card data through
CardSystemManager.Instance
Data Flow
-
Card Collection:
CardSystemManagermanages the player'sCardInventory- Cards are added via
AddCardToInventory() - Card collection triggers
OnCardCollectedevent
-
Booster Packs:
- Added via
CardSystemManager.AddBoosterPack() - Opened via
CardSystemManager.OpenBoosterPack() - Booster count changes trigger
OnBoosterCountChangedevent - Opening boosters triggers
OnBoosterOpenedevent
- Added via
-
Card Display:
CardUIElementdisplays a card usingSetupCard(cardData)AlbumViewPagedisplays cards in a grid with filtering optionsBoosterOpeningPagehandles interactive card reveals
Event System
Key events that connect data and UI layers:
OnBoosterCountChanged: Triggered when booster count changesOnBoosterOpened: Triggered when a booster is openedOnCardCollected: Triggered when a new card is added to collectionOnCardRarityUpgraded: Triggered when duplicates upgrade a card's rarity
Testing Tool: CardSystemTester
The CardSystemTester provides a simple interface for testing the card system without requiring full game integration.
Features
- Adding booster packs
- Opening the card menu
- Opening booster packs
- Browsing the album view
- Generating random test cards
- Clearing the card collection
Usage
- Add
CardSystemTestercomponent to a GameObject in your test scene - Reference the
CardAlbumUIcomponent - Enter Play mode and use the inspector buttons
- All buttons are disabled in edit mode
Implementation Notes
public class CardSystemTester : MonoBehaviour
{
// Only need reference to CardAlbumUI, the CardSystemManager is accessed via singleton
[SerializeField] private CardAlbumUI cardAlbumUI;
// Other variables for test configuration
[SerializeField] [Range(1, 10)] private int boosterPacksToAdd = 3;
[SerializeField] [Range(1, 100)] private int cardsToGenerate = 10;
// All operations use CardSystemManager.Instance
public void AddBoosterPacks() {
CardSystemManager.Instance.AddBoosterPack(boosterPacksToAdd);
// Other operations...
}
// Uses CardAlbumUI to simulate UI interactions
public void SimulateBackpackClick() {
// Trigger the backpack button's onClick event
}
// Additional test methods...
}
Test Scene Setup
- Create a new scene or use an existing test scene
- Add a Canvas with proper UI configuration
- Add the CardSystem prefab (containing CardAlbumUI)
- Add the CardSystemTester component
- Make sure you have card definitions configured
Current Implementation Status
-
Complete:
- Core data management through
CardSystemManager - Card collection and inventory management
- Basic UI navigation system
- Booster pack opening flow
- Album view with filtering
- Core data management through
-
Added API Methods:
GetAllCardDefinitions(): Returns list of all card definitionsGetCardInventory(): Returns reference to player's card inventoryClearAllCards(): Resets the player's collection- Various utility methods for filtering and statistics
-
UI Improvements:
- Simplified card display in album view
- Properly integrated card reveal animations
- Back button functionality for all pages
Known Issues and Considerations
- Performance: Large collections may require optimization
- Save System: Currently not implemented, needs integration with game save system
- Card Definition Loading: Ensure card definitions are loaded before use
- Testing Workflow: Test specific state scenarios using the CardSystemTester
- Animation Timing: May need adjustment for smoother experience
Next Steps
- Implement save/load system for card collection
- Add collection statistics display
- Implement rarity-specific effects for card reveals
- Create more comprehensive test coverage
Technical References
- Bootstrap system: Use
BootCompletionService.RegisterInitAction(InitializePostBoot)for initialization - Data access: Always use
CardSystemManager.Instancefor data access - Page navigation: Use
UIPageController.Instance.PushPage()andPopPage() - Card UI: Use
CardUIElement.SetupCard()to configure card display