Kind of working booster packs
This commit is contained in:
@@ -16,7 +16,6 @@ namespace AppleHills.Tests
|
||||
public class CardSystemTester : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private CardSystemManager cardSystemManager;
|
||||
[SerializeField] private CardAlbumUI cardAlbumUI;
|
||||
|
||||
[Header("Test Settings")]
|
||||
@@ -32,16 +31,10 @@ namespace AppleHills.Tests
|
||||
private void Awake()
|
||||
{
|
||||
// Auto-find references if needed
|
||||
if (cardSystemManager == null)
|
||||
cardSystemManager = FindAnyObjectByType<CardSystemManager>();
|
||||
|
||||
if (cardAlbumUI == null)
|
||||
cardAlbumUI = FindAnyObjectByType<CardAlbumUI>();
|
||||
|
||||
// Log missing references
|
||||
if (cardSystemManager == null)
|
||||
Debug.LogError("CardSystemTester: No CardSystemManager found in the scene!");
|
||||
|
||||
if (cardAlbumUI == null)
|
||||
Debug.LogError("CardSystemTester: No CardAlbumUI found in the scene!");
|
||||
}
|
||||
@@ -54,10 +47,11 @@ namespace AppleHills.Tests
|
||||
// Refresh the debug information displayed in the inspector
|
||||
private void RefreshDebugInfo()
|
||||
{
|
||||
if (cardSystemManager != null)
|
||||
// Access CardSystemManager through the singleton Instance
|
||||
if (CardSystemManager.Instance != null)
|
||||
{
|
||||
currentBoosterCount = cardSystemManager.GetBoosterPackCount();
|
||||
totalCardsInCollection = cardSystemManager.GetCardInventory().GetAllCards().Count;
|
||||
currentBoosterCount = CardSystemManager.Instance.GetBoosterPackCount();
|
||||
totalCardsInCollection = CardSystemManager.Instance.GetCardInventory().GetAllCards().Count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +59,10 @@ namespace AppleHills.Tests
|
||||
// Custom editor buttons for testing
|
||||
public void AddBoosterPacks()
|
||||
{
|
||||
if (cardSystemManager != null)
|
||||
// Access CardSystemManager through the singleton Instance
|
||||
if (CardSystemManager.Instance != null)
|
||||
{
|
||||
cardSystemManager.AddBoosterPack(boosterPacksToAdd);
|
||||
CardSystemManager.Instance.AddBoosterPack(boosterPacksToAdd);
|
||||
lastActionMessage = $"Added {boosterPacksToAdd} booster pack(s)";
|
||||
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
|
||||
RefreshDebugInfo();
|
||||
@@ -135,10 +130,11 @@ namespace AppleHills.Tests
|
||||
|
||||
public void GenerateRandomCards()
|
||||
{
|
||||
if (cardSystemManager != null)
|
||||
// Access CardSystemManager through the singleton Instance
|
||||
if (CardSystemManager.Instance != null)
|
||||
{
|
||||
int cardsAdded = 0;
|
||||
List<CardDefinition> allDefinitions = cardSystemManager.GetAllCardDefinitions();
|
||||
List<CardDefinition> allDefinitions = CardSystemManager.Instance.GetAllCardDefinitions();
|
||||
|
||||
if (allDefinitions.Count == 0)
|
||||
{
|
||||
@@ -154,7 +150,7 @@ namespace AppleHills.Tests
|
||||
|
||||
// Create a card data instance and add it to inventory
|
||||
CardData newCard = randomDef.CreateCardData();
|
||||
cardSystemManager.GetCardInventory().AddCard(newCard);
|
||||
CardSystemManager.Instance.GetCardInventory().AddCard(newCard);
|
||||
cardsAdded++;
|
||||
}
|
||||
|
||||
@@ -166,21 +162,17 @@ namespace AppleHills.Tests
|
||||
|
||||
public void ClearAllCards()
|
||||
{
|
||||
if (cardSystemManager != null)
|
||||
// Access CardSystemManager through the singleton Instance
|
||||
if (CardSystemManager.Instance != null)
|
||||
{
|
||||
int count = cardSystemManager.GetCardInventory().GetAllCards().Count;
|
||||
cardSystemManager.GetCardInventory().ClearAllCards();
|
||||
int count = CardSystemManager.Instance.GetCardInventory().GetAllCards().Count;
|
||||
CardSystemManager.Instance.GetCardInventory().ClearAllCards();
|
||||
lastActionMessage = $"Cleared {count} cards from inventory";
|
||||
Logging.Debug($"[CardSystemTester] {lastActionMessage}");
|
||||
RefreshDebugInfo();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -196,6 +188,9 @@ namespace AppleHills.Tests
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Test Actions", EditorStyles.boldLabel);
|
||||
|
||||
// Only enable buttons when in play mode
|
||||
GUI.enabled = Application.isPlaying;
|
||||
|
||||
if (GUILayout.Button("Add Booster Packs"))
|
||||
{
|
||||
tester.AddBoosterPacks();
|
||||
@@ -227,6 +222,13 @@ namespace AppleHills.Tests
|
||||
{
|
||||
tester.ClearAllCards();
|
||||
}
|
||||
|
||||
// If not in play mode, show a hint
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
GUI.enabled = true;
|
||||
EditorGUILayout.HelpBox("Enter Play Mode to use these testing functions.", MessageType.Info);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user