From 0ea190c39f036352e5b73f025896608fa9fed685 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sat, 3 Apr 2010 04:11:27 -0300 Subject: [PATCH] Added initial display code. --- lib/display.c | 21 +++++++++++++++++++++ lib/display.h | 11 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lib/display.c create mode 100644 lib/display.h diff --git a/lib/display.c b/lib/display.c new file mode 100644 index 0000000..982fb0d --- /dev/null +++ b/lib/display.c @@ -0,0 +1,21 @@ +#include +#include +#include +#include "card.h" +#include "display.h" + +char *card_suit(enum suit suit) { + char *card_suit; + + card_suit = malloc(5 * sizeof(card_suit)); + + switch(suit) { + case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); + case SPADES: strcpy(card_suit, SPADES_SYMBOL); + case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); + case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); + default: strcpy(card_suit, "?"); + } + + return(card_suit); +} diff --git a/lib/display.h b/lib/display.h new file mode 100644 index 0000000..e2a651f --- /dev/null +++ b/lib/display.h @@ -0,0 +1,11 @@ +#ifndef DISPLAY_H +#define DISPLAY_H + +#define DIAMONDS_SYMBOL "\u2666" +#define SPADES_SYMBOL "\u2660" +#define HEARTS_SYMBOL "\u2665" +#define CLUBS_SYMBOL "\u2663" + +char *card_suit(enum suit); + +#endif