From 1d79e77722dd8f6a1f0f08128bdd9b361e309f55 Mon Sep 17 00:00:00 2001 From: Nathan Vance Date: Fri, 20 Feb 2015 13:23:57 -0500 Subject: Started backend for game view --- data.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index 41317b4..8be97a9 100644 --- a/data.c +++ b/data.c @@ -3,6 +3,7 @@ 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); @@ -27,14 +28,14 @@ void data_nextera() hands[i][j] = decks[era][k++]; } -void data_distributewonders(int n) +void data_distributewonders() { int i; int wonders[7]; for(i = 0; i < 7; i++) wonders[i] = i+3; //wonders are numbered 3-9 shuffle(wonders, 7); - for(i = 0; i < n; i++) { + for(i = 0; i < numplayers; i++) { player[i][3][0] = wonders[i]; player[i][3][1] = rand()%2; } @@ -101,6 +102,11 @@ int data_getwonderstages(int p) return player[p][3][2]; } +int data_numplayers() +{ + return numplayers; +} + void data_build(int p, int card) { int i; @@ -203,3 +209,18 @@ int data_canafford(int p, int *cost) if(data_iszerocost(cost)) return 2; return recurse(cost, data_getindefinites(p)); } + +int* data_getbuilt(int p) +{ + int *ret = get_intarray(42); + int type, e, c; + int i = 0; + for(type = 0; type <= 7; type++) + for(e = 0; e < 3; e++) + for(c = 0; c < 7; c++) + if(cards_gettype(e, player[p][e][c]) == type) { + ret[i++] = e; + ret[i++] = player[p][e][c]; + } + return ret; +} -- cgit