webdevcody / webdevcody/code-racer

[TASK]: Refactor Multiplayer & Typing Logic

Open
#716 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
697
Forks
594
PR merge metrics
No merged PRs in 30d

Description

Task Summary

Since we have multiplayer, it will be better if we reuse the logic for:

  • Typing
  • Errors in Typing
  • Row Line Tracker
  • Progress Tracker

Also, it will be nice if we can clean up the code a bit. By separating the logic from the component that renders stuff, it will be nice. Use useReducer as well for a component that uses a lot of state. Usage of proper practices in React (to avoid unnecessary recalculation of stuff) with useMemo useCallback and memo.

In Multiplayer, refactor the websocket server to be clear about the responsibilites of each function as much as possible. Separate a layer for memory (storing temporary data for matching userIDs, etc.).

Also, for result page, to avoid the bug of typing in the resultID or something after finishing will cause an increase in CPM (If I'm remembering the bug properly), we can change the result page to not take any of those and instead only base from the sessionStorage (which is convenient for both logged in users and anonymous users). Of course, user data will still be saved if a user is logged in.

Make the multiplayer functional, for now, I think rooms will be preferable. It's not neccesary to add database calls yet, we can incorporate that after making sure that the structure for the multiplayer is sturdy.

Remove the topten from the results page and instead put it in the leaderboard (can be a feature), and remove history since it's not displaying anything.

All this is for a PR that I will be doing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the multiplayer typing components, websocket server, result page, leaderboard, and history implementation described in the issue. Map the existing typing, progress, room, and sessionStorage flows before deciding on boundaries. Done means multiplayer works with rooms, shared logic is separated from rendering, result CPM cannot be changed after completion, and the requested results-page cleanup is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
backend, frontend, full-stack
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.