From a2d696dea797faaa3157046c8ae89cd70e965bff Mon Sep 17 00:00:00 2001 From: scratko Date: Sat, 10 Aug 2024 02:46:56 +0300 Subject: Prefinal version Added client. Moved files to directories. --- client/printing_game_frames.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 client/printing_game_frames.c (limited to 'client/printing_game_frames.c') diff --git a/client/printing_game_frames.c b/client/printing_game_frames.c new file mode 100644 index 0000000..38f1a78 --- /dev/null +++ b/client/printing_game_frames.c @@ -0,0 +1,104 @@ +#include "printing_game_frames.h" +#include "card_stack.h" + +#include + +void pgf_first_player() +{ + printf("=======================================" + " You're the first player" + "Waiting for other players to connect..." + "=======================================\n"); +} + +void pgf_confirmation_waiting(int total_players) +{ + printf("=======================================" + " To start game press key " + "Connected players: %u/8 " + "=======================================\n", total_players); +} + +void pgf_table(struct client *cl) +{ + struct card_stack_item *deck = NULL; + int i; + + for(i = 0; i < cl->cc.number_arr_idx; ++i) + /* printing who will move */ + if(cl->state == attack_expectation || cl->state == defense_expectation) + printf("<%c%u > ", cl->position_whose_turn-1 == i ? '*' : ' ', + cl->cc.number_arr[i]); + else + printf("< %u > ", cl->cc.number_arr[i]); + printf(" %s [ %u ]", cl->trump_card, cl->total_cards_left); + printf("\n\n\n"); + /* ================= cards on table ================ */ + for(i = 0; i <= cl->cot.card_arr_idx; i += 3) + printf(" %s %s %s\n", cl->cot.card_arr[i], cl->cot.card_arr[i+1], + cl->cot.card_arr[i+2]); + /* for the defender, the cards in the queue are hidden */ + if(cl->state == defense_expectation) + for(i = 0; i <= cl->cq.card_arr_idx; ++i) + printf(" %s \\ -\n", cl->cq.card_arr[i]); + printf("\n\n"); + /* ================ player's deck ================ */ + deck = cl->deck; + i = 0; + while(deck) { + printf("%c: %s ", deck->tip, deck->str); + ++i; + /* line break every 6 cards */ + if(!(i % 6)) + printf("\n"); + deck = deck->next; + } + printf("\n"); +} + +void pgf_suggestions(struct client *cl) +{ + struct card_stack_item *deck = NULL; + + if(cl->state == attack || cl->state == tossing) + printf("you can specify more than one card " + "(under certain conditions)\n"); + deck = cl->deck; + while(deck) { + if(deck->is_usable) + printf("%c", deck->tip); + deck = deck->next; + } + printf(" > "); +} + +void pgf_select_idle_mode_message(enum client_states state) +{ + switch(state) { + case attack_expectation: + printf("waiting for the attacker's turn\n"); + break; + case defense_expectation: + printf("waiting for the defender's turn\n"); + break; + case tossing_expectation: + printf("waiting for other players to toss cards\n"); + break; + default: + {} + } +} + +void pgf_card_acceptance_status(int all_input_cards_accepted) +{ + if(all_input_cards_accepted) + printf("all cards accepted\n"); + else + printf("not all cards were accepted\n"); +} + +void pgf_tossing_limit_status() +{ + printf("the cards were not accepted.\n" + "The other players have already tossed cards.\n"); +} -- cgit v1.2.3