back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/linux_client/client.h
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-08-30 12:46:56 +0300
committerscratko <m@scratko.xyz>2024-08-30 14:59:44 +0300
commit831f9f01fbe4088eb6bd378c0e417d9996b676fd (patch)
tree53297459d35ad795618c351a79b1829776e5e1f4 /linux_client/client.h
parent4b6c15f780d59895f067383a5041edcfe86f504e (diff)
downloaddurak-831f9f01fbe4088eb6bd378c0e417d9996b676fd.tar.gz
durak-831f9f01fbe4088eb6bd378c0e417d9996b676fd.tar.bz2
durak-831f9f01fbe4088eb6bd378c0e417d9996b676fd.zip
Final version v2.0
Added windows client. SIGPIPE signal was being sent to the server when the client was disconnected. Now there is handling of this signal. Added a delay when displaying some informational messages.
Diffstat (limited to 'linux_client/client.h')
-rw-r--r--linux_client/client.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/linux_client/client.h b/linux_client/client.h
new file mode 100644
index 0000000..12ec619
--- /dev/null
+++ b/linux_client/client.h
@@ -0,0 +1,84 @@
+#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
+};
+
+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;
+};
+
+#endif