Skip to content

Conversation

@Chiranthdv
Copy link

@Chiranthdv Chiranthdv commented Dec 10, 2025

Description

This PR adds a fully functional Multiplayer Memory Game along with an improved local 2-player Memory Game. The implementation introduces real-time synchronization using Socket.io, enhanced UI styling, correct card-flip behavior, and stable turn-based gameplay.

The feature includes:

  • Full multiplayer support (P1 vs P2) with synchronized game state
  • Local 2-player mode for offline play
  • Accurate player-role loading (P1 or P2) via localStorage
  • Real-time turn switching and match updates through WebSocket events
  • A UI rendering fix that ensures both flipped cards appear correctly before match checking
  • Grid loading fix for Player 2 by triggering state initialization on mount
  • Modern UI with Tailwind styling for the grid, cards, scoreboard, and turn highlights
  • Smooth animations for flips, matches, and turn transitions
  • Winner calculation and display for both game modes

This PR significantly enhances gameplay consistency, ensures correct state synchronization between players, and improves the overall user experience.


Key Features Added

🎮 Multiplayer Mode (Socket.io)

  • Real-time synchronized memory game
  • Flip events broadcast to opponent
  • Matches update scores live for both players
  • Server-managed turn switching
  • Full-state sync when a player joins late
  • Reset functionality over sockets

👥 Local 2-Player Mode

  • Turn-based card flipping
  • Accurate mismatch/match handling
  • Correct flip timing so the second card always shows
  • Independent score tracking
  • Clean visual feedback

🎨 UI & UX Improvements

  • Tailwind-based polished layout
  • Responsive grid size scaling
  • Styled scoreboard and turn indicators
  • Matched cards highlighted with animations
  • Loading state for when Player 2 waits for server sync

🛠️ Fixes Applied

  • Second card now always reveals before checking match (timing fix)
  • Player 2 grid not showing — fixed by forcing initialization on mount
  • Proper role assignment using localStorage
  • Consistent flip/match logic across both modes

Motivation & Context

This feature significantly increases the interactivity and playability of the app by offering both online multiplayer and local two-player gameplay. It also fixes several core visual and logic issues, such as:

  • Second card not showing before match evaluation
  • Player 2 not receiving initialized board
  • Turn desynchronization issues
  • UI inconsistencies between different grid sizes

The update creates a stable, enjoyable, and visually appealing memory game experience.

Fixes # (issue)


Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • UI improvement (non-breaking styling enhancement)
  • Breaking change (feature affecting existing functionality)
  • Documentation update

Additional Notes

Future enhancements may include:

  • Flip animations using Framer Motion
  • Sound effects for matches and flips
  • Animated winner screen
  • Spectator mode for multiplayer
  • Real-time chat inside the game room

This PR lays the foundation for all future multiplayer expansions.

@Chiranthdv
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant