diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-04-02 13:10:41 -0400 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-04-02 13:10:41 -0400 |
commit | c9bec9ecc7dc8d0ccc8b0331b4cdf2bd8c77011f (patch) | |
tree | 3f8a1b0daf0e34b6e072d0f7e669fb5d3ba92b56 | |
parent | Added more special actions (diff) | |
download | 7w-c9bec9ecc7dc8d0ccc8b0331b4cdf2bd8c77011f.tar.gz 7w-c9bec9ecc7dc8d0ccc8b0331b4cdf2bd8c77011f.tar.bz2 7w-c9bec9ecc7dc8d0ccc8b0331b4cdf2bd8c77011f.zip |
Halicarnassus bug fixes
-rw-r--r-- | data.c | 23 | ||||
-rw-r--r-- | io.c | 38 | ||||
-rw-r--r-- | player_turn.c | 10 | ||||
-rw-r--r-- | special_actions.c | 6 | ||||
-rw-r--r-- | trade.c | 1 | ||||
-rw-r--r-- | view.c | 8 |
6 files changed, 55 insertions, 31 deletions
@@ -58,9 +58,6 @@ void data_discard(int p, int card); void data_nextera() { int i, j, k; - for(i = 0; i < numplayers; i++) { - data_discard((i+numplayers-turn)%numplayers, hands[i][0]); - } war(); if(era == 2) data_endgame(); era++; @@ -85,8 +82,8 @@ void data_distributewonders() for(i = 0; i < numplayers; i++) { player[i][3][0] = wonders[i]; player[i][3][1] = rand()%2; - player[0][3][0] = 7; //delete these lines later - player[0][3][1] = 0; //this one too! + player[0][3][0] = 8; //delete these lines later + player[0][3][1] = 1; //this one too! } } @@ -117,12 +114,18 @@ void data_init(int n) void data_endturn() { //remember, player numbers are arranged clockwise + totturns++; + int i, j; + if(totturns == 6) { //Do this first for some special moves + for(i = 0; i < numplayers; i++) { + data_discard((i+numplayers-turn)%numplayers, hands[i][0]); + } + } if(era == 0 || era == 2) //pass to the left turn++; else //pass to the right turn--; if(turn < 0) turn = numplayers-1; - int i, j; for(i = 0; i < numplayers; i++) { if(buffer[i][0] == -2) { player[i][3][2]++; @@ -140,7 +143,6 @@ void data_endturn() buffer[i][1] = 0; buffer[i][2] = 0; } - totturns++; if(totturns == 6) data_nextera(); } @@ -332,6 +334,9 @@ void data_discard(int p, int card) void data_freebuild(int p, int e, int card) { + int i; + for(i = 0; player[p][e][i] != -1; i++); + player[p][e][i] = card; data_addgold(cards_getproduction(e, card)[GOLD], p); data_addvps(cards_getproduction(e, card)[VP], p); data_addgold(get_special(e, card, p)[1], p); @@ -340,8 +345,10 @@ void data_freebuild(int p, int e, int card) void data_build(int p, int card) { buffer[p][0] = card; //will be added to player array at end of turn + data_addgold(cards_getproduction(era, card)[GOLD], p); + data_addvps(cards_getproduction(era, card)[VP], p); + data_addgold(get_special(era, card, p)[1], p); data_addgold(cards_getcost(era, card)[GOLD] * -1, p); - data_freebuild(p, era, card); data_remove(p, card); } @@ -189,24 +189,36 @@ int io_printcard(int x, int y, int era, int card, int player) return y; } -int io_printhand(int x, int y, int player, int cursor) +int* data_getdiscards(); +int print_cards(int x, int y, int *cards, int cursor); + +int io_printhand(int x, int y, int player, int cursor, int mode) //mode 0 is normal, 1 is discard search { - int *hand = data_gethand(player); + int *hand; + if(mode) hand = data_getdiscards(); + else hand = data_gethand(player); int i; io_printborder(x, y++, 28); - y = io_printtext(x, y, 28, " Hand"); - for(i = 0; hand[i] != -1 && i < 7; i++) { - io_printname(x, y++, data_getera(), hand[i]); - if(i == cursor) { - mvprintw(y-1, x+25, "*"); + if(mode) { + y = io_printtext(x, y, 28, " Discards"); + y = print_cards(x, y, hand, cursor); + y = io_printcard(x, y, hand[cursor*2], hand[cursor*2+1], player); + } + else { + y = io_printtext(x, y, 28, " Hand"); + for(i = 0; hand[i] != -1 && i < 7; i++) { + io_printname(x, y++, data_getera(), hand[i]); + if(i == cursor) { + mvprintw(y-1, x+25, "*"); + } } + y = io_printtext(x, y, 28, " Trade..."); + if(i == cursor) + mvprintw(y-1, x+25, "*"); + else if(cursor >= 0 && cursor < 7 && hand[cursor] != -1) + y = io_printcard(x, y, data_getera(), hand[cursor], player); + else io_printborder(x, y++, 28); } - y = io_printtext(x, y, 28, " Trade..."); - if(i == cursor) - mvprintw(y-1, x+25, "*"); - else if(cursor >= 0 && cursor < 7 && hand[cursor] != -1) - y = io_printcard(x, y, data_getera(), hand[cursor], player); - else io_printborder(x, y++, 28); return y; } diff --git a/player_turn.c b/player_turn.c index 84a02e3..da2e6f7 100644 --- a/player_turn.c +++ b/player_turn.c @@ -14,7 +14,7 @@ int data_canafford(int p, int era, int card); int data_getwonder(int p); int data_getnextwonderstage(int p); int data_hasbuiltname(int p, int era, int card); -int view_refresh(int focus, int cursor, int player); +int view_refresh(int focus, int cursor, int player, int mode); int wonder_numstages(int player); int* cards_getcost(int era, int card); int data_numbuilt(int p); @@ -26,6 +26,7 @@ int trade_routine(int x, int y, int player); void trade_commit(int player); int data_spendfreebuild(); int postyn(int x, int y, char *message); +void halt(); int player_build(int focus, int cursor, int player, int y) { @@ -68,7 +69,7 @@ void player_turn(int player) int focus = data_numplayers(); while(1) { numcards = data_numcards(player)+1; //include trade option in hand - tradey = view_refresh(focus, cursor, player); + tradey = view_refresh(focus, cursor, player, 0); switch(io_getkey()) { case UP: cursor--; break; @@ -92,6 +93,9 @@ void player_turn(int player) break; case 'h': posthelp(); break; + case 'q': + if(postyn(61, tradey, "Are you sure you want to quit?")) halt(); + break; default: break; } if(focus < 0) focus = data_numplayers(); @@ -99,7 +103,7 @@ void player_turn(int player) if(focus == data_numplayers()) { if(cursor < 0) cursor = numcards-2; if(cursor >= numcards-1) { - if(trade_routine(61, view_refresh(focus, cursor, player), player)) cursor = 0; + if(trade_routine(61, view_refresh(focus, cursor, player, 0), player)) cursor = 0; else cursor = numcards-2; } } diff --git a/special_actions.c b/special_actions.c index fa8d013..babf6e2 100644 --- a/special_actions.c +++ b/special_actions.c @@ -10,9 +10,11 @@ int print_cards(int x, int y, int *cards, int cursor); int io_printtext(int xorigin, int y, int width, char* text); void io_printborder(int x, int y, int width); int io_getkey(); +int io_printcard(int x, int y, int wonder, int stage, int player); void posthelp(); int data_isai(int p); void data_setfreebuild(int p); +int view_refresh(int focus, int cursor, int player, int mode); void Halicarnassus(int player) { @@ -26,10 +28,8 @@ void Halicarnassus(int player) int bottom = 0; while(discards[numcards++] != -1 && numcards < 50); numcards /= 2; - io_printborder(x, y++, 28); - y = io_printtext(x, y, 28, " Discards"); while(1) { - bottom = print_cards(x, y, discards, cursor); + view_refresh(focus, cursor, player, 1); switch(io_getkey()) { case UP: cursor--; break; @@ -58,6 +58,7 @@ void trade_set(int player, int trade[3][GOLD]) for(i = 0; i < 3; i++) { for(j = 0; j < GOLD; j++) { tradebuffer[i][j] = trade[i][j]; + tradebuffer[i][GOLD] = 0; //we deal with gold in the method that calls this } } } @@ -2,7 +2,7 @@ int* print_wonder(int x, int y, int player, int cursor); int print_wondersmall(int x, int y, int player, int selected, int dir); -int io_printhand(int x, int y, int player, int cursor); +int io_printhand(int x, int y, int player, int cursor, int mode); int io_printcard(int x, int y, int wonder, int stage, int player); void io_clearscreen(); int data_numplayers(); @@ -29,17 +29,17 @@ int* view_printwonders(int focus, int cursor, int player) return ret; } -int view_refresh(int focus, int cursor, int player) +int view_refresh(int focus, int cursor, int player, int mode) //mode 0 is normal, 1 is discard search { int ret; int *card; io_clearscreen(); if(focus == data_numplayers()) { card = view_printwonders(player, -1, player); - ret = io_printhand(61, 0, player, cursor); + ret = io_printhand(61, 0, player, cursor, mode); } else { card = view_printwonders((focus+player)%data_numplayers(), cursor, player); - ret = io_printhand(61, 0, player, -1); + ret = io_printhand(61, 0, player, -1, mode); } if(card[0] != -1) ret = io_printcard(61, ret-1, card[0], card[1], player); |