diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-02-26 13:37:08 -0500 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-02-26 13:37:08 -0500 |
commit | 3bc64a91ce3478fdffcacf2ad5585c3922a4b187 (patch) | |
tree | ea1de35ce603809293c28982531332b9949776aa | |
parent | Trade ui implemented (diff) | |
download | 7w-3bc64a91ce3478fdffcacf2ad5585c3922a4b187.tar.gz 7w-3bc64a91ce3478fdffcacf2ad5585c3922a4b187.tar.bz2 7w-3bc64a91ce3478fdffcacf2ad5585c3922a4b187.zip |
Started adding support for special cards
-rw-r--r-- | cards.c | 4 | ||||
-rw-r--r-- | data.c | 12 | ||||
-rw-r--r-- | io.c | 13 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | specialcards.c | 96 | ||||
-rw-r--r-- | wonder.c | 6 |
6 files changed, 123 insertions, 9 deletions
@@ -330,7 +330,7 @@ void cards_init() cards_setname(1, 13, "Vineyard", COMMERCIAL); cards_setmessage(1, 14, "2 coins for each industry card of adjacent players or your own."); - cards_setname(1, 14, "Bazar", COMMERCIAL); + cards_setname(1, 14, "Bazaar", COMMERCIAL); cards_setcost(1, 15, STONE, 3); cards_setproduction(1, 15, SHIELD, 2); @@ -535,7 +535,7 @@ void cards_init() cards_setcost(2, 26, WOOD, 3); cards_setcost(2, 26, STONE, 1); cards_setcost(2, 26, CLOTH, 1); - cards_setmessage(2, 26, "1 vp for each structure card."); + cards_setmessage(2, 26, "1 vp for each structure card owned by adjacent players."); cards_setname(2, 26, "Magistrates Guild", GUILD); cards_setcost(2, 27, STONE, 2); @@ -14,7 +14,7 @@ int* trade_buffer(); #define DATAGOLD 0 static int decks[3][49]; -static int player[7][4][7]; //3 eras and extra stuff (wonder, wonder side, wonder stages completed, gold, military wins, defeats) +static int player[7][4][7]; //3 eras and extra stuff (wonder, wonder side, wonder stages completed, gold, military wins, defeats, vps(partial)) static int buffer[7][2]; static int hands[7][7]; static int numplayers; @@ -152,6 +152,11 @@ int data_getwonderstages(int p) return player[p][3][2]; } +int data_getdefeats(int p) +{ + return player[p][3][5]; +} + int data_getgold(int p) { return player[p][3][3] + turngoldbuffer[p]; @@ -163,6 +168,11 @@ void data_addgold(int amnt, int p) turngoldbuffer[p] += amnt; } +void data_addvps(int amnt, int p) +{ + player[p][3][6] += amnt; +} + int data_numplayers() { return numplayers; @@ -13,6 +13,7 @@ int* cards_getcouponed(int era, int card); char* cards_specialmessage(int era, int card); int data_getera(); int* data_gethand(int p); +int* get_special(int era, int card, int player); void io_init() { @@ -118,7 +119,7 @@ void io_printborder(int x, int y, int width) mvprintw(y, x+i, "#"); } -int io_printcard(int x, int y, int era, int card) +int io_printcard(int x, int y, int era, int card, int player) { io_printborder(x, y++, 28); if(cards_getname(era, card)[0] != '\0') @@ -175,6 +176,14 @@ int io_printcard(int x, int y, int era, int card) io_printname(x, y++, coupons[2], coupons[3]); } + int* special = get_special(era, card, player); + if(special[0] || special[1]) + { //print special (vp, gold) + mvprintw(y++, x, "# In your case, produces: #"); + mvprintw(y++, x, "# %2d victory points #", special[0]); + mvprintw(y++, x, "# %2d gold #", special[1]); + } + io_printborder(x, y, 28); return y; } @@ -198,7 +207,7 @@ int io_printhand(int x, int y, int player, int cursor) mvprintw(y-1, x+25, "*"); //trade_print(x, y, player, -1, -1); } - else if(cursed) io_printcard(x, y, data_getera(), hand[cursor]); + else if(cursed) io_printcard(x, y, data_getera(), hand[cursor], player); else io_printborder(x, y++, 28); return y; } @@ -4,7 +4,6 @@ void tester(); void io_init(); void cards_init(); -void io_printcard(int x, int y, int era, int card); void io_clearscreen(); int* getdeck(int era, int numplayers); void data_init(int num_players); diff --git a/specialcards.c b/specialcards.c new file mode 100644 index 0000000..20e9b24 --- /dev/null +++ b/specialcards.c @@ -0,0 +1,96 @@ +#include "7w.h" + +int data_geteast(int p); +int data_getwest(int p); +int* data_getbuilt(int p); +int cards_gettype(int era, int card); +int data_getwonderstages(int p); +int data_getdefeats(int p); + +int cardcounter(int *cards, int type) +{ + int sum = 0; + int i; + for(i = 0; cards[i] != -1; i+=2) { + if(cards_gettype(cards[i], cards[i+1]) == type) sum++; + } + return sum; +} + +int* get_special(int era, int card, int player) +{ + //formatted vp, gold + static int ret[2]; + ret[0] = ret[1] = 0; + switch(era*100+card) { + case 113: //Vineyard: 1 coin for each resource card of adjacent players or your own. + ret[1] += cardcounter(data_getbuilt(data_geteast(player)), RESOURCE); + ret[1] += cardcounter(data_getbuilt(data_getwest(player)), RESOURCE); + ret[1] += cardcounter(data_getbuilt(player), RESOURCE); + break; + case 114: //Bazaar: 2 coins for each industry card of adjacent players or your own. + ret[1] += cardcounter(data_getbuilt(data_geteast(player)), INDUSTRY); + ret[1] += cardcounter(data_getbuilt(data_getwest(player)), INDUSTRY); + ret[1] += cardcounter(data_getbuilt(player), INDUSTRY); + ret[1] *= 2; + break; + case 205: //Haven: 1 coin and 1 vp for each resource card. + ret[0] = ret[1] = cardcounter(data_getbuilt(player), RESOURCE); + break; + case 206: //Lighthouse: 1 coin and 1 vp for each commercial card. + ret[0] = ret[1] = cardcounter(data_getbuilt(player), COMMERCIAL); + break; + case 207: //Chamber Of Commerce: 2 coins and 2 vps for each industrial card. + ret[0] = ret[1] = cardcounter(data_getbuilt(player), INDUSTRY) * 2; + break; + case 208: //Arena: 3 coins and 1 vp for each completed wonder stage. + ret[1] = data_getwonderstages(player); + ret[0] = 3*ret[1]; + break; + case 218: //Workers Guild: 1 vp for each resource card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), RESOURCE); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), RESOURCE); + break; + case 219: //Craftmens Guild: 2 vps for each industrial card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), INDUSTRY); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), INDUSTRY); + ret[0] *= 2; + break; + case 220: //Traders Guild: 1 vp for each commercial card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), COMMERCIAL); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), COMMERCIAL); + break; + case 221: //Philosophers Guild: 1 vp for each scientific card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), SCIENTIFIC); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), SCIENTIFIC); + break; + case 222: //Spy Guild: 1 vp for each military card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), MILITARY); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), MILITARY); + break; + case 223: //Strategy Guild: 1 vp for each military defeat by adjacent players. + ret[0] += data_getdefeats(data_geteast(player)); + ret[0] += data_getdefeats(data_getwest(player)); + break; + case 224: //Shipowners Guild: 1 vp for each resource, industrial, and guild card. + ret[0] += cardcounter(data_getbuilt(player), RESOURCE); + ret[0] += cardcounter(data_getbuilt(player), INDUSTRY); + ret[0] += cardcounter(data_getbuilt(player), GUILD); + break; + case 225: //Scientists Guild: Counts as either a compass, gear or tablet. + ret[0] = ret[1] = 0; + break; + case 226: //Magistrates Guild: 1 vp for each structure card owned by adjacent players. + ret[0] += cardcounter(data_getbuilt(data_geteast(player)), STRUCTURE); + ret[0] += cardcounter(data_getbuilt(data_getwest(player)), STRUCTURE); + break; + case 227: //Builders Guild: 1 vp for each completed wonder stage by you or adjacent players. + ret[0] += data_getwonderstages(data_geteast(player)); + ret[0] += data_getwonderstages(data_getwest(player)); + ret[0] += data_getwonderstages(player); + break; + default: ret[0] = ret[1] = 0; + break; + } + return ret; +} @@ -10,7 +10,7 @@ int data_getwonder(int p); int data_getwonderside(int p); void io_printborder(int x, int y, int width); int io_printtext(int xorigin, int y, int width, char* text); -int io_printcard(int x, int y, int wonder, int stage); +int io_printcard(int x, int y, int wonder, int stage, int player); void io_printname(int x, int y, int era, int card); int data_getwonderstages(int p); int data_getgold(int p); @@ -95,9 +95,9 @@ int print_wonder(int x, int y, int player, int cursor) //Info about component if(cursor >= 0 && cursor < wonder_numstages(player)) - return io_printcard(x, y, data_getwonder(player), cursor+1+3*data_getwonderside(player)); + return io_printcard(x, y, data_getwonder(player), cursor+1+3*data_getwonderside(player), player); if(cursor >= wonder_numstages(player)) - return io_printcard(x, y, built[print], built[print+1]); + return io_printcard(x, y, built[print], built[print+1], player); } //dir is 0 for none, 1 for east, 2 for west |