Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LocalStorage #36

Open
ovidiubute opened this issue May 30, 2017 · 1 comment
Open

Implement LocalStorage #36

ovidiubute opened this issue May 30, 2017 · 1 comment

Comments

@ovidiubute
Copy link
Member

ovidiubute commented May 30, 2017

  • Game progress should be saved to LocalStorage
  • This will allow users to continue the game even if they close their browser/tab
  • What needs to be saved?
    • Some sort of user id, we don't want a full login system yet so we'll have to generate a UUID for him and save it
    • It's 2017, we don't care about browsers not supporting LocalStorage, so no cookie workarounds 😄
    • The game needs to be paused when leaving the app and the state must be persisted
      • This is required because otherwise you will reload the game and the timer will start immediately and it will be confusing
    • Every move a user makes needs to be saved
      • This will be easier in the long term than just saving a snapshot of the game, we can implement replays for example or even (wait for it) have some sort of async multiplayer mode
      • This needs to be light so a format like [ [0,'r'], [1, 'l'], [3, 'u'], [2, 'd'] ] should be used (tile index 0 to 14 and direction 'r' = 'right', etc...
  • On new game we can clear the history until we have a backend to save them (way long term)
  • We'll need full 100% unit-test coverage for this functionality because it will be very easy to break stuff and it's very hard to debug local storage issues
  • Also need to take care of users having inconsistent data in local storage due to application bugs
  • There are literally dozens of LocalStorage libs out there, need to research on which one is the lightest and suits our needs
@ovidiubute
Copy link
Member Author

Update after 6 years (how time flies):

  • Hitting reload will make you lose your progress, this sucks. Have a confirmation dialog (browser dialog is good enough).
  • No need to use a LocalStorage lib, just use the API directly
  • Hitting reload should check if there is a game currently in progress, and if yes, load it, but start in pause mode so the timer doesn't just keep going
  • We don't need a user id, a lot has changed in 6 years, people hate tracking nowadays 🥲

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

No branches or pull requests

1 participant