lazarchitect / FlaskReactor

With a Flask backend and a React front-end, this site will let you play board games online with friends. The culmination of many different ideas and projects. Full stack, complete with PostgreSQL database and CI/CD Jenkins + Docker tooling. Powered by Linux / Raspberry Pi!
http://flaskreactor.net
1 stars 0 forks source link

Save chess notation to DB for future features #71

Open lazarchitect opened 6 months ago

lazarchitect commented 6 months ago

As the game goes on, record each move in the database using algebraic notation. I'm thinking we use "long algebraic notation" where we record the starting position in addition to the ending position. No need to record the piece type, except for promotions. Turns can optionally be separated by a delimiter such as a period.

e.g. e2e4.d7d6. etc O-O and O-O-O are fine for castling e7e8Q to indicate a Pawn was promoted to a Queen (so the code should check if the turn shorthand was 5 characters instead of 4)

I foresee keeping track of en passant being a real pain in the future... maybe just send "e" at the end of the move so the server can easily tell if en passant was performed

lazarchitect commented 5 months ago

Technical approach:

  1. on client side, when move is made, record board coordinates of source and destination. (Castling will record the king's movement).
  2. client sends these details to server (I think this already happens?)
  3. server side, chess socket handler logic parses the src and dest details, maps it into move notation
  4. key part - when updating the DB, we pull the current game moves string and append the new move.