Skip to content

feat: added Show Solution toggle to Game Over screen for Issue #2#10

Open
ShubhamSingh-online wants to merge 4 commits into
coder-zs-cse:mainfrom
ShubhamSingh-online:main
Open

feat: added Show Solution toggle to Game Over screen for Issue #2#10
ShubhamSingh-online wants to merge 4 commits into
coder-zs-cse:mainfrom
ShubhamSingh-online:main

Conversation

@ShubhamSingh-online

Copy link
Copy Markdown

Closes #2

Description of Changes:

  • Added a toggle button to the Game Over screen (game-result.tsx).
  • Conditionally renders a 5x5 grid preview of the hidden shape solution when the user clicks the button.
  • Passed the solution matrix down from the parent state.

Testing Done:

  • Forced a "lost" game state locally and verified the button toggles the text.
  • Verified the grid renders the correct layout based on the passed data.

@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

@ShubhamSingh-online is attempting to deploy a commit to the coderzs' projects Team on Vercel.

A member of the Team first needs to authorize it.

@coder-zs-cse

coder-zs-cse commented May 15, 2026

Copy link
Copy Markdown
Owner

@ShubhamSingh-online Please attach a video of how the solution button interaction looks like.

@ShubhamSingh-online

Copy link
Copy Markdown
Author
Shabble.-.Google.Chrome.2026-05-15.23-40-22.mp4

Hi @coder-zs-cse, here is the screen recording showing the UI toggle and the grid!

@coder-zs-cse

coder-zs-cse commented May 16, 2026

Copy link
Copy Markdown
Owner

You seem to have completely misunderstood the requirements. I don't see the solution getting displayed at all. For the correct demo you will have to show the following things

  1. First play the game, exhaust your 15 attempts and make the final guess.
  2. currently the game will display something like this
image
  1. You need to put a green button just below "Game Over!" text "Reveal Solution"
  2. Clicking on this button will make a api call to backend and fetch the solution from the DB.
  3. The solution will be displayed in the exact same board which is the main gameplay board
  4. The "Reveal Solution" button will change to "Hide Solution" and then you can click on it, to toggle back your gameplay board just as an option to see back your inputs

@ShubhamSingh-online

Copy link
Copy Markdown
Author

Hi @coder-zs-cse,

I have the solution ready to implement the toggle logic on the main board exactly as you requested! However, I am currently blocked from testing it via the steps you provided because the local development database appears to be down.

As shown in the attached screen recording, I am running into two blockers when trying to play the game naturally:

  1. Submitting a guess hangs on "Checking..." and throws a "Database is inactive" error, preventing me from exhausting the 15 attempts.

  2. Clicking a tile before making a guess immediately consumes a hint (the counter goes down), but the hint value fails to render on the board.

Because I cannot reach the "Game Over" screen naturally under these conditions, how would you prefer I proceed? 1. I can wait until the development database is back online to record the full gameplay loop.
2. I can temporarily mock the game state to lost locally. This will let me bypass the broken gameplay loop and instantly record a demo verifying that the Game Over toggle UI works exactly as you requested.

Let me know which option you prefer!

0517.mp4

@coder-zs-cse

Copy link
Copy Markdown
Owner

have you set the postgres url in the .env file? You have to locally start a postgresql database server. or if you are uncomfortable doing that, you can login to Neon.com and get a free postgresql database url running on cloud.

@ShubhamSingh-online

Copy link
Copy Markdown
Author

Hi @coder-zs-cse,

I have the frontend UI fully built and ready to go for this feature. I’ve added the "Reveal Solution" / "Hide Solution" button to the Game Over screen, and wired it up with the state logic to swap the main board when clicked.

While testing the API call (Step 4), I noticed that the backend endpoint to fetch the solution isn't currently set up in the project yet. Before I open the Pull Request, how would you like me to handle this?

  1. I can push my frontend code as-is. (I added a safe fallback so if the API fails, it just shows a toast error instead of crashing the app, waiting for the backend to be built).
  2. Or, if you would like me to handle the full-stack implementation, I would be happy to build out the Next.js API route (e.g., /api/puzzle/solution) to query the database and return the array so the whole feature works end-to-end!

Let me know what works best for the project!

@coder-zs-cse

Copy link
Copy Markdown
Owner

yes @ShubhamSingh-online this is a full stack feature requirement. you have to implement the backend route to fetch the solution

@ShubhamSingh-online

Copy link
Copy Markdown
Author

Hi @coder-zs-cse,

The full-stack implementation is complete and tested! Per your instruction, I built out the backend API route so this feature works perfectly end-to-end.

Here is exactly what is included in this PR:

  • Frontend: Added the "Reveal Solution" / "Hide Solution" button to the Game Over screen and wired up the toggle state.
  • Backend: Created the Next.js API route at app/api/puzzle/solution/route.ts.
  • Data Parsing: The backend successfully queries the DailyPuzzle table using Prisma, extracts the coordinate array from the JSON board, maps it into a clean 2D grid, and sends it to the frontend.
  • Safety: Protected the .env.example template so the repository stays clean.

I have attached a screen recording below showing the feature working locally! Let me know if you need any adjustments, otherwise it is ready for review.

Shabble.-.Google.Chrome.2026-05-19.23-43-26.mp4

@coder-zs-cse

coder-zs-cse commented May 20, 2026

Copy link
Copy Markdown
Owner

hmm ... doesn't look like the solution is correct. Why are the bottom hints showing zeroes when the shape is at the bottom

@ShubhamSingh-online

Copy link
Copy Markdown
Author

Great catch, thanks for spotting that! It looks like there is a coordinate mapping mismatch between how the database stores the shape and how the frontend grid renders it (likely an inverted Y-axis or swapped row/col). I am looking into the logic now and will push a fix shortly!

@ShubhamSingh-online

Copy link
Copy Markdown
Author

Hi @coder-zs-cse, thanks again for catching that! The coordinate mismatch has been successfully fixed.

The issue was a standard 2D matrix mapping bug where the backend API was assigning coordinates inverted relative to the frontend layout logic (mapping the vertical Y-axis values to horizontal indexes). I have restored the proper index mapping (solutionGrid[coord.y][coord.x]) and forced dynamic rendering on the API route to ensure Next.js clears out any static caching.

I've verified it locally against the daily puzzle metrics, and the grid solution highlights now align perfectly with both the column and row hints. Ready for review!

Shabble.-.Google.Chrome.2026-05-20.23-51-08.mp4

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.

Show solution feature

2 participants