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

@@ -85,7 +85,7 @@ namespace UI.CardSystem.StateMachine.States
context.RootTransform.localRotation = _originalLocalRotation;
// Transition back to placed state
context.StateMachine.ChangeState("PlacedInSlotState");
context.StateMachine.ChangeState(CardStateNames.PlacedInSlot);
});
}
else
@@ -95,7 +95,7 @@ namespace UI.CardSystem.StateMachine.States
context.RootTransform.SetParent(_originalParent, true);
context.RootTransform.localPosition = _originalLocalPosition;
context.RootTransform.localRotation = _originalLocalRotation;
context.StateMachine.ChangeState("PlacedInSlotState");
context.StateMachine.ChangeState(CardStateNames.PlacedInSlot);
}
}

View File

@@ -87,7 +87,7 @@ namespace UI.CardSystem.StateMachine.States
{
Logging.Warning("[CardDraggingRevealedState] No target slot set - cannot place card");
// Return to corner
_context.StateMachine.ChangeState("PendingFaceDownState");
_context.StateMachine.ChangeState(CardStateNames.PendingFaceDown);
return;
}
@@ -95,11 +95,11 @@ namespace UI.CardSystem.StateMachine.States
var albumPage = _context.AlbumViewPage;
if (albumPage == null)
{
Logging.Warning("[CardDraggingRevealedState] AlbumViewPage not found - placing immediately");
Logging.Warning("[CardDraggingRevealedState] AlbumViewPage not injected - placing immediately");
TransitionToPlacement(_context);
return;
}
// Check if page is still flipping
if (albumPage.IsPageFlipping)
{
@@ -146,7 +146,7 @@ namespace UI.CardSystem.StateMachine.States
var card = ctx.GetComponent<Card>();
if (card != null)
{
var placedState = card.GetStateComponent<CardPlacedInSlotState>("PlacedInSlotState");
var placedState = card.GetStateComponent<CardPlacedInSlotState>(CardStateNames.PlacedInSlot);
if (placedState != null)
{
placedState.SetPlacementInfo(_targetSlot);
@@ -155,7 +155,7 @@ namespace UI.CardSystem.StateMachine.States
// Transition to PlacedInSlotState
// The state will handle animation and finalization in OnEnterState
ctx.StateMachine.ChangeState("PlacedInSlotState");
ctx.StateMachine.ChangeState(CardStateNames.PlacedInSlot);
}
private void OnDisable()

View File

@@ -58,13 +58,13 @@ namespace UI.CardSystem.StateMachine.States
{
context.Animator.PlayShrink(context.OriginalScale, onComplete: () =>
{
context.StateMachine.ChangeState("RevealedState");
context.StateMachine.ChangeState(CardStateNames.Revealed);
});
}
else
{
// Fallback if no animator
context.StateMachine.ChangeState("RevealedState");
context.StateMachine.ChangeState(CardStateNames.Revealed);
}
}

View File

@@ -162,12 +162,12 @@ namespace UI.CardSystem.StateMachine.States
if (newRarity == CardRarity.Legendary)
{
// Show special enlarged legendary presentation, await click to shrink to revealed
_context.StateMachine.ChangeState("EnlargedLegendaryRepeatState");
_context.StateMachine.ChangeState(CardStateNames.EnlargedLegendaryRepeat);
}
else
{
// Treat as NEW at higher rarity (enlarged with NEW visuals handled there)
_context.StateMachine.ChangeState("EnlargedNewState");
_context.StateMachine.ChangeState(CardStateNames.EnlargedNew);
}
}
}
@@ -182,7 +182,7 @@ namespace UI.CardSystem.StateMachine.States
// Transition to EnlargedNewState (card is already enlarged, will show NEW badge)
// State will query fresh collection data to determine if truly new
_context.StateMachine.ChangeState("EnlargedNewState");
_context.StateMachine.ChangeState(CardStateNames.EnlargedNew);
}
public void OnCardClicked(CardContext context)
@@ -196,7 +196,7 @@ namespace UI.CardSystem.StateMachine.States
{
context.Animator.PlayShrink(context.OriginalScale, onComplete: () =>
{
context.StateMachine.ChangeState("RevealedState");
context.StateMachine.ChangeState(CardStateNames.Revealed);
});
}
else

View File

@@ -121,7 +121,7 @@ namespace UI.CardSystem.StateMachine.States
if (isNew)
{
// New card - show "NEW" badge and enlarge
_context.StateMachine.ChangeState("EnlargedNewState");
_context.StateMachine.ChangeState(CardStateNames.EnlargedNew);
}
else if (_context.CardData != null && _context.CardData.Rarity == AppleHills.Data.CardSystem.CardRarity.Legendary)
{
@@ -131,12 +131,12 @@ namespace UI.CardSystem.StateMachine.States
{
Data.CardSystem.CardSystemManager.Instance.AddCardToInventoryDelayed(_context.CardData);
}
_context.StateMachine.ChangeState("RevealedState");
_context.StateMachine.ChangeState(CardStateNames.Revealed);
}
else
{
// Repeat card - show progress toward upgrade
_context.StateMachine.ChangeState("EnlargedRepeatState");
_context.StateMachine.ChangeState(CardStateNames.EnlargedRepeat);
}
}

View File

@@ -56,11 +56,11 @@ namespace UI.CardSystem.StateMachine.States
{
if (_isFlipping) return true; // Already handling
// Step 1: Find AlbumViewPage
AlbumViewPage albumPage = Object.FindFirstObjectByType<AlbumViewPage>();
// Get AlbumViewPage from context (injected dependency)
var albumPage = context.AlbumViewPage;
if (albumPage == null)
{
Logging.Warning("[CardPendingFaceDownState] AlbumViewPage not found!");
Logging.Warning("[CardPendingFaceDownState] AlbumViewPage not injected!");
return true;
}
@@ -143,11 +143,11 @@ namespace UI.CardSystem.StateMachine.States
private void OnFlipComplete()
{
// Transition to dragging revealed state
// Pass target slot to next state (it will query AlbumViewPage for flip status)
// Pass target slot to next state (it will query AlbumService for flip status)
var card = _context.GetComponent<Card>();
if (card != null)
{
var draggingState = card.GetStateComponent<CardDraggingRevealedState>("DraggingRevealedState");
var draggingState = card.GetStateComponent<CardDraggingRevealedState>(CardStateNames.DraggingRevealed);
if (draggingState != null)
{
draggingState.SetTargetSlot(_targetSlot);
@@ -161,7 +161,7 @@ namespace UI.CardSystem.StateMachine.States
}
}
_context.StateMachine.ChangeState("DraggingRevealedState");
_context.StateMachine.ChangeState(CardStateNames.DraggingRevealed);
}
private void OnDisable()

View File

@@ -1,4 +1,4 @@
using Core;
using Core;
using Core.SaveLoad;
using Data.CardSystem;
using UnityEngine;
@@ -143,7 +143,7 @@ namespace UI.CardSystem.StateMachine.States
{
// Click to enlarge when in album
Logging.Debug($"[CardPlacedInSlotState] Card clicked in slot, transitioning to enlarged state");
context.StateMachine.ChangeState("AlbumEnlargedState");
context.StateMachine.ChangeState(CardStateNames.AlbumEnlarged);
}
}
}

View File

@@ -34,7 +34,7 @@ namespace UI.CardSystem.StateMachine.States
}
// Show appropriate idle badge unless suppressed
if (_context.SuppressRevealBadges)
if (_context.BoosterContext.SuppressRevealBadges)
{
if (newCardIdleBadge != null) newCardIdleBadge.SetActive(false);
if (repeatCardIdleBadge != null) repeatCardIdleBadge.SetActive(false);
@@ -61,7 +61,7 @@ namespace UI.CardSystem.StateMachine.States
}
// Fire reveal flow complete event (signals booster page that this card is done)
_context.NotifyRevealComplete();
_context.BoosterContext.NotifyRevealComplete();
}
private void OnDisable()