Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 1.78 KB

File metadata and controls

46 lines (29 loc) · 1.78 KB

CS50 Final Project - Nuggets

Group jjen: Julian, Joanna, Eddie, Neo

client

The client provides a user interface for the nuggets game. It has no role in tracking gold, determining visibility, handling moves, or checking the validity of user's keystrokes. The client's main functionality is to pass keystrokes to the server and display the maps that come back.

Usage

The client, implemented in client.c, defines a game state_t structure and exports the following functions:

int main(const int argc, char *argv[]);
static bool handleInput(void *arg);
static bool handleMessage(void *arg, const addr_t from, const char *message);
static void showStatus();
static void cleanupAndQuit(const char *msg, int exitCode);

Implementation

The main function parses the command-line arguments and initializes the modules needed for the game (messaging, ncurses). The client loops for input or a message from server.

The handleInput function reads keystrokes from the human player and sends a corresponding message to the server. The game's status line is updated if necessary and displayed.

The handleMessage function reads messages from the server and handles them according to the specs. The game's status line is updated if necessary and displayed, and malformatted/error messages are handled according to the specs.

The showStatus function displays the game's status line using ncurses. It is called in both handleInput and handleMessage.

The cleanupAndQuit function is called when the client receives a "QUIT" message and effectively ends the nuggets game.

Files

  • Makefile - compilation procedure
  • client.c - the implementation

Compilation

To compile, simply make.

Testing

Test with the miniserver in the support library library.