2010-04-03 07:11:27 +00:00
|
|
|
#include <ncurses.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <string.h>
|
2010-04-03 18:26:21 +00:00
|
|
|
#include <locale.h>
|
2010-04-03 07:11:27 +00:00
|
|
|
#include "card.h"
|
|
|
|
#include "display.h"
|
|
|
|
|
2010-04-03 18:26:21 +00:00
|
|
|
void init_curses() {
|
|
|
|
setlocale(LC_ALL, ""); /* supporting unicode characters */
|
|
|
|
initscr(); /* initialize the terminal in curses mode */
|
|
|
|
raw(); /* disable line buffers */
|
|
|
|
noecho(); /* character echo is unnecessary */
|
|
|
|
keypad(stdscr, TRUE); /* enable F and arrow keys */
|
|
|
|
}
|
|
|
|
|
2010-04-03 07:11:27 +00:00
|
|
|
char *card_suit(enum suit suit) {
|
|
|
|
char *card_suit;
|
|
|
|
|
|
|
|
card_suit = malloc(5 * sizeof(card_suit));
|
|
|
|
|
|
|
|
switch(suit) {
|
2010-04-03 18:24:10 +00:00
|
|
|
case DIAMONDS: strcpy(card_suit, DIAMONDS_SYMBOL); break;
|
|
|
|
case SPADES: strcpy(card_suit, SPADES_SYMBOL); break;
|
|
|
|
case HEARTS: strcpy(card_suit, HEARTS_SYMBOL); break;
|
|
|
|
case CLUBS: strcpy(card_suit, CLUBS_SYMBOL); break;
|
2010-04-03 07:11:27 +00:00
|
|
|
default: strcpy(card_suit, "?");
|
|
|
|
}
|
|
|
|
|
|
|
|
return(card_suit);
|
|
|
|
}
|