diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-02-21 18:06:11 -0500 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-02-21 18:06:11 -0500 |
commit | e723087996663d5a1461297533e57bd2d8174585 (patch) | |
tree | dfd2584267d434c97dd543e8dc0d354a2060f75b /data.c | |
parent | Added view for all wonders (diff) | |
download | 7w-e723087996663d5a1461297533e57bd2d8174585.tar.gz 7w-e723087996663d5a1461297533e57bd2d8174585.tar.bz2 7w-e723087996663d5a1461297533e57bd2d8174585.zip |
Major view improvements
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 39 |
1 files changed, 23 insertions, 16 deletions
@@ -5,7 +5,6 @@ int* getdeck(int era, int numplayers); int* cards_getproduction(int era, int card); int cards_gettype(int era, int card); int* get_intarray(int size); -void array_cpy(int *a, int *b, int len); //copies b to a void shuffle(int *deck, int n); #define MISC 3 @@ -16,16 +15,33 @@ static int player[7][4][7]; //3 eras and extra stuff (wonder, wonder side, wonde static int hands[7][7]; static int numplayers; static int era; +static int turn; + +void data_sorthands() +{ + int i, j, k, type, buffer[7]; + for(i = 0; i < numplayers; i++) { + k = 0; + for(type = 0; type <= 7; type++) { + for(j = 0; j < 7; j++) { + if(cards_gettype(era, hands[i][j]) == type) buffer[k++] = hands[i][j]; + } + } + for(k = 0; k < 7; k++) hands[i][k] = buffer[k]; + } +} void data_nextera() { if(era == 2) return; era++; + turn = 0; int i, j, k; k = 0; for(i = 0; i < numplayers; i++) for(j = 0; j < 7; j++) hands[i][j] = decks[era][k++]; + data_sorthands(); } void data_distributewonders() @@ -61,25 +77,16 @@ void data_init(int n) void data_passturn() { //remember, player numbers are arranged clockwise - int buffer[7], i; - if(era == 0 || era == 2) { //pass to the left - array_cpy(buffer, hands[numplayers-1], 7); - for(i = numplayers-1; i > 0; i--) { - array_cpy(hands[i], hands[i-1], 7); - } - array_cpy(hands[0], buffer, 7); - } else { //pass to the right - array_cpy(buffer, hands[0], 7); - for(i = 0; i < numplayers-1; i++) { - array_cpy(hands[i], hands[i+1], 7); - } - array_cpy(hands[numplayers-1], buffer, 7); - } + if(era == 0 || era == 2) //pass to the left + turn++; + else //pass to the right + turn--; + if(turn < 0) turn = numplayers-1; } int* data_gethand(int p) { - return hands[p]; + return hands[(p+turn)%numplayers]; } int data_getera() |