aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-02-20 13:23:57 -0500
committerNathan Vance <nathav63@gmail.com>2015-02-20 13:23:57 -0500
commit1d79e77722dd8f6a1f0f08128bdd9b361e309f55 (patch)
tree7e085fa54e44b1424b8e1e36db0feb3b3d1c7898
parentadded a basic view for wonders (diff)
download7w-1d79e77722dd8f6a1f0f08128bdd9b361e309f55.tar.gz
7w-1d79e77722dd8f6a1f0f08128bdd9b361e309f55.tar.bz2
7w-1d79e77722dd8f6a1f0f08128bdd9b361e309f55.zip
Started backend for game view
-rw-r--r--data.c25
-rw-r--r--view.c12
-rw-r--r--wonder.c3
3 files changed, 38 insertions, 2 deletions
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;
+}
diff --git a/view.c b/view.c
new file mode 100644
index 0000000..beb62aa
--- /dev/null
+++ b/view.c
@@ -0,0 +1,12 @@
+#include "7w.h"
+
+void print_wonder(int x, int y, int player, int cursor);
+void io_printcard(int x, int y, int era, int card);
+void io_printhand(int x, int y, int player, int cursor);
+void io_clearscreen();
+int data_numplayers();
+
+void view_refresh(int focus, int cursor)
+{
+
+}
diff --git a/wonder.c b/wonder.c
index 282fe3f..5fa2cc2 100644
--- a/wonder.c
+++ b/wonder.c
@@ -4,6 +4,8 @@ int* cards_getcost(int wonder, int stage); //remember the stage offset!
int* cards_getproduction(int wonder, int stage);
char* cards_getname(int wonder, int stage); //stage should always be 0
char* cards_specialmessage(int wonder, int stage);
+char* getname(int res);
+int cards_gettype(int wonder, int stage); //stage is 0
int data_getwonder(int p);
int data_getwonderside(int p);
void io_printborder(int x, int y);
@@ -30,6 +32,7 @@ void print_wonder(int x, int y, int player, int cursor)
{
io_printborder(x, y++);
y = io_printtext(x, y, 29, cards_getname(data_getwonder(player), 0));
+ y = io_printtext(x, y, 29, cat("Produces 1 ", getname(cards_gettype(data_getwonder(player), 0))));
int i;
for(i = 0; wonder_hasstage(data_getwonder(player), data_getwonderside(player), i); i++) {
char *text = cat("Stage ", itoa(i+1));
bgstack15