1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#ifndef CLIENT_H_SENTRY
#define CLIENT_H_SENTRY
#include "card_stack.h"
enum {
max_buffer_size = 4096,
max_cot_arr_size = 18,
card_size = 4,
max_cq_arr_size = 5,
backspace = 8
};
enum client_states {
none,
first_player,
confirmation_waiting,
/* in game */
display_only_table,
attack_expectation,
defense_expectation,
tossing_expectation,
attack,
defense,
tossing,
card_acceptance_status,
tossing_limit_status,
spectator,
result,
disconnect
};
enum spectator_mode {
spectator_attack,
spectator_defense,
spectator_tossing,
spectator_table
};
struct cards_on_table {
/*
* example: 2^ \ - 10# \ K#
* [2 ^ '\0' ][1 0 # '\0'][\ '\0' ]
*/
char card_arr[max_cot_arr_size][card_size];
/* index of the last filled element */
int card_arr_idx;
};
struct card_queue {
char card_arr[max_cq_arr_size][card_size];
int card_arr_idx;
};
struct card_count {
int *number_arr;
/*
* will only store the initial number of players
* (idx: total_players - 1
*/
int number_arr_idx;
};
struct client {
int fd;
enum client_states state;
char buffer[max_buffer_size];
int total_players;
int total_cards_left;
int player_position;
char trump_card[4];
struct card_count cc;
struct cards_on_table cot;
player_cards deck;
int pending_server_response;
struct card_queue cq;
int position_whose_turn;
int display_new_frame;
int all_input_cards_accepted;
int data_left_in_buffer;
enum spectator_mode sp_mode;
int durak_position;
int read_data;
};
#endif
|