Cadiac / sanuli

A finnish version of a popular word guessing game, written in Rust.
https://sanuli.fi
MIT License
64 stars 7 forks source link

Solving daily at midnight #7

Closed armatti closed 2 years ago

armatti commented 2 years ago

Started #15 before midnight, but finished it just past midnight. Now #16 is claimed to be solved. Words are from yesterday, but colors apparently based on today's solution.

Cadiac commented 2 years ago

:D yeah that's probably broken. Thanks for bringing that up - I should change it to save that as day #15 solution if this happens

khlsvr commented 2 years ago

fwiw in the original game if you open the daily before midnight and get it solved after midnight, you won't be able to play that new day's daily word either, but I don't remember it having any color bugs :)

Cadiac commented 2 years ago

This could simply be solved by ensuring that the solution gets written with the date of the game - not current date. There's also a second bug related to midnight:

If you have the daily word mode enabled, complete it at 23:00, and then refresh the page at 01:00, the previous days game is still shown until you switch to another game mode and come back to daily word.

This is regression from the state refactoring, a check is needed for if game mode is daily word and no game for today exists -> instead of rehydrating the previous game switch to today's game.

Cadiac commented 2 years ago

I think the original issue reported here was already fixed at the refactoring I merged during the weekend, and I couldn't replicate it anymore.

Previously the game was saved with current date which lead to this, but when the game was rehydrated the daily word was still picked from the daily words list. Now the game should be stored with correct date, and moving to classic game mode and back (or refresh) should restore the correct daily word.

I also created a fix for the second issue, and now if user has the daily word game open from before, date has changed and browser is refreshed, the new current date's game should be shown. I deployed this just before midnight.

Cadiac commented 2 years ago

Verified working - I started a word at 23:59, completed it 00:01 and after refresh I was able to also complete the todays word.

When I completed the word from yesterday the UI still had title "Päivän sanuli #19" (n+1) as the top title when the day had already changed, but everything gets saved correctly and I don't think adding logic for that is worth it.