aboutsummaryrefslogtreecommitdiff
path: root/wonder.c
diff options
context:
space:
mode:
Diffstat (limited to 'wonder.c')
-rw-r--r--wonder.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/wonder.c b/wonder.c
index 54ecba6..36923ce 100644
--- a/wonder.c
+++ b/wonder.c
@@ -10,7 +10,7 @@ int data_getwonder(int p);
int data_getwonderside(int p);
void io_printborder(int x, int y);
int io_printtext(int xorigin, int y, int width, char* text);
-void io_printcard(int x, int y, int wonder, int stage);
+int io_printcard(int x, int y, int wonder, int stage);
void io_printname(int x, int y, int era, int card);
int data_getwonderstages(int p);
char* cat(char a[], char b[]);
@@ -18,25 +18,26 @@ char* itoa(int i);
int io_getkey();
void io_clearscreen();
int* data_getbuilt(int p);
+void io_printplain(int x, int y, char *s);
-int wonder_hasstage(int wonder, int side, int stage)
+int wonder_numstages(int player)
{
- if(side == 0 && stage > 2 || stage > 3) return 0;
- int *cost = cards_getcost(wonder, stage+1+side*3);
- int i;
- int has = 0;
- for(i = 0; i < NUMPRODUCTS; i++)
- if(cost[i]) has = 1;
- return has;
+ int side = data_getwonderside(player);
+ int wonder = data_getwonder(player);
+ if(side == 0) return 3;
+ if(wonder == 9) return 4;
+ if(wonder == 3) return 2;
+ return 3;
}
-void print_wonder(int x, int y, int player, int cursor)
+int print_wonder(int x, int y, int player, int cursor)
{
+// if(cursor != -1) cursor = cursor % wonder_numstages(player);
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++) {
+ for(i = 0; i < wonder_numstages(player); i++) {
char *text = cat("Stage ", itoa(i+1));
if(data_getwonderstages(player) > i)
text = cat(text, " (complete)");
@@ -58,15 +59,20 @@ void print_wonder(int x, int y, int player, int cursor)
if(i == 0) y--;
//Info about component
- if(wonder_hasstage(data_getwonder(player), data_getwonderside(player), cursor))
- io_printcard(x, y, data_getwonder(player), cursor+1+3*data_getwonderside(player));
+ if(cursor >= 0 && cursor < wonder_numstages(player))
+ return io_printcard(x, y, data_getwonder(player), cursor+1+3*data_getwonderside(player));
}
-void print_wondersmall(int x, int y, int player)
+//dir is 0 for none, 1 for east, 2 for west
+int print_wondersmall(int x, int y, int player, int selected, int dir)
{
io_printborder(x, y++);
+ if(selected) io_printplain(28, y, "*");
+ if(dir == 1) io_printplain(29, y, "East");
+ if(dir == 2) io_printplain(29, y, "West");
y = io_printtext(x, y, 29, cards_getname(data_getwonder(player), 0));
io_printborder(x, y);
+ return y;
}
void wonder_selected(int player)
@@ -84,7 +90,7 @@ void wonder_selected(int player)
default: break;
}
if(cursor < 0) cursor = 0;
- if(! wonder_hasstage(data_getwonder(player), data_getwonderside(player), cursor))
+ if(cursor >= wonder_numstages(player))
cursor--;
}
}
bgstack15