forked from kastian/dictator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.c
51 lines (46 loc) · 1.77 KB
/
plot.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Plot
Copyright (C) 1983 Don Priestley - original zx-basic code.
Copyright (C) 1983 DkTRONICS - original zx-basic code.
2015 #kstn - port to C.
*/
#include "plot.h"
void plot()
{
int a, p;
if (month < 3) /* Do not assatinations or revolutions as first two month */
return;
reset_plot(); /* Reset army, peasants and landowners statuses and allies */
if (month < plot_bonus) /* Do not assatinations or revolutions two month after failed revolution */
return;
for (a = 0; a < 3; a++)
{
if (GROUP[a].popularity > minimal) /* Next group if this group popularity > minimal */
continue;
for (p = 0; p < 6; p++) /* Try to find allies for revolution */
{
if (a == p || GROUP[p].popularity > minimal) /* Next group if it is the same group or popularity > minimal */
continue;
if (GROUP[a].strength + GROUP[p].strength >= revolution_strength) /* If their combined strength > minimal revolution strength */
{
GROUP[a].status = 'R'; /* Set status */
GROUP[a].allies = &GROUP[p]; /* Set pointer to ally group */
break;
}
}
if (GROUP[a].status == ' ') /* Or set group status to assasination if group couldn't find allies */
GROUP[a].status = 'A';
}
}
/*
Reset army, peasants and landowners statuses and allies
*/
void reset_plot()
{
int a;
for (a = 0; a < 3; a++)
{
GROUP[a].status = ' ';
GROUP[a].allies = NULL;
}
}