SERVER STARTUP -------------- * server starts up and initializes * server binds to port * server listens for connections from clients SERVER LOGIN HANDLING --------------------- * client sends keepalive request * server sends keepalive acknowledgement * server sends authentication request * client sends authentication acknowledgement * server sends authentication accepted/denied * if denied: * server closes client connection * server logs failed authentication attempt * if accepted * server sends user stats request * client sends user stats acknowledgement * server sends user stats * server sends user friend list request * client sends user friend list acknowledgement * server sends user friend list start * server sends user friend list * server sends user friend list stop * server sends lobby list request * client sends lobby list acknowledgement * server sends lobby list start * server sends lobby list * server sends lobby list stop * server sends login successful request * client sends login successful acknowledgement * server logs successful login attempt SERVER LOBBY/GAME HANDLING -------------------------- * client sends join lobby request * server sends join lobby acknowledgement * server checks if user can join lobby * server sends join lobby accepted/denied * if denied: * server does nothing * server logs failed join lobby request * if accepted: * server joins user to lobby * server sends lobby info request * client sends lobby info acknowledgement * server sends lobby info * server sends games list request * client sends games list acknowledgement * server sends games list start * server sends games list * server sends games list stop * if user wants to leave lobby: * client sends part lobby request * server sends part lobby acknowledgement * server boots user from lobby * client sends join game request * server sends join game acknowledgement * server checks if user can join game * server sends join game accepted/denied * if denied: * server does nothing * server logs failed join game request * if accepted: * server joins user to game * server sends game info request * client sends game info acknowledgement * server sends game info * server sends player list request * client sends player list acknowledgement * server sends player list start * server sends player list * server sends player list stop * server sends ready to play request * client sends ready to play acknowledgement * server readys user for gameplay * if user wants to leave game: * client sends part game request * server sends part game acknowledgement SERVER GAMEPLAY HANDLING ------------------------ * server calculates number of clients in game * server waits for each client in game to be ready * once each client is ready, initiate game * server starts game loop: * server shuffles deck, storing deck order locally * server deals one card to each user until each user has 7 * server sets player order * first round starts, initiating game rounds loop * server prepares game-state packet * server sends game-state packet request to each client * each client sends game-state packet acknowledgement * server sends game-state packet to each client * current player plays hand and sends it to server * server reads players hand and updates game-state packet * round ends, next round starts * game rounds loop continues until server recognizes winner * once winner is declared, server notifies each client * server updates each clients user stats * server sends 'play again or leave' query to each user * server waits for each client to send their option * server boots users that want to leave * sever gameplay loop starts over with calculating number of clients SERVER LOGGING -------------- * logging function checks logging configuration * logging function forms log string with prefixed date/time * logging function prints either to console or file USER STATS STRUCTURE -------------------- * username * users rank * email address * date of last login USER FRIEND LIST STRUCTURE -------------------------- * each friend's username * each friend's rank * each friend's email * each users date of last login * each users online/offline status LOBBY LIST STRUCTURE -------------------- * lobby name * number of games in lobby * max number of games allowed in lobby * whether or not it has a rank limit, and if so, what the rank limit is GAMES LIST STRUCTURE ------------------- * game name * number of players currently in game * whether or not game has rank limit, and if so, the rank limit PLAYER LIST STRUCTURE --------------------- * username * rank GAME-STATE PACKET STRUCTURE --------------------------- * round number * number of cards in each players hand * list of cards in current players hand * list of cards in each face-up pile * list of cards in each kings pile LOBBY INFO STRUCTURE -------------------- * name of lobby * date of lobby creation * number of games in lobby GAME INFO STRUCTURE ------------------- * name of game * date of game creation * number of players in game NETWORKING STRINGS (REQ, ACK) ----------------------------- keepalive request n_req_keepalive keepalive acknowledgement n_ack_keepalive authentication request n_req_auth authentication acknowledgement n_ack_auth authentication accepted n_auth_accepted authentication failure n_auth_failed user stats request n_req_user_stats user stats acknowledgement n_ack_user_stats user friend list request n_req_user_flist user friend list acknowledgement n_ack_user_flist user friend list start n_stt_user_flist user friend list stop n_stp_user_flist lobby list request n_req_lobby_list lobby list acknowledgement n_ack_lobby_list lobby list start n_stt_lobby_list lobby list stop n_stp_lobby_list games list request n_req_games_list games list acknowledgement n_ack_games_list games list start n_stt_games_list games list stop n_stp_games_list player list request n_req_player_list player list acknowledgement n_ack_player_list player list start n_stt_player_list player list stop n_stp_player list login successful request n_req_login_ok login successful acknowledgement n_ack_login_ok join lobby request n_req_lobby_join join lobby acknowledgement n_ack_lobby_join part lobby request n_req_lobby_part part lobby acknowledgement n_ack_lobby_part lobby info request n_req_lobby_info lobby info acknowledgement n_ack_lobby_info join game request n_req_game_join join game acknowledgement n_ack_game_join part game request n_req_game_part part game acknowledgement n_ack_game_part game info request n_req_game_info game info acknowledgement n_ack_game_info ready to play request n_req_readytoplay ready to play acknowledgement n_ack_readytoplay send game-state packet request n_req_send_gamestate send game-state packet acknowledgement n_ack_send_gamestate NETWORKING STRINGS (STRUCTURES, INFO) ------------------------------- user stats s_ustats_ user friend list s_uflist_ lobby list s_llist_ games list s_glist_ player list s_plist_ game state packet s_gs_ lobby info s_info_lobby_ game info s_info_game_ USTATS STRING ------------- ::: where... a is username b is rank c is email d is date of last login UFLIST STRING ------------- ::::: where... a is id b is username c is rank d is email e is date of last login f is online/offline LLIST STRING ------------ :::: where... a is id b is lobby name c is number of games in lobby d is max number of games in lobby allowed e is 0 for no rank limit, or rank limit number GLIST STRING ------------ ::: where... a is id b is game name c is number of players in game d is 0 for no rank limit, or rank limit number PLIST STRING ------------ :: where... a is id b is username c is rank GS STRING --------- :::::::::::::: where... a is round number (round id) b is id of current player (player gs packet is sent to) c is hand of current player d is number of cards in player1's hand e is number of cards in player2's hand f is number if cards in player3's hand (0 if no player) g is number of cards in player4's hand (0 if no player) h is list of cards in face-up pile 1 i is list of cards in face-up pile 2 j is list of cards in face-up pile 3 k is list of cards in face-up pile 4 l is list of cards in kings pile 1 m is list of cards in kings pile 2 n is list of cards in kings pile 3 o is list of cards in kings pile 4 LOBBY INFO STRING ----------------- :: where... a is name of lobby b is date of lobby creation c is number of games in lobby GAME INFO STRING ---------------- :: where... a is name of game b is date of game creation c is number of players in game CARD CHARACTERS --------------- (in data strings, each card is separated by a '-') SPADES ------ ace 01 two 02 three 03 four 04 five 05 six 06 seven 07 eight 08 nine 09 ten 0a jack 0b queen 0c king 0d DIAMONDS -------- ace 0e two 0f three 10 four 11 five 12 six 13 seven 14 eight 15 nine 16 ten 17 jack 18 queen 19 king 1a CLUBS ----- two 1b three 1c four 1d five 1e six 1f seven 20 eight 21 nine 22 ten 23 jack 24 queen 25 king 26 HEARTS ------ ace 27 two 28 three 29 four 2a five 2b six 2c seven 2d eight 2e nine 2f ten 30 jack 31 queen 32 king 33