diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-07-27 19:15:59 -0400 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-07-27 19:15:59 -0400 |
commit | 06818a49b337ef5d3277ebf6ed0b3f13a88239d3 (patch) | |
tree | 500f311c25ac68fc9a3b8429bf0747572e4d3e69 /war.c | |
parent | fixed bugs and formatting errors (diff) | |
download | 7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.gz 7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.bz2 7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.zip |
Updated to work with gcc 5.X
Diffstat (limited to 'war.c')
-rw-r--r-- | war.c | 55 |
1 files changed, 25 insertions, 30 deletions
@@ -1,35 +1,30 @@ #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]; - if(data_haswonderstage(player, 3, 2)) sum += 2; - if(data_haswonderstage(player, 3, 4)) sum += 1; - if(data_haswonderstage(player, 3, 5)) sum += 1; - return sum; +int military_might(int player) { + int *built = data_getbuilt(player); + int prod[NUMPRODUCTS]; + int i, sum; + sum = 0; + for (i = 0; built[i] != -1; i += 2) + sum += cards_getproduction(built[i], built[i + 1], prod)[SHIELD]; + if (data_haswonderstage(player, 3, 2)) + sum += 2; + if (data_haswonderstage(player, 3, 4)) + sum += 1; + if (data_haswonderstage(player, 3, 5)) + sum += 1; + 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); - } +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); + } } |