#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 = 12 /* it was 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, end_game }; enum client_game_states { /* in game */ display_only_table = 3, attack_expectation, defense_expectation, tossing_expectation, attack, defense, tossing, card_acceptance_status, tossing_limit_status, spectator, result }; enum tossing_mode { cancel, answer_wait, answer_got, none }; enum spectator_mode { spectator_attack, spectator_defense, spectator_tossing, spectator_table }; 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 card_count { int *number_arr; /* will only store the initial number of players (idx) */ int number_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; /* TODO: make static allocation memory */ const char **shuffled_deck; int shuffled_deck_size; const char *trump_suit; const char *trump_card; struct game_info *gi; struct session **turn_queue; /* changes if the player has discarded all his cards * (and shuffled_deck_size == 0) */ int turn_queue_size; struct card_count cc; int position_whose_turn; struct card_queue cq; struct cards_on_table cot; int durak_position; int tossing_limit; }; #endif