aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c34
-rw-r--r--special_cards.c (renamed from specialcards.c)0
-rw-r--r--view.c16
-rw-r--r--wonder.c19
4 files changed, 56 insertions, 13 deletions
diff --git a/data.c b/data.c
index 81bfe56..da23108 100644
--- a/data.c
+++ b/data.c
@@ -25,6 +25,7 @@ int data_haswonderstage(int p, int wonder, int stage);
#define DATAGOLD 0
static int decks[3][49];
+static int discards[3][49];
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][3];
static int hands[7][7];
@@ -87,6 +88,9 @@ void data_init(int n)
for(j = 0; j < numplayers*7; j++)
decks[i][j] = deck[j];
}
+ for(i = 0; i < 3; i++)
+ for(j = 0; j < 49; j++)
+ discards[i][j] = -1;
era = -1;
data_nextera();
data_distributewonders(n);
@@ -240,7 +244,23 @@ int data_numplayers()
return numplayers;
}
-void data_discard(int p, int card)
+int** data_getdiscards()
+{
+ static int **ret;
+ int i;
+ for(i = 0; i < 3; i++)
+ ret[i] = discards[i];
+ return ret;
+}
+
+void data_deletediscard(int era, int card)
+{
+ int i;
+ for(i = 0; discards[era][i] != card && i < 48; i++);
+ discards[era][i] = -1;
+}
+
+void data_remove(int p, int card) //as in, removes it from the hand
{
int i;
int *hand = hands[(p+turn)%numplayers];
@@ -250,6 +270,14 @@ void data_discard(int p, int card)
for(i = 0; i < 7; i++) turngoldbuffer[i] = 0; //end of turn
}
+void data_discard(int p, int card)
+{
+ data_remove(p, card);
+ int i;
+ for(i = 0; discards[era][i] != -1 && i < 49; i++);
+ discards[era][i] = card;
+}
+
void data_build(int p, int card)
{
buffer[p][0] = card; //will be added to player array at end of turn
@@ -257,7 +285,7 @@ void data_build(int p, int card)
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_discard(p, card);
+ data_remove(p, card);
}
void data_buildwonder(int p, int card)
@@ -266,7 +294,7 @@ void data_buildwonder(int p, int card)
data_addgold(cards_getcost(data_getwonder(p), data_getwonderside(p)*3+1+data_getwonderstages(p))[GOLD] * -1, p);
data_addgold(cards_getproduction(data_getwonder(p), data_getwonderside(p)*3+1+data_getwonderstages(p))[GOLD], p);
data_addvps(cards_getproduction(data_getwonder(p), data_getwonderside(p)*3+1+data_getwonderstages(p))[VP], p);
- data_discard(p, card);
+ data_remove(p, card);
}
//0 is non producing, 1 produces one kind of resource, 2 produces multiple resources
diff --git a/specialcards.c b/special_cards.c
index b49e53c..b49e53c 100644
--- a/specialcards.c
+++ b/special_cards.c
diff --git a/view.c b/view.c
index 54c8ee8..88b8901 100644
--- a/view.c
+++ b/view.c
@@ -1,16 +1,18 @@
#include "7w.h"
-int print_wonder(int x, int y, int player, int cursor);
+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_printcard(int x, int y, int wonder, int stage, int player);
void io_clearscreen();
int data_numplayers();
void printmessage(int x, int y, int width);
int data_geteast(int p);
int data_getwest(int p);
-void view_printwonders(int focus, int cursor, int player)
+int* view_printwonders(int focus, int cursor, int player)
{
+ int *ret;
int num = data_numplayers();
int x, y, i, dir, p;
x = y = 0;
@@ -20,22 +22,26 @@ void view_printwonders(int focus, int cursor, int player)
if(p == data_geteast(player)) dir = 1;
if(p == data_getwest(player)) dir = 2;
if(focus == p)
- print_wonder(34, 0, p, cursor);
+ ret = print_wonder(34, 0, p, cursor);
y = print_wondersmall(x, y, p, focus == p, dir);
}
printmessage(0, y+2, 35);
+ return ret;
}
int view_refresh(int focus, int cursor, int player)
{
int ret;
+ int *card;
io_clearscreen();
if(focus == data_numplayers()) {
- view_printwonders(player, -1, player);
+ card = view_printwonders(player, -1, player);
ret = io_printhand(61, 0, player, cursor);
} else {
- view_printwonders((focus+player)%data_numplayers(), cursor, player);
+ card = view_printwonders((focus+player)%data_numplayers(), cursor, player);
ret = io_printhand(61, 0, player, -1);
}
+ if(card[0] != -1)
+ ret = io_printcard(61, ret-1, card[0], card[1], player);
return ret;
}
diff --git a/wonder.c b/wonder.c
index 252472d..dffceb4 100644
--- a/wonder.c
+++ b/wonder.c
@@ -36,7 +36,7 @@ int wonder_numstages(int player)
return 3;
}
-int print_wonder(int x, int y, int player, int cursor)
+int* print_wonder(int x, int y, int player, int cursor)
{
int i, j;
io_printborder(x, y++, 28);
@@ -97,10 +97,19 @@ int print_wonder(int x, int y, int player, int cursor)
io_printborder(x, y, 28);
//Info about component
- if(cursor >= 0 && cursor < wonder_numstages(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], player);
+ static int ret[2];
+ ret[0] = ret[1] = -1;
+ if(cursor >= 0 && cursor < wonder_numstages(player)) {
+ ret[0] = data_getwonder(player);
+ ret[1] = cursor+1+3*data_getwonderside(player), player;
+ }
+ //return io_printcard(x, y, data_getwonder(player), cursor+1+3*data_getwonderside(player), player);
+ if(cursor >= wonder_numstages(player)) {
+ ret[0] = built[print];
+ ret[1] = built[print+1];
+ }
+ //return io_printcard(x, y, built[print], built[print+1], player);
+ return ret;
}
//dir is 0 for none, 1 for east, 2 for west
bgstack15