diff options
author | scratko <m@scratko.xyz> | 2024-08-10 02:46:56 +0300 |
---|---|---|
committer | scratko <m@scratko.xyz> | 2024-08-10 02:46:56 +0300 |
commit | a2d696dea797faaa3157046c8ae89cd70e965bff (patch) | |
tree | 74051e828ec401f399b2316a535c200f3afa95c5 /client/verification_client_input.c | |
parent | 9e9919b897b00ff23aee6581471b4d7b4567bf4a (diff) | |
download | durak-a2d696dea797faaa3157046c8ae89cd70e965bff.tar.gz durak-a2d696dea797faaa3157046c8ae89cd70e965bff.tar.bz2 durak-a2d696dea797faaa3157046c8ae89cd70e965bff.zip |
Prefinal version
Added client.
Moved files to directories.
Diffstat (limited to 'client/verification_client_input.c')
-rw-r--r-- | client/verification_client_input.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/client/verification_client_input.c b/client/verification_client_input.c new file mode 100644 index 0000000..2134f30 --- /dev/null +++ b/client/verification_client_input.c @@ -0,0 +1,46 @@ +#include "verification_client_input.h" + +#include <stdio.h> +#include <unistd.h> + +/* + * 1 - response received + * 0 - waiting for re-entry of data + */ +int vci_confirmation_waiting(int fd, char *buffer) +{ + if(buffer[0] == '\n') { + write(fd, buffer, 1); + return 1; + } + else + printf("please press enter\n"); + return 0; +} + +int vci_attack_or_tossing(int fd, char *buffer, player_cards deck, + enum client_states state) +{ + int i; + + if(state == tossing && buffer[0] == '\n') /* cancel card tossing */ + return 1; + + for(i = 0; buffer[i] != '\n'; ++i) + if(!card_search_by_letter(deck, buffer[i])) { + printf("incorrect input\n"); + return 0; + } + return 1; +} + +int vci_defense(int fd, char *buffer, player_cards deck) +{ + if(buffer[0] == '\n') /* the player does not want to keep the defense */ + return 1; + if(!card_search_by_letter(deck, buffer[0])) + return 0; + if(buffer[1] != '\n') + return 0; + return 1; +} |