From 831f9f01fbe4088eb6bd378c0e417d9996b676fd Mon Sep 17 00:00:00 2001 From: scratko Date: Fri, 30 Aug 2024 12:46:56 +0300 Subject: 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. --- client/card_handling.c | 64 -------------------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 client/card_handling.c (limited to 'client/card_handling.c') diff --git a/client/card_handling.c b/client/card_handling.c deleted file mode 100644 index 011ad40..0000000 --- a/client/card_handling.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "card_handling.h" - -#include -#include - -int convert_rank_to_int(const char *card) -{ - int length; - char str_rank[2]; - - length = strlen(card); - /* 10 - the only one of its kind */ - if(length == 3) - return 10; - - str_rank[0] = card[0]; - str_rank[1] = '\0'; - - switch(card[0]) { - case 'J': - return 11; - case 'Q': - return 12; - case 'K': - return 13; - case 'A': - return 14; - default: - return strtol(str_rank, NULL, 10); - } - return 0; -} - -int is_card_beaten(const char *attack_card, const char *defend_card, - const char *trump_suit) -{ - int length, attack_rank, defend_rank; - const char *attack_suit, *defend_suit; - - length = strlen(attack_card); - attack_suit= attack_card + length - 1; - length = strlen(defend_card); - defend_suit = defend_card + length - 1; - - /* suits matched */ - if(!strcmp(attack_suit, defend_suit)) { - attack_rank = convert_rank_to_int(attack_card); - defend_rank = convert_rank_to_int(defend_card); - if(defend_rank > attack_rank) - return 1; - /* defender has a trump suit */ - } else if(!strcmp(defend_suit, trump_suit)) - return 1; - return 0; -} - -int check_matched_ranks(const char *attack_card, const char *not_defender_card) -{ - int attack_rank, not_defender_rank; - - attack_rank = convert_rank_to_int(attack_card); - not_defender_rank = convert_rank_to_int(not_defender_card); - return attack_rank == not_defender_rank; -} -- cgit v1.2.3