Server Tasks - niehusst/TerminalJeopardy GitHub Wiki

  • accept connecting clients while clients_connected < MAX_CLIENTS
  • load and process game data from raw JSON/CSV file
  • game loop:

{

  • construct and send metadata_t to clients
  • send 5 category name strings 1-by-1 (same order as filled out in the category field of the metadata_t struct)
    • if game is determined to be over:
    • send array of integer scores to the clients
    • send int array of sizes of usernames (order corresponding to scores)
    • send each username string 1-by-1 (order corresponding to scores)
  • send boolean to each client, dictating whose turn it is to select a question
  • read question choice coordinates (2 chars, e.g. E5) from the client whose turn it was
  • convert coords to board position and extract question
  • send the question size
  • send the question as a string itself
  • read buzz in (time_t struct containing system time in seconds since 1970 when the user buzzed in)
  • send boolean back to all clients telling them if they were the first to buzz in or not (dictating whether they answer the question)
  • from the client who buzzed first, read their answer to the question (and their username??)
  • send answer_sizes_t struct to all clients (contains length of predicted answer, true answer, and answerer username)
  • send predicted answer string
  • send real answer string
  • send username string
  • send boolean dictating whether the predicted answer was correct (True) or not (False)

}