From 6946460b7752ddd9b4f77ff4d28dbff9bda247b1 Mon Sep 17 00:00:00 2001 From: Nathan Vance Date: Thu, 19 Mar 2015 17:47:35 -0400 Subject: ui and trading bug fixes --- data.c | 20 +++++++++++++++++++- main.c | 2 +- player_turn.c | 3 +++ trade.c | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/data.c b/data.c index c7cb591..6ad09f2 100644 --- a/data.c +++ b/data.c @@ -19,6 +19,7 @@ char* cards_getname(int wonder, int stage); void io_printborder(int x, int y, int width); int io_printtext(int xorigin, int y, int width, char* text); int io_getkey(); +int data_haswonderstage(int p, int wonder, int stage); #define MISC 3 #define DATAGOLD 0 @@ -314,6 +315,7 @@ void data_removedefinites(int p, int *cost) } } + int** data_getindefinites(int p) { int i, j, k, l, m, *prod; @@ -338,6 +340,22 @@ int** data_getindefinites(int p) } } } + if(data_haswonderstage(p, 4, 2) || data_haswonderstage(p, 4, 4)) { + m = 0; + prod = cards_getproduction(1, 12); //production for caravansery + for(l = 0; l < GOLD; l++) { + if(prod[l]) ret[k][m++] = l; + } + k++; + } + if(data_haswonderstage(p, 4, 5)) { + m = 0; + prod = cards_getproduction(1, 11); //production for forum + for(l = 0; l < GOLD; l++) { + if(prod[l]) ret[k][m++] = l; + } + k++; + } return ret; } @@ -348,7 +366,7 @@ int* data_gettradables(int p) for(i = 0; i < GOLD+1; i++) ret[i] = 0; for(i = 0; i < 3; i++) { for(j = 0; j < 7; j++) { - if(player[p][i][j] != -1) { + if(player[p][i][j] != -1 && (cards_gettype(i, player[p][i][j]) == RESOURCE || cards_gettype(i, player[p][i][j]) == INDUSTRY)) { prod = cards_getproduction(i, player[p][i][j]); for(k = 0; k < GOLD; k++) { ret[k] += prod[k]; diff --git a/main.c b/main.c index b629a73..f743298 100644 --- a/main.c +++ b/main.c @@ -40,7 +40,7 @@ main() { io_init(); cards_init(); - data_init(7); + data_init(4); main_routine(); halt(); } diff --git a/player_turn.c b/player_turn.c index ba35953..f4bf19e 100644 --- a/player_turn.c +++ b/player_turn.c @@ -71,8 +71,10 @@ void player_turn(int player) case DOWN: cursor++; break; case RIGHT: focus++; + cursor = 0; break; case LEFT: focus--; + cursor = 0; break; case ENTER: if(player_build(focus, cursor, player, tradey)) { @@ -82,6 +84,7 @@ void player_turn(int player) } break; case '\t': focus = (focus+1)%(data_numplayers()+1); + cursor = 0; break; case 'h': posthelp(); break; diff --git a/trade.c b/trade.c index 4bfb625..002dcac 100644 --- a/trade.c +++ b/trade.c @@ -94,7 +94,7 @@ void trade_print(int x, int y, int player, int cursorx, int cursory) y = io_printtext(x, y, width, s); int i; for(i = 0; i < GOLD+1; i++) { - sprintf(s, "%-7s %d %c| %-7s %d %c", getname(i), west[i], (cursorx == 1 && cursory == i)? '*' : ' ', getname(i), east[i], (cursorx == 0 && cursory == i)? '*' : ' '); + sprintf(s, "%-7s%2d %c| %-7s %d %c", getname(i), west[i], (cursorx == 1 && cursory == i)? '*' : ' ', getname(i), east[i], (cursorx == 0 && cursory == i)? '*' : ' '); y = io_printtext(x, y, width, s); if(tradebuffer[1][i]) io_printcolor(x+10, y-1, 31, itoa(west[i])); -- cgit