Stash work!
This commit is contained in:
@@ -42,6 +42,7 @@ namespace Data.CardSystem
|
||||
public event Action<CardData> OnCardCollected;
|
||||
public event Action<int> OnBoosterCountChanged;
|
||||
public event Action<CardData> OnPendingCardAdded;
|
||||
public event Action<CardData> OnPendingCardRemoved;
|
||||
public event Action<CardData> OnCardPlacedInAlbum;
|
||||
|
||||
internal override void OnManagedAwake()
|
||||
@@ -492,11 +493,28 @@ namespace Data.CardSystem
|
||||
#region Album System
|
||||
|
||||
/// <summary>
|
||||
/// Returns all cards waiting to be placed in the album
|
||||
/// Returns all pending reveal cards (cards waiting to be placed in album)
|
||||
/// </summary>
|
||||
public List<CardData> GetPendingRevealCards()
|
||||
{
|
||||
return new List<CardData>(_pendingRevealCards);
|
||||
return _pendingRevealCards;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a card from the pending reveal list and fire event.
|
||||
/// Called when a card starts being dragged to album slot.
|
||||
/// </summary>
|
||||
public bool RemoveFromPending(CardData card)
|
||||
{
|
||||
if (card == null) return false;
|
||||
|
||||
bool removed = _pendingRevealCards.Remove(card);
|
||||
if (removed)
|
||||
{
|
||||
OnPendingCardRemoved?.Invoke(card);
|
||||
Logging.Debug($"[CardSystemManager] Removed '{card.Name}' from pending reveal cards");
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -563,26 +581,37 @@ namespace Data.CardSystem
|
||||
|
||||
/// <summary>
|
||||
/// Marks a card as placed in the album
|
||||
/// Moves it from pending reveal to owned inventory
|
||||
/// Adds card to owned inventory and tracks as placed
|
||||
/// Note: Card may have already been removed from pending list during drag
|
||||
/// </summary>
|
||||
public void MarkCardAsPlaced(CardData card)
|
||||
{
|
||||
if (_pendingRevealCards.Remove(card))
|
||||
if (card == null)
|
||||
{
|
||||
// Add to owned inventory
|
||||
playerInventory.AddCard(card);
|
||||
|
||||
// Track as placed
|
||||
_placedInAlbumCardIds.Add(card.Id);
|
||||
|
||||
OnCardPlacedInAlbum?.Invoke(card);
|
||||
OnCardCollected?.Invoke(card);
|
||||
|
||||
Logging.Debug($"[CardSystemManager] Card '{card.Name}' placed in album and added to inventory.");
|
||||
Logging.Warning("[CardSystemManager] Attempted to place null card");
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to remove from pending (may already be removed during drag)
|
||||
bool wasInPending = _pendingRevealCards.Remove(card);
|
||||
|
||||
// Add to owned inventory (regardless of whether it was in pending)
|
||||
playerInventory.AddCard(card);
|
||||
|
||||
// Track as placed
|
||||
_placedInAlbumCardIds.Add(card.Id);
|
||||
|
||||
// Fire events
|
||||
OnCardPlacedInAlbum?.Invoke(card);
|
||||
OnCardCollected?.Invoke(card);
|
||||
|
||||
if (wasInPending)
|
||||
{
|
||||
Logging.Debug($"[CardSystemManager] Card '{card.Name}' removed from pending and added to inventory");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Warning($"[CardSystemManager] Attempted to place card '{card.Name}' but it wasn't in pending reveal list.");
|
||||
Logging.Debug($"[CardSystemManager] Card '{card.Name}' added to inventory (was already removed from pending)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user