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/printing_game_frames.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/printing_game_frames.c')
-rw-r--r-- | client/printing_game_frames.c | 104 |
1 files changed, 104 insertions, 0 deletions
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 <stdio.h> + +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 <Enter> 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"); +} |