sheleoni / icecream-kana-game

A game for learning Japanese characters in the form of collecting ice-cream scoops. 🍦
https://icecream.sheleoni.com/
1 stars 0 forks source link

fetch total score from server and render on game interface ✍️ #69

Closed sheleoni closed 11 months ago

sheleoni commented 11 months ago

Points to Consider

whether to store totalScore as its individual field derived state in backend mongoDB

sheleoni commented 11 months ago

replying to https://github.com/sheleoni/icecream-kana-game/issues/69#issue-2050695291

thing is, we have to store the scoreBreakdown in the backend anyway (and retrieve it on page load) since the frontend rendering logic depends on the score breakdown (your score: XX) is dependent on scoreBreakdown object. If we only send the final score (number) to the backend on pass it as a prop to "your score", you will create disconnection between the scoreBreakdown and the total score, which makes for a very confusing UX

CleanShot 2023-12-21 at 21 21 58@2x

So, let's go forward and store the scoreBreakdown as it is on the backend as an array of kana characters and their score. Anyway, we are going to need to fetch the scoreBreakdown object, so I don't think it's worth in in trying to optimize data fetching by storing total score in a separate field. Unless we evolve to require only totalScore on some other routes (e.g. leaderboard that only shows users' totalscore)

sheleoni commented 11 months ago

resolved by https://github.com/sheleoni/icecream-kana-game/issues/71