aboutsummaryrefslogtreecommitdiff
path: root/player_turn.c
blob: 8c0f889ca109687ccbf3647656b665a8ced45e6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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