aboutsummaryrefslogtreecommitdiff
path: root/player_turn.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-02-18 19:51:17 -0500
committerNathan Vance <nathav63@gmail.com>2015-02-18 19:51:17 -0500
commitd43d5b206ae3393a19b21c36d2b8ba443ed0e121 (patch)
treea6607af121caf8a79e528ae20d6786e108136d84 /player_turn.c
parentadded data to keep track of hands and what's been built (diff)
download7w-d43d5b206ae3393a19b21c36d2b8ba443ed0e121.tar.gz
7w-d43d5b206ae3393a19b21c36d2b8ba443ed0e121.tar.bz2
7w-d43d5b206ae3393a19b21c36d2b8ba443ed0e121.zip
Added a view for the hand
Diffstat (limited to 'player_turn.c')
-rw-r--r--player_turn.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/player_turn.c b/player_turn.c
new file mode 100644
index 0000000..8c0f889
--- /dev/null
+++ b/player_turn.c
@@ -0,0 +1,36 @@
+#include "7w.h"
+
+int* data_gethand(int p);
+int data_getera();
+void io_printhand(int x, int y, int player, int cursor);
+void io_printcard(int x, int y, int era, int card);
+int io_getkey();
+void data_passturn();
+void io_clearscreen();
+void data_nextera();
+
+void player_turn(int player)
+{
+ int *hand = data_gethand(player);
+ int numcards;
+ for(numcards = 0; numcards < 7 && hand[numcards] > -1; numcards++);
+ int cursor = 0;
+ while(1) {
+ io_clearscreen();
+ io_printhand(0, 0, player, cursor);
+ io_printcard(0, 8, data_getera(), hand[cursor]);
+ switch(io_getkey()) {
+ case UP: cursor--;
+ break;
+ case DOWN: cursor++;
+ break;
+ case RIGHT: data_passturn();
+ break;
+ case ENTER: data_nextera();
+ break;
+ default: break;
+ }
+ if(cursor < 0) cursor = numcards-1;
+ if(cursor >= numcards) cursor = 0;
+ }
+}
bgstack15