fix: clear hover state on turn changes and game transitions
Clear playerHovers state in three scenarios to prevent stale hover avatars: 1. **Turn switching (mismatch)**: When a player misses a match and turn switches to next player, clear the previous player's hover state so their avatar doesn't show on the last card they hovered from their previous turn. 2. **Starting new game**: Clear all hover state when starting fresh game to ensure clean initial state. 3. **Returning to setup**: Clear all hover state when going back to setup phase to prevent stale hovers from previous game sessions. This fixes the issue where players would see their opponent's (or their own) hover avatar stuck on a card at the start of a turn, even though no hovering has occurred yet in the current turn. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,11 @@ export class MatchingGameValidator
|
||||
flippedCards: newFlippedCards,
|
||||
isProcessingMove: true, // Keep processing state so no more cards can be flipped
|
||||
showMismatchFeedback: true,
|
||||
// Clear hover state for the player whose turn is ending
|
||||
playerHovers: {
|
||||
...state.playerHovers,
|
||||
[state.currentPlayer]: null,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -259,6 +264,8 @@ export class MatchingGameValidator
|
||||
// Clear any paused game state (starting fresh)
|
||||
pausedGamePhase: undefined,
|
||||
pausedGameState: undefined,
|
||||
// Clear hover state when starting new game
|
||||
playerHovers: {},
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -356,6 +363,7 @@ export class MatchingGameValidator
|
||||
isProcessingMove: false,
|
||||
showMismatchFeedback: false,
|
||||
lastMatchedPair: null,
|
||||
playerHovers: {}, // Clear hover state when returning to setup
|
||||
// Preserve configuration - players can modify in setup
|
||||
// gameType, difficulty, turnTimer stay as-is
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user