From c4ce09551ee2cb93927e327b0b9f0b6f32f0bcd2 Mon Sep 17 00:00:00 2001 From: Murilo Soares Pereira Date: Sat, 3 Apr 2010 15:49:57 -0300 Subject: [PATCH] Adding card_value(). --- lib/display.c | 26 ++++++++++++++++++++++++++ lib/display.h | 1 + 2 files changed, 27 insertions(+) diff --git a/lib/display.c b/lib/display.c index 564e000..421a410 100644 --- a/lib/display.c +++ b/lib/display.c @@ -2,6 +2,7 @@ #include #include #include +#include "frame.h" #include "card.h" #include "display.h" @@ -28,3 +29,28 @@ char *card_suit(enum suit suit) { return(card_suit); } + +char *card_value(enum value value) { + char *card_value; + + card_value = malloc(2 * sizeof(card_value)); + + switch(value) { + case TWO: card_value = "2"; break; + case THREE: card_value = "3"; break; + case FOUR: card_value = "4"; break; + case FIVE: card_value = "5"; break; + case SIX: card_value = "6"; break; + case SEVEN: card_value = "7"; break; + case EIGHT: card_value = "8"; break; + case NINE: card_value = "9"; break; + case TEN: card_value = "10"; break; + case JACK: card_value = "J"; break; + case QUEEN: card_value = "Q"; break; + case KING: card_value = "K"; break; + case ACE: card_value = "A"; break; + default: card_value = "?"; + } + + return(card_value); +} diff --git a/lib/display.h b/lib/display.h index 091643f..048178b 100644 --- a/lib/display.h +++ b/lib/display.h @@ -8,5 +8,6 @@ void init_curses(); char *card_suit(enum suit); +char *card_value(enum value); #endif