diff options
Diffstat (limited to 'client/printing_game_frames.c')
-rw-r--r-- | client/printing_game_frames.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/client/printing_game_frames.c b/client/printing_game_frames.c index bda1208..6b2131a 100644 --- a/client/printing_game_frames.c +++ b/client/printing_game_frames.c @@ -2,6 +2,7 @@ #include "card_stack.h" #include <stdio.h> +#include <unistd.h> void pgf_new_frame() { @@ -34,29 +35,39 @@ void pgf_first_player() printf("=======================================\n" " You're the first player\n" "Waiting for other players to connect...\n" + " Press q <Enter> to exit\n" "=======================================\n"); } void pgf_confirmation_waiting(int total_players) { printf("=======================================\n" - " To start game press <Enter> key \n" - " Connected players: %u/8 \n" + " To start game press <Enter> key\n" + " Connected players: %u/8\n" + " Press q <Enter> to exit\n" "=======================================\n", total_players); } +static int move_indication_condition(const struct client *cl, + int current_player) +{ + return + current_player == cl->position_whose_turn && + (cl->state == attack_expectation || cl->state == defense_expectation || + cl->state == attack || cl->state == defense || + (cl->state == spectator && (cl->sp_mode == spectator_attack || + cl->sp_mode == spectator_defense))); +} + 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 %c> ", cl->player_position == i+1 ? "YOU" : " ", + cl->cc.number_arr[i], move_indication_condition(cl, i+1) ? + '*' : ' '); printf(" %s [ %u ]", cl->trump_card, cl->total_cards_left); printf("\n\n\n"); /* ================= cards on table ================ */ @@ -64,7 +75,7 @@ void pgf_table(struct client *cl) 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) + if(cl->state == defense_expectation || cl->state == spectator) for(i = 0; i <= cl->cq.card_arr_idx; ++i) printf(" %s \\ -\n", cl->cq.card_arr[i]); if(cl->cot.card_arr_idx != -1) @@ -88,6 +99,7 @@ void pgf_suggestions(struct client *cl) { struct card_stack_item *deck = NULL; + printf("qq - exit the game\n"); if(cl->state == attack || cl->state == tossing) printf("you can specify more than one card\n"); deck = cl->deck; @@ -152,7 +164,20 @@ void pgf_game_result(int durak_position) "=======================================\n", durak_position); } +static void clear_input() +{ + int key; + + while((key = getchar()) != '\n') + {} +} + void pgf_disconnect() { - printf("Server connection disconnected\n"); + char key; + + printf("Server connection disconnected\n" + "Press <Enter> to close program\n"); + while((key = getchar()) != '\n') + clear_input(); } |