Smarter stack erasing.

This commit is contained in:
Murilo Pereira 2011-05-15 20:39:22 -03:00
parent 18a78c9713
commit f4e9a10572

View File

@ -55,11 +55,19 @@ static char *card_value(enum value value) {
return(card_value); return(card_value);
} }
void erase_card(struct card *card) {
werase(card->frame->window);
wbkgd(card->frame->window, WHITE_ON_GREEN);
wrefresh(card->frame->window);
}
void erase_stack(struct stack *stack) { void erase_stack(struct stack *stack) {
for (; stack; stack = stack->next) { if (maneuvre_stack(stack)) {
werase(stack->card->frame->window); for (; stack; stack = stack->next) {
wbkgd(stack->card->frame->window, WHITE_ON_GREEN); erase_card(stack->card);
wrefresh(stack->card->frame->window); }
} else {
erase_card(stack->card);
} }
} }
@ -111,13 +119,8 @@ void draw_card(struct card *card) {
void draw_stack(struct stack *stack) { void draw_stack(struct stack *stack) {
erase_stack(stack); erase_stack(stack);
if (empty(stack)) { if (empty(stack)) {
WINDOW *empty_stack = newwin(FRAME_HEIGHT, box(stack->card->frame->window, 0, 0);
FRAME_WIDTH, wrefresh(stack->card->frame->window);
stack->card->frame->begin_y,
stack->card->frame->begin_x);
box(empty_stack, 0, 0);
wrefresh(empty_stack);
delwin(empty_stack);
} else { } else {
if (maneuvre_stack(stack)) { if (maneuvre_stack(stack)) {
struct stack *reversed_stack = reverse(stack); struct stack *reversed_stack = reverse(stack);