tty-solitaire/lib/card.c

54 lines
907 B
C
Raw Normal View History

2010-04-01 05:28:00 +00:00
#include <ncurses.h>
#include <malloc.h>
#include "card.h"
2010-04-01 05:28:00 +00:00
void allocate_card(struct card **card) {
*card = malloc(sizeof(**card));
2010-04-01 05:28:00 +00:00
allocate_frame(&((*card)->frame));
2010-04-01 05:28:00 +00:00
return;
}
void initialize_card(struct card *card) {
initialize_frame(card->frame);
2010-04-01 13:13:37 +00:00
card->value = NO_VALUE;
card->suit = NO_SUIT;
card->face = NO_FACE;
2010-04-01 05:28:00 +00:00
return;
2010-04-01 05:28:00 +00:00
}
void delete_card(struct card *card) {
delete_frame(card->frame);
free(card);
return;
}
void set_card(struct card *card,
enum value value,
enum suit suit,
enum face face,
2010-04-01 05:28:00 +00:00
int start_y,
int start_x) {
set_frame(card->frame, start_y, start_x);
card->value = value;
card->suit = suit;
card->face = face;
2010-04-01 05:28:00 +00:00
return;
}
void expose_card(struct card *card) {
card->face = EXPOSED;
return;
}
void cover_card(struct card *card) {
card->face = COVERED;
return;
}