Almost working card state machine
This commit is contained in:
@@ -51,13 +51,10 @@ namespace UI.CardSystem.Testing
|
||||
_originalAnchoredPosition = rectTransform.anchoredPosition;
|
||||
}
|
||||
|
||||
// Subscribe to all card events
|
||||
// Subscribe to card events (new simplified event model)
|
||||
if (_cardContext != null)
|
||||
{
|
||||
_cardContext.OnFlipComplete += OnCardFlipComplete;
|
||||
_cardContext.OnCardDismissed += OnCardDismissed;
|
||||
_cardContext.OnCardInteractionComplete += OnCardInteractionComplete;
|
||||
_cardContext.OnUpgradeTriggered += OnCardUpgradeTriggered;
|
||||
_cardContext.OnRevealFlowComplete += OnCardRevealFlowComplete;
|
||||
}
|
||||
|
||||
// Subscribe to drag events to ensure card snaps back when released
|
||||
@@ -89,7 +86,7 @@ namespace UI.CardSystem.Testing
|
||||
// Initialize card with test data
|
||||
if (testCard != null && testCardData != null && _cardContext != null)
|
||||
{
|
||||
_cardContext.SetupCard(testCardData, isNew: true, repeatCount: 0);
|
||||
_cardContext.SetupCard(testCardData);
|
||||
}
|
||||
|
||||
LogEvent("Card Test Scene Initialized");
|
||||
@@ -185,37 +182,37 @@ namespace UI.CardSystem.Testing
|
||||
{
|
||||
if (_cardContext == null) return;
|
||||
|
||||
_cardContext.IsNewCard = true;
|
||||
_cardContext.RepeatCardCount = 0;
|
||||
// NOTE: These properties no longer exist in CardContext (removed to prevent stale data)
|
||||
// States now query CardSystemManager directly
|
||||
// This test controller manually manipulates state machine for testing only
|
||||
_cardContext.IsClickable = true;
|
||||
|
||||
TransitionToIdleState();
|
||||
LogEvent("Simulating NEW CARD flow - click card to flip");
|
||||
LogEvent("Simulating NEW CARD flow - click card to flip (test bypasses collection checks)");
|
||||
}
|
||||
|
||||
public void SimulateRepeatCardFlow()
|
||||
{
|
||||
if (_cardContext == null) return;
|
||||
|
||||
int repeatCount = Mathf.RoundToInt(repeatCountSlider.value);
|
||||
_cardContext.IsNewCard = false;
|
||||
_cardContext.RepeatCardCount = repeatCount;
|
||||
// NOTE: RepeatCardCount removed from CardContext
|
||||
// Test directly transitions to state for visual testing
|
||||
_cardContext.IsClickable = true;
|
||||
|
||||
TransitionToIdleState();
|
||||
LogEvent($"Simulating REPEAT CARD flow ({repeatCount}/5) - click card to flip");
|
||||
LogEvent($"Simulating REPEAT CARD flow (test bypasses collection checks)");
|
||||
}
|
||||
|
||||
public void SimulateUpgradeFlow()
|
||||
{
|
||||
if (_cardContext == null) return;
|
||||
|
||||
_cardContext.IsNewCard = false;
|
||||
_cardContext.RepeatCardCount = 5; // Trigger upgrade
|
||||
// NOTE: WillTriggerUpgrade removed from CardContext
|
||||
// Test directly transitions to state for visual testing
|
||||
_cardContext.IsClickable = true;
|
||||
|
||||
TransitionToIdleState();
|
||||
LogEvent("Simulating UPGRADE flow (5/5) - click card to flip and auto-upgrade");
|
||||
LogEvent("Simulating UPGRADE flow (test bypasses collection checks)");
|
||||
}
|
||||
|
||||
public void TestDragAndSnap()
|
||||
@@ -240,9 +237,6 @@ namespace UI.CardSystem.Testing
|
||||
bool isNew = isNewToggle != null && isNewToggle.isOn;
|
||||
int repeatCount = repeatCountSlider != null ? Mathf.RoundToInt(repeatCountSlider.value) : 0;
|
||||
|
||||
_cardContext.IsNewCard = isNew;
|
||||
_cardContext.RepeatCardCount = repeatCount;
|
||||
|
||||
// Apply rarity if needed
|
||||
if (rarityDropdown != null && testCardData != null)
|
||||
{
|
||||
@@ -364,24 +358,9 @@ namespace UI.CardSystem.Testing
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void OnCardFlipComplete(CardContext context)
|
||||
private void OnCardRevealFlowComplete(CardContext context)
|
||||
{
|
||||
LogEvent($"Event: OnFlipComplete - IsNew={context.IsNewCard}, RepeatCount={context.RepeatCardCount}");
|
||||
}
|
||||
|
||||
private void OnCardDismissed(CardContext context)
|
||||
{
|
||||
LogEvent("Event: OnCardDismissed");
|
||||
}
|
||||
|
||||
private void OnCardInteractionComplete(CardContext context)
|
||||
{
|
||||
LogEvent("Event: OnCardInteractionComplete");
|
||||
}
|
||||
|
||||
private void OnCardUpgradeTriggered(CardContext context)
|
||||
{
|
||||
LogEvent($"Event: OnUpgradeTriggered - New Rarity={context.CardData?.Rarity}");
|
||||
LogEvent($"Event: OnRevealFlowComplete - Card reveal complete for {context.CardData?.Name}");
|
||||
}
|
||||
|
||||
private void OnCardDragStarted(UI.DragAndDrop.Core.DraggableObject draggable)
|
||||
@@ -459,10 +438,7 @@ namespace UI.CardSystem.Testing
|
||||
// Unsubscribe from events
|
||||
if (_cardContext != null)
|
||||
{
|
||||
_cardContext.OnFlipComplete -= OnCardFlipComplete;
|
||||
_cardContext.OnCardDismissed -= OnCardDismissed;
|
||||
_cardContext.OnCardInteractionComplete -= OnCardInteractionComplete;
|
||||
_cardContext.OnUpgradeTriggered -= OnCardUpgradeTriggered;
|
||||
_cardContext.OnRevealFlowComplete -= OnCardRevealFlowComplete;
|
||||
}
|
||||
|
||||
if (testCard != null)
|
||||
|
||||
Reference in New Issue
Block a user