#ifndef SERVER_H_SENTRY #define SERVER_H_SENTRY #include "card_queue.h" #include "card_stack.h" enum { max_buffer_size = 4096, listen_qlen = 32, init_sess_arr_size = 32 }; enum { max_shuffled_deck_size = 52, max_card_arr_size = 18 }; enum server_states { no_players, first_player, confirmation_waiting, start_game, attack_phase_out, attack_phase_in, defense_phase_out, defense_phase_in, tossing_phase_out, tossing_phase_in, table }; enum client_game_states { display_only_table, attack_expectation, defense_expectation, tossing_expectation, attack, defense, tossing }; enum tossing_mode { cancel, answer_wait, answer_got, none }; struct session { int fd; enum client_game_states state; /* read data from client */ char buffer[max_buffer_size]; int buffer_used; int record; player_cards deck; int player_position; enum tossing_mode tm; int defense_lost; }; struct cards_on_table { /* * example: 2^ \ - 10# \ K# */ const char* card_arr[max_card_arr_size]; int card_arr_idx; }; struct server { int change_server_state; enum server_states state; int listen_socket; struct session **sess_arr; int max_sess_arr_size; int connected_players_counter; const char **shuffled_deck; int shuffled_deck_size; const char *trump_suit; struct game_info *gi; struct session **turn_queue; int *card_quantity_arr; int position_whose_turn; struct card_queue *cq; struct cards_on_table *cot; }; #endif