aboutsummaryrefslogtreecommitdiff
path: root/science.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-02-28 00:18:29 -0500
committerNathan Vance <nathav63@gmail.com>2015-02-28 00:18:29 -0500
commit68d09777d9f188b2ac69c98ccfdcc315037224fd (patch)
tree76d41617e8ec05be2afe50a8f1b3dd6660f32332 /science.c
parentAdded battles (diff)
download7w-68d09777d9f188b2ac69c98ccfdcc315037224fd.tar.gz
7w-68d09777d9f188b2ac69c98ccfdcc315037224fd.tar.bz2
7w-68d09777d9f188b2ac69c98ccfdcc315037224fd.zip
added science to vp count; color to trades
Diffstat (limited to 'science.c')
-rw-r--r--science.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/science.c b/science.c
new file mode 100644
index 0000000..89af807
--- /dev/null
+++ b/science.c
@@ -0,0 +1,42 @@
+#include "7w.h"
+
+int* data_getbuilt(int p);
+int* cards_getproduction(int era, int card);
+int cards_gettype(int era, int card);
+int data_hasbuilt(int p, int era, int card);
+
+int calc_science(int player, int guildval)
+{
+ int science[3];
+ int i, j;
+ for(i = 0; i < 3; i++) science[i] = 0;
+ if(guildval != -1) science[guildval]++;
+ int *built = data_getbuilt(player);
+ int *prod;
+ for(i = 0; built[i] != -1; i += 2) {
+ if(cards_gettype(built[i], built[i+1]) == SCIENTIFIC) {
+ prod = cards_getproduction(built[i], built[i+1]);
+ for(j = COMPASS; j <= TABLET; j++) {
+ science[j-COMPASS] += prod[j];
+ }
+ }
+ }
+ int min = science[0];
+ for(i = 0; i < 3; i++)
+ if(science[i] < min) min = science[i];
+ int ret = 7*min;
+ for(i = 0; i < 3; i++) ret += science[i] * science[i];
+ return ret;
+}
+
+int science(int player)
+{
+ if(! data_hasbuilt(player, 2, 25)) return calc_science(player, -1);
+ int max = 0;
+ int i, m;
+ for(i = 0; i < 3; i++) {
+ m = calc_science(player, i);
+ if(m > max) max = m;
+ }
+ return max;
+}
bgstack15