2010-04-13 04:07:00 +00:00
|
|
|
#include <stdlib.h>
|
2010-04-13 02:42:21 +00:00
|
|
|
#include "../lib/util.h"
|
|
|
|
#include "../lib/game.h"
|
2010-04-20 04:10:42 +00:00
|
|
|
#include "../lib/cursor.h"
|
2010-04-13 04:07:00 +00:00
|
|
|
#include "../lib/keyboard.h"
|
2010-03-31 05:21:17 +00:00
|
|
|
|
2011-02-06 01:42:14 +00:00
|
|
|
extern struct deck *deck;
|
|
|
|
|
2010-03-31 05:21:17 +00:00
|
|
|
int main(int argc, const char *argv[]) {
|
2010-04-13 04:07:00 +00:00
|
|
|
int option;
|
2010-04-20 04:10:42 +00:00
|
|
|
struct cursor *cursor;
|
2010-04-13 04:07:00 +00:00
|
|
|
|
2010-04-12 05:56:28 +00:00
|
|
|
initialize_curses();
|
2010-03-31 05:21:17 +00:00
|
|
|
|
2010-04-13 04:07:00 +00:00
|
|
|
greet_player();
|
|
|
|
|
2010-04-20 04:10:42 +00:00
|
|
|
while (option != KEY_SPACEBAR) {
|
2010-04-13 04:07:00 +00:00
|
|
|
switch (option = getch()) {
|
|
|
|
case KEY_SPACEBAR:
|
|
|
|
initialize_game();
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
case 'Q':
|
|
|
|
end_curses();
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-20 04:10:42 +00:00
|
|
|
allocate_cursor(&cursor);
|
|
|
|
initialize_cursor(cursor);
|
|
|
|
draw_cursor(cursor);
|
|
|
|
|
2010-04-13 04:07:00 +00:00
|
|
|
while (1) {
|
2010-04-20 04:10:42 +00:00
|
|
|
switch (option = getch()) {
|
|
|
|
case 'h':
|
|
|
|
case KEY_LEFT:
|
|
|
|
move_cursor(cursor, LEFT);
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
case KEY_DOWN:
|
|
|
|
move_cursor(cursor, DOWN);
|
|
|
|
break;
|
|
|
|
case 'k':
|
|
|
|
case KEY_UP:
|
|
|
|
move_cursor(cursor, UP);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
case KEY_RIGHT:
|
|
|
|
move_cursor(cursor, RIGHT);
|
|
|
|
break;
|
2010-04-20 17:11:16 +00:00
|
|
|
case KEY_SPACEBAR:
|
|
|
|
if (cursor_on_stock(cursor)) {
|
|
|
|
handle_stock_event();
|
|
|
|
} else {
|
2010-04-22 04:50:19 +00:00
|
|
|
handle_card_movement(cursor);
|
2010-04-20 17:11:16 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-04-20 04:10:42 +00:00
|
|
|
case 'q':
|
|
|
|
case 'Q':
|
|
|
|
end_curses();
|
2011-02-06 01:42:14 +00:00
|
|
|
print_deck(deck);
|
2010-04-20 04:10:42 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2010-04-13 04:07:00 +00:00
|
|
|
}
|
2010-04-03 03:32:19 +00:00
|
|
|
|
2010-04-12 05:56:28 +00:00
|
|
|
return(0);
|
2010-03-31 05:21:17 +00:00
|
|
|
}
|