diff --git a/lib/display.c b/lib/display.c index ed9cb2d..15d429e 100644 --- a/lib/display.c +++ b/lib/display.c @@ -1,9 +1,11 @@ +#include #include #include #include #include #include "deck.h" #include "display.h" +#include "../debug/deck_debug.h" void init_curses() { setlocale(LC_ALL, ""); /* supporting unicode characters */ @@ -54,7 +56,13 @@ void initialize_game() { draw_empty_stacks(); allocate_deck(&deck); initialize_deck(deck); + set_deck_stacks_coordinates(deck); fill_deck(deck); + shuffle_deck(deck); + deal_cards(deck); + draw_game(deck); + endwin(); + /*print_deck(deck);*/ return; } @@ -138,11 +146,45 @@ void draw_back(struct card *card) { } void draw_card(struct card *card) { + mvwin(card->frame->shape, card->frame->start_y, card->frame->start_x); if (card->face == EXPOSED) { draw_front(card); } else { draw_back(card); } + wrefresh(card->frame->shape); + + return; +} + +void draw_stack(struct stack *stack) { + if (!empty(stack)) { + struct stack *iterator = stack; + while (iterator != NULL) { + draw_card(iterator->card); + iterator = iterator->next; + } + } + + return; +} + +void draw_game(struct deck *deck) { + draw_stack(deck->stock); + draw_stack(deck->waste_pile); + + draw_stack(deck->foundation_0); + draw_stack(deck->foundation_1); + draw_stack(deck->foundation_2); + draw_stack(deck->foundation_3); + + draw_stack(deck->maneuvre_0); + draw_stack(deck->maneuvre_1); + draw_stack(deck->maneuvre_2); + draw_stack(deck->maneuvre_3); + draw_stack(deck->maneuvre_4); + draw_stack(deck->maneuvre_5); + draw_stack(deck->maneuvre_6); return; } diff --git a/lib/display.h b/lib/display.h index 4100c41..69529ae 100644 --- a/lib/display.h +++ b/lib/display.h @@ -2,6 +2,7 @@ #define DISPLAY_H #include "card.h" +#include "deck.h" #define EMPTY_STACKS_NUMBER 13 @@ -24,5 +25,7 @@ void draw_suit(struct card *); void draw_front(struct card *); void draw_back(struct card *); void draw_card(struct card *); +void draw_stack(struct stack *); +void draw_game(struct deck *); #endif