back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/windows_client/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'windows_client/client.h')
-rw-r--r--windows_client/client.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/windows_client/client.h b/windows_client/client.h
new file mode 100644
index 0000000..f3b1ce8
--- /dev/null
+++ b/windows_client/client.h
@@ -0,0 +1,87 @@
+#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 = 127,
+ back = 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