aboutsummaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-03-24 12:34:19 -0400
committerNathan Vance <nathav63@gmail.com>2015-03-24 12:34:19 -0400
commit01d411a870580e368d6530a2eaacd9c828a258ce (patch)
tree3b429979de6008bc31b2643711b231cc9623b7b9 /data.c
parentstarted thinking about ai trading (diff)
download7w-01d411a870580e368d6530a2eaacd9c828a258ce.tar.gz
7w-01d411a870580e368d6530a2eaacd9c828a258ce.tar.bz2
7w-01d411a870580e368d6530a2eaacd9c828a258ce.zip
Implemented ai trading (buggy)
Diffstat (limited to 'data.c')
-rw-r--r--data.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/data.c b/data.c
index 6ad09f2..81bfe56 100644
--- a/data.c
+++ b/data.c
@@ -288,9 +288,8 @@ int data_productiontype(int e, int card)
int* data_getdefinites(int p)
{
int *ret = get_intarray(GOLD);
- int *trade = trade_buffer();
int i, j, k, *prod;
- for(i = 0; i < GOLD; i++) ret[i] = trade[i];
+ for(i = 0; i < GOLD; i++) ret[i] = 0;
for(i = 0; i < 3; i++) {
for(j = 0; j < 7; j++) {
if(data_productiontype(i, player[p][i][j]) == 1) {
@@ -315,6 +314,15 @@ void data_removedefinites(int p, int *cost)
}
}
+void data_removetraded(int p, int *cost)
+{
+ int *trade = trade_buffer();
+ int i;
+ for(i = 0; i < GOLD; i++) {
+ cost[i] -= trade[i];
+ if(cost[i] < 0) cost[i] = 0;
+ }
+}
int** data_getindefinites(int p)
{
@@ -455,6 +463,7 @@ int data_canafford(int p, int era, int card)
if(cost[GOLD] > data_getgold(p)) return 0;
int i, j, k;
data_removedefinites(p, cost);
+ data_removetraded(p, cost);
if(data_iszerocost(cost)) return 1;
return recurse(cost, data_getindefinites(p), 0);
}
bgstack15