Adding card_value().

This commit is contained in:
Murilo Soares Pereira 2010-04-03 15:49:57 -03:00
parent a51e1c8b79
commit c4ce09551e
2 changed files with 27 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <locale.h> #include <locale.h>
#include "frame.h"
#include "card.h" #include "card.h"
#include "display.h" #include "display.h"
@ -28,3 +29,28 @@ char *card_suit(enum suit suit) {
return(card_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);
}

View File

@ -8,5 +8,6 @@
void init_curses(); void init_curses();
char *card_suit(enum suit); char *card_suit(enum suit);
char *card_value(enum value);
#endif #endif