Working refactor of cleaned up card structure

This commit is contained in:
Michal Pikulski
2025-11-18 01:03:45 +01:00
parent 689e177c99
commit 64c304bb6d
18 changed files with 163 additions and 73 deletions

View File

@@ -24,9 +24,9 @@ namespace UI.CardSystem.StateMachine
public CardData CardData => context?.CardData;
// State inspection properties for booster flow
public bool IsIdle => GetCurrentStateName() == "IdleState";
public bool IsIdle => GetCurrentStateName() == CardStateNames.Idle;
public bool IsRevealing => !IsIdle && !IsComplete;
public bool IsComplete => context?.HasCompletedReveal ?? false;
public bool IsComplete => context?.BoosterContext.HasCompletedReveal ?? false;
// Event fired when this card is successfully placed into an AlbumCardSlot
public event System.Action<Card, AlbumCardSlot> OnPlacedInAlbumSlot;
@@ -89,23 +89,23 @@ namespace UI.CardSystem.StateMachine
// Default behavior for states that don't implement custom drag end
string current = GetCurrentStateName();
if (current == "DraggingState")
if (current == CardStateNames.Dragging)
{
if (CurrentSlot is AlbumCardSlot albumSlot)
{
Logging.Debug($"[Card] Dropped in album slot, transitioning to PlacedInSlotState");
var placedState = GetStateComponent<States.CardPlacedInSlotState>("PlacedInSlotState");
var placedState = GetStateComponent<States.CardPlacedInSlotState>(CardStateNames.PlacedInSlot);
if (placedState != null)
{
placedState.SetParentSlot(albumSlot);
}
ChangeState("PlacedInSlotState");
ChangeState(CardStateNames.PlacedInSlot);
OnPlacedInAlbumSlot?.Invoke(this, albumSlot);
}
else
{
Logging.Debug("[Card] Dropped outside valid slot, returning to RevealedState");
ChangeState("RevealedState");
ChangeState(CardStateNames.Revealed);
}
}
}
@@ -137,7 +137,7 @@ namespace UI.CardSystem.StateMachine
/// </summary>
public void SetupForBoosterReveal(CardData data, bool isNew)
{
SetupCard(data, "IdleState");
SetupCard(data, CardStateNames.Idle);
SetDraggingEnabled(false); // Booster cards cannot be dragged
}
@@ -147,11 +147,11 @@ namespace UI.CardSystem.StateMachine
/// </summary>
public void SetupForAlbumSlot(CardData data, AlbumCardSlot slot)
{
SetupCard(data, "PlacedInSlotState");
SetupCard(data, CardStateNames.PlacedInSlot);
SetDraggingEnabled(false); // Cards in slots cannot be dragged out
// Set the parent slot on the PlacedInSlotState
var placedState = GetStateComponent<States.CardPlacedInSlotState>("PlacedInSlotState");
var placedState = GetStateComponent<States.CardPlacedInSlotState>(CardStateNames.PlacedInSlot);
if (placedState != null)
{
placedState.SetParentSlot(slot);
@@ -165,7 +165,7 @@ namespace UI.CardSystem.StateMachine
public void SetupForAlbumPending()
{
// Start with no data; state will assign when dragged
SetupCard(null, "PendingFaceDownState");
SetupCard(null, CardStateNames.PendingFaceDown);
SetDraggingEnabled(true);
}