#include "printing_game_frames.h" #include "card_stack.h" #include void pgf_new_frame() { int i; for(i = 0; i < 25; ++i) printf("\n"); } void pgf_first_player() { printf("=======================================\n" " You're the first player\n" "Waiting for other players to connect...\n" "=======================================\n"); } void pgf_confirmation_waiting(int total_players) { printf("=======================================\n" " To start game press key \n" "Connected players: %u/8 \n" "=======================================\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]); if(cl->cot.card_arr_idx != -1) 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; } if(cl->deck) 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(" > "); fflush(stdout); } 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"); } void pgf_spectator_mode(enum spectator_mode sp_mode) { printf("spectator mode\n"); if(sp_mode == spectator_attack) printf("attacker makes a move\n"); else if(sp_mode == spectator_defense) printf("defender make a move\n"); else if(sp_mode == spectator_tossing) printf("players toss in extra cards\n"); else printf("round result\n"); } void pgf_game_result(int durak_position) { printf("===============================\n" " END OF GAME\n" "player under number %u is durak\n" "===============================\n", durak_position); }