aboutsummaryrefslogtreecommitdiff
path: root/war.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-02-27 15:00:06 -0500
committerNathan Vance <nathav63@gmail.com>2015-02-27 15:00:06 -0500
commit03b04f383c2897b6177e4feb0eb86b68e377f6dc (patch)
treef3d914b2010f01a32f59dabaa8b4881faeb9797c /war.c
parentNow counts special cards! (diff)
download7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.tar.gz
7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.tar.bz2
7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.zip
Added battles
Diffstat (limited to 'war.c')
-rw-r--r--war.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/war.c b/war.c
new file mode 100644
index 0000000..53a9239
--- /dev/null
+++ b/war.c
@@ -0,0 +1,32 @@
+#include "7w.h"
+
+int data_getdir(int dir, int p);
+void data_adddefeat(int p);
+void data_addvictory(int p);
+int data_numplayers();
+int* data_getbuilt(int p);
+int data_haswonderstage(int p, int wonder, int stage);
+int* cards_getproduction(int era, int card);
+
+int military_might(int player)
+{
+ int *built = data_getbuilt(player);
+ int i, sum;
+ sum = 0;
+ for(i = 0; built[i] != -1; i += 2)
+ sum += cards_getproduction(built[i], built[i+1])[SHIELD];
+ return sum;
+}
+
+void war()
+{
+ int numplayers = data_numplayers();
+ int player, j;
+ for(player = 0; player < numplayers; player++)
+ for(j = 0; j < 2; j++) {
+ if(military_might(player) > military_might(data_getdir(j, player)))
+ data_addvictory(player);
+ else if(military_might(player) != military_might(data_getdir(j, player)))
+ data_adddefeat(player);
+ }
+}
bgstack15