Skip to content

Latest commit

 

History

History
234 lines (224 loc) · 10.8 KB

DONE.md

File metadata and controls

234 lines (224 loc) · 10.8 KB

Bugs

  • pawn promotion needs to be rewritten
    • the pawn can't transform into its promotion piece before moving to its destination square, it messed up get_possible_moves
  • the black king, when eligible to castle, doesn't have a dot in the right place for that
  • can't click on a space if you're hovering over the blue dot
  • if you click an ineligible square (no dots) after selecting a piece, it doesn't remove the dots but it un-highlights the piece and makes it so you can't click on a dot to move the piece

Front End

  • make room for non-game-over messages, use colors
  • disable pinch to zoom
  • add ethical analytics
  • maybe get rid of the 'share url' button altogether
  • make the 'create game' button bigger on mobile

Features

  • prevent modals from being dismissed via 'escape'

  • support landscape mode on mobile (fill the screen ,no scrolling)

  • make the board centered

  • make it so the buttons don't go off the page (board a bit smaller?)

  • add a spinner when creating a game

  • make the messages (game on, game over, etc.) modals which hover over the center of the board

    • make modal
    • on second thought, only use the modal for game over
  • make dots smaller

  • shade the selected piece/background

  • show previous move coloring

  • show dot on top of possible target piece (possible moves)

    • z-index doesn't cut it for this so far
  • put it at a domain, even if it's averba.ch/chess

  • make sure same-origin policy is getting enforced

  • initiate closing of connection from client (it's not getting called on the server currently)

  • resign

  • draw

    • don't allow it until both sides have moved
    • change message sent from server for
      • reject
      • accept
    • hide 'offer draw' and show 'withdraw draw' when there's a pending one from self
    • make a dialog for accepting/rejecting a draw
      • made buttons instead
    • erase 'you have offered a draw' when it's been rejected or the other person has moved
    • bug: when white offers a draw, white's buttons are changed instead of black's (from 'offer' to 'accept' and 'decline')
  • threefold repetition

    • same position
    • same person's turn as two other occurrences
    • same en passant state
    • same castling state
    • NOT automatic, must be requested by either player before the next move is made
    • create a record of a combination of
      • board states
      • all possible moves for each board state
    • after each move, check whether the state has occurred twice before
    • when the game is over, empty this cache as well
    • deal with state.draw = 1 in ws logic after do_move_and_persist
  • there's a bunch of stray UIDs on the home screen, they're getting stuck in Redis

  • this should be checkmate: should be checkmate

    • 2k4N/ppp5/5n1p/8/4N2n/3b4/PP1b2r1/5K2
    • the board before that: 2k4N/ppp5/5n1p/8/4N2n/8/PPbb2r1/5K2
      • the last move was c2 to d3 (bishop)
    • there were no console errors in either browser, but the move never got reported to white's browser
    • i'm pretty sure this did get registered as checkmate but the server disconnected too fast
      • for this reason I'm not disconnecting in game_over
  • pawn promotion! (websockets and web view)

    • maybe use native dialog link
  • deploy

    • spin up Redis instances
      • prod
      • dev
    • spin up postgres instances
      • prod
      • dev
    • make script for initializing postgres DB
      • run it on
        • dev (locally)
        • prod
    • replace hardcoded assets with env vars
      • db connection
      • redis connection
    • refactor DB operations to postgres
    • make a separate requirements-prod.txt
    • create a web service for the API
      • add gunicorn
    • create a web service for the websocket server
  • websocket API

    • wrong number of watchers is shown once someone leaves (seems like it's not always decrement, or else maybe it's including the players once there's been more than one watcher?)
    • "someone has left chat" is the message shown when a watcher leaves! (also wrong count)
    • send entire game state at start of game, including to players
    • who abandoned the game? there's some confusion here
      • "black abandoned the game, so white wins!" -- this happens when white abandons
  • create a basic DB

    • use sqlite for completed games
      • fields: uid and moves
      • a function to store a completed game
    • use Redis at first for the active games
      • make a list for each active game
        • key is "game_"
        • value is list of verbose moves (originating square, pieces, destination square)
      • make a hash for each game
        • key is "game_"
        • values are key/values
          • half_moves: int
          • turn: 0/1
          • white_can_castle_queenside
          • black_can_castle_queenside
          • white_can_castle_kingside
          • black_can_castle_kingside
          • half_moves_since_last_capture: null/moveNum
          • board: probably a FEN
  • create logic for

    • create game
    • make move
      • validate move
        • pawn
          • en passant
        • rook
        • bishop
        • queen
        • king
        • knight
          • write tests
        • is it check?
        • if castling, would it sweep through check?
      • persist move
      • update game state
        • see "make a hash for each game"
      • test "get all legal moves"
        • en passant results in the captured piece actually disappearing
        • king is prohibited from putting himself into check, especially with another king
      • check if game is over
        • is it stalemate? (no possible moves and check is False)
        • is it checkmate? (no possible moves and check is True)
        • if it is, persist it to "completed_games" (sqlite)
      • pawn promotion
        • implement it
  • create a basic web API

    • HTTP

      • /game
        • POST
          • /create
    • websockets

      • there's a bug (Feb 5, 2023) where some invalid chars are sent but a) somehow this doesn't produce an error and 'continue' and b) the sender gets disconnected. Possibly I just fat-fingered this and disconnected myself, BUT the game didn't get set as "abandoned" when it happened, which points to an actual bug.
        • resolved on Feb 6, 2023 with commit c510c4f51e61c0b4a555016bf70de46056391837
      • use the websockets library, at first without concerning yourself with authentication
      • events
        • handle abandoned games
          • remove from redis, (maybe) add to db
        • join
        • resign
        • draw
          • requested
          • accepted
        • move
          • try stalemate
          • try the fool's mate, make sure it goes
            • f2-f3, e7-e5, g2-g4, Qd8-Qh4
          • on success, return to whoever's turn it is
            • all possible moves
            • new game state
            • from/to of prev move
          • don't allow someone to make a move who isn't attached to a game! (different UID)
          • say "it's your turn" to whoever's turn it is, i guess as a separate message
          • provide the game state to new watchers
          • don't allow a websocket connection to 'join' a game if it already has joined one
          • don't allow if there's only one player
          • don't allow if the game is over
          • don't allow a player to move out of turn
          • don't allow a spectator to make a move
    • mark 'winner' field of game state when there's a resignation

    • update 'existing_uids' redis list as games end

    • BUG: when leaving/refreshing the browser, the game gets removed but somehow remains as a link on the home screen

      • this might be because of the bullet point above
  • create a basic web interface

    • /
      • when you click on the create game button it automatically brings you to that new URL
      • list of active games, each joinable
    • /
      • render the board
      • use cm-chessboard which has event handlers
      • connect the board!
        • when a piece moves, trigger a ws message
        • freeze the pieces when it's not that player's turn
        • turn the board around for black
          • get which player the ws is for, set that as a global var
      • only allow legal moves
        • check possible_moves as delivered with 'your_turn' event
        • check castling (what does that look like from the board, 'o-o' or?
      • support castling
        • move the rook automatically
        • deliver the move accurately to the server
        • make sure it's shown on opponent's/watchers' boards
        • don't let castling happen more than once!
      • make captures work (have to deliver 'capture' arg to ws server)
      • connect to websocket server
      • 'invite' button which copies the URL to your clipboard
      • a debug box to show the websocket messages getting sent/received
  • BUG: white king can't capture rook here??

    • screenshot
    • related: white rook doesn't exist after castling
  • BUG: this isn't check??

    • screenshot
    • screenshot
  • BUG: there are a bunch of error messages on websocket server

  • BUG: this isn't checkmate?

    • screenshot
    • i can't replicate it (test_make_move_bug_11)
  • en passant

    • for black, it's not showing up as a possbile move
    • for white, the captured piece isn't disappearing
      • add en passant logic to "case: success" clause
      • figure out why board.removePiece isn't getting found (added it to chessground)
    • show the allowed moves
    • fill the screen on mobile
    • warn when closing the tab/window, instead of allowing resume
    • indicate checkmate
    • indicate check
    • indicate stalemate