From cb11d841ecea5c55df6a73bff33eaac7cf477861 Mon Sep 17 00:00:00 2001 From: Nathan Vance Date: Thu, 12 Mar 2015 12:41:29 -0400 Subject: Now cannot buy two of the same card --- ai.c | 3 ++- data.c | 20 +++++++++++++++----- player_turn.c | 5 +++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ai.c b/ai.c index 7bb9f86..1eb8c11 100644 --- a/ai.c +++ b/ai.c @@ -15,6 +15,7 @@ int weight_buildcard(int era, int card, int player); int weight_buildwonder(int player); int* cards_getproduction(int era, int card); int* cards_getcost(int era, int card); +int data_hasbuiltname(int p, int era, int card); int* ai_bestcard(int *hand, int player) //return card { @@ -23,7 +24,7 @@ int* ai_bestcard(int *hand, int player) //return card int card = 0; for(i = 0; hand[i] != -1 && i < 7; i++) { temp = weight_buildcard(data_getera(), hand[i], player); - if(! data_canafford(player, data_getera(), hand[i])) + if(! data_canafford(player, data_getera(), hand[i]) || data_hasbuiltname(player, data_getera(), hand[i])) temp = 0; if(temp > max) { max = temp; diff --git a/data.c b/data.c index 01f96fd..c7cb591 100644 --- a/data.c +++ b/data.c @@ -15,6 +15,10 @@ int* get_special(int era, int card, int player); void war(); int science(int player); void halt(); +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(); #define MISC 3 #define DATAGOLD 0 @@ -405,6 +409,17 @@ int data_hasbuilt(int p, int era, int card) return 0; } +int data_hasbuiltname(int p, int era, int card) +{ + if(data_hasbuilt(p, era, card)) return 1; + if(era == 1) { + if(card == 4 && data_hasbuilt(p, 0, 10)) return 1; + if(card == 5 && data_hasbuilt(p, 0, 11)) return 1; + if(card == 6 && data_hasbuilt(p, 0, 12)) return 1; + } + return 0; +} + int data_iscouponed(int p, int era, int card) { int* coupons = cards_getcouponed(era, card); @@ -476,11 +491,6 @@ int data_potentialvps(int p, int era, int card) return vps; } -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(); - void data_endgame() { int x = 20; diff --git a/player_turn.c b/player_turn.c index aa86077..891c565 100644 --- a/player_turn.c +++ b/player_turn.c @@ -13,6 +13,7 @@ int data_numcards(int p); 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 wonder_numstages(int player); int* cards_getcost(int era, int card); @@ -31,6 +32,10 @@ int player_build(int focus, int cursor, int player) if(hand[cursor] == -1) return 0; int choice = postoptions(62, 20); if(choice == 0) { + if(data_hasbuiltname(player, data_getera(), hand[cursor])) { + postmessage("Cannot have two of the same card!"); + return 0; + } if(data_canafford(player, data_getera(), hand[cursor])) { data_build(player, hand[cursor]); return 1; -- cgit