aboutsummaryrefslogtreecommitdiff
path: root/science.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-07-27 19:15:59 -0400
committerNathan Vance <nathav63@gmail.com>2015-07-27 19:15:59 -0400
commit06818a49b337ef5d3277ebf6ed0b3f13a88239d3 (patch)
tree500f311c25ac68fc9a3b8429bf0747572e4d3e69 /science.c
parentfixed bugs and formatting errors (diff)
download7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.gz
7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.tar.bz2
7w-06818a49b337ef5d3277ebf6ed0b3f13a88239d3.zip
Updated to work with gcc 5.X
Diffstat (limited to 'science.c')
-rw-r--r--science.c83
1 files changed, 40 insertions, 43 deletions
diff --git a/science.c b/science.c
index 2d0f323..5dac5ff 100644
--- a/science.c
+++ b/science.c
@@ -1,50 +1,47 @@
#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* get_intarray(int size);
-
-int* get_science(int player)
-{
- int *science = get_intarray(3);
- int i, j;
- for(i = 0; i < 3; i++) science[i] = 0;
- 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];
- }
- }
- }
- return science;
+int* get_science(int player, int science[3]) {
+ int i, j;
+ for (i = 0; i < 3; i++)
+ science[i] = 0;
+ int *built = data_getbuilt(player);
+ int prod[NUMPRODUCTS];
+ for (i = 0; built[i] != -1; i += 2) {
+ if (cards_gettype(built[i], built[i + 1]) == SCIENTIFIC) {
+ cards_getproduction(built[i], built[i + 1], prod);
+ for (j = COMPASS; j <= TABLET; j++) {
+ science[j - COMPASS] += prod[j];
+ }
+ }
+ }
+ return science;
}
-int calc_science(int player, int guildval)
-{
- int i;
- int *science = get_science(player);
- if(guildval != -1) science[guildval]++;
- 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 calc_science(int player, int guildval) {
+ int i;
+ int science[3];
+ get_science(player, science);
+ if (guildval != -1)
+ science[guildval]++;
+ 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;
+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