line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Nation::Role::IA; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Nation::Role::IA::VERSION = '0.400115'; |
3
|
13
|
|
|
13
|
|
6261
|
use strict; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
399
|
|
4
|
13
|
|
|
13
|
|
154
|
use v5.10; |
|
13
|
|
|
|
|
37
|
|
5
|
13
|
|
|
13
|
|
60
|
use Moo::Role; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
92
|
|
6
|
13
|
|
|
13
|
|
9876
|
use Array::Utils qw(intersect); |
|
13
|
|
|
|
|
4633
|
|
|
13
|
|
|
|
|
934
|
|
7
|
|
|
|
|
|
|
|
8
|
13
|
|
|
13
|
|
93
|
use BalanceOfPower::Constants ':all'; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
8420
|
|
9
|
13
|
|
|
13
|
|
81
|
use BalanceOfPower::Utils qw( prev_turn ); |
|
13
|
|
|
|
|
20
|
|
|
13
|
|
|
|
|
9604
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has executive => ( |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
handles => { decide => 'decide' } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub decision |
18
|
|
|
|
|
|
|
{ |
19
|
69
|
|
|
69
|
0
|
1221
|
my $self = shift; |
20
|
69
|
|
|
|
|
74
|
my $world = shift; |
21
|
69
|
|
|
|
|
75
|
my @advisors; |
22
|
69
|
100
|
100
|
|
|
255
|
if($world->at_war($self->name) || $world->at_civil_war($self->name)) |
23
|
|
|
|
|
|
|
{ |
24
|
14
|
|
|
|
|
31
|
@advisors = ('military'); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else |
27
|
|
|
|
|
|
|
{ |
28
|
55
|
|
|
|
|
217
|
@advisors = ('domestic', 'economy', 'military'); |
29
|
|
|
|
|
|
|
} |
30
|
69
|
|
|
|
|
1426
|
@advisors = $world->shuffle("Choosing advisor for ".$self->name, @advisors); |
31
|
69
|
|
|
|
|
179
|
foreach my $a (@advisors) |
32
|
|
|
|
|
|
|
{ |
33
|
77
|
|
|
|
|
102
|
my $decision = undef; |
34
|
77
|
100
|
|
|
|
294
|
if($a eq 'domestic') |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
35
|
|
|
|
|
|
|
{ |
36
|
19
|
|
|
|
|
73
|
$decision = $self->domestic_advisor(); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif($a eq 'economy') |
39
|
|
|
|
|
|
|
{ |
40
|
7
|
|
|
|
|
26
|
$decision = $self->economy_advisor(); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif($a eq 'military') |
43
|
|
|
|
|
|
|
{ |
44
|
32
|
|
|
|
|
84
|
$decision = $self->military_advisor(); |
45
|
|
|
|
|
|
|
} |
46
|
77
|
100
|
|
|
|
496
|
return $self->name . ": " . $decision if($decision); |
47
|
|
|
|
|
|
|
} |
48
|
22
|
|
|
|
|
48
|
return undef; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub advisor |
52
|
|
|
|
|
|
|
{ |
53
|
58
|
|
|
58
|
0
|
77
|
my $self = shift; |
54
|
58
|
|
|
|
|
133
|
my @orders = @_; |
55
|
58
|
|
|
|
|
71
|
my $order = undef; |
56
|
58
|
|
|
|
|
88
|
for(@orders) |
57
|
|
|
|
|
|
|
{ |
58
|
257
|
|
|
|
|
738
|
$order = $self->decide($_); |
59
|
257
|
100
|
|
|
|
739
|
return $order if $order; |
60
|
|
|
|
|
|
|
} |
61
|
11
|
|
|
|
|
27
|
return undef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub domestic_advisor |
65
|
|
|
|
|
|
|
{ |
66
|
19
|
|
|
19
|
0
|
29
|
my $self = shift; |
67
|
19
|
|
|
|
|
55
|
return $self->advisor("LOWER DISORDER", |
68
|
|
|
|
|
|
|
"BOOST PRODUCTION", |
69
|
|
|
|
|
|
|
"TREATY NAG WITH", |
70
|
|
|
|
|
|
|
"DIPLOMATIC PRESSURE ON", |
71
|
|
|
|
|
|
|
"MILITARY AID FOR", |
72
|
|
|
|
|
|
|
"PROGRESS"); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub economy_advisor |
76
|
|
|
|
|
|
|
{ |
77
|
7
|
|
|
7
|
0
|
11
|
my $self = shift; |
78
|
7
|
|
|
|
|
20
|
return $self->advisor("TREATY COM WITH", |
79
|
|
|
|
|
|
|
"DELETE TRADEROUTE", |
80
|
|
|
|
|
|
|
"ADD ROUTE", |
81
|
|
|
|
|
|
|
"ECONOMIC AID"); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub military_advisor |
85
|
|
|
|
|
|
|
{ |
86
|
32
|
|
|
32
|
0
|
44
|
my $self = shift; |
87
|
32
|
|
|
|
|
87
|
return $self->advisor("DECLARE WAR TO", |
88
|
|
|
|
|
|
|
"AID INSURGENTS IN", |
89
|
|
|
|
|
|
|
"MILITARY SUPPORT", |
90
|
|
|
|
|
|
|
"REBEL MILITARY SUPPORT", |
91
|
|
|
|
|
|
|
"RECALL MILITARY SUPPORT", |
92
|
|
|
|
|
|
|
"BUILD TROOPS"); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
sub accept_military_support |
95
|
|
|
|
|
|
|
{ |
96
|
4
|
|
|
4
|
0
|
68
|
my $self = shift; |
97
|
4
|
|
|
|
|
9
|
my $other = shift; |
98
|
4
|
|
|
|
|
10
|
my $world = shift; |
99
|
4
|
50
|
|
|
|
24
|
if($world->already_in_military_support($self->name)) |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
|
|
0
|
my $supd = $world->supported($self->name); |
102
|
0
|
0
|
0
|
|
|
0
|
if($supd && $supd->node1 eq $other) |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
|
|
0
|
return 1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
|
|
|
|
0
|
return 0; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
4
|
50
|
|
|
|
34
|
return 0 if($world->diplomacy_status($self->name, $other) eq 'HATE'); |
112
|
4
|
|
|
|
|
30
|
return $self->army < ARMY_TO_ACCEPT_MILITARY_SUPPORT; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub good_prey |
116
|
|
|
|
|
|
|
{ |
117
|
12
|
|
|
12
|
0
|
20
|
my $self = shift; |
118
|
12
|
|
|
|
|
15
|
my $enemy = shift; |
119
|
12
|
|
|
|
|
31
|
my $world = shift; |
120
|
|
|
|
|
|
|
|
121
|
12
|
|
|
|
|
57
|
my $crisis = $world->crisis_exists($self->name, $enemy->name); |
122
|
12
|
100
|
|
|
|
44
|
my $level = $crisis ? $crisis->get_crisis_level : ALLY_CONFLICT_LEVEL_FOR_INVOLVEMENT; |
123
|
|
|
|
|
|
|
|
124
|
12
|
100
|
|
|
|
71
|
if($self->army < MIN_ARMY_FOR_WAR) |
125
|
|
|
|
|
|
|
{ |
126
|
9
|
|
|
|
|
35
|
return 0; |
127
|
|
|
|
|
|
|
} |
128
|
3
|
|
|
|
|
6
|
my $war_points = 0; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
#ARMY EVALUATION |
131
|
3
|
|
|
|
|
4
|
my $army_ratio; |
132
|
3
|
100
|
|
|
|
12
|
if($enemy->army > 0) |
133
|
|
|
|
|
|
|
{ |
134
|
1
|
|
|
|
|
6
|
$army_ratio = int($self->army / $enemy->army); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else |
137
|
|
|
|
|
|
|
{ |
138
|
2
|
|
|
|
|
4
|
$army_ratio = 3; |
139
|
|
|
|
|
|
|
} |
140
|
3
|
50
|
|
|
|
9
|
if($army_ratio < 1) |
141
|
|
|
|
|
|
|
{ |
142
|
0
|
|
|
|
|
0
|
my $reverse_army_ratio = $enemy->army / $self->army; |
143
|
0
|
0
|
|
|
|
0
|
if($reverse_army_ratio > MIN_INFERIOR_ARMY_RATIO_FOR_WAR) |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
|
|
0
|
return 0; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else |
148
|
|
|
|
|
|
|
{ |
149
|
0
|
|
|
|
|
0
|
$army_ratio = -1; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
3
|
|
|
|
|
6
|
$war_points += $army_ratio; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#INTERNAL EVALUATION |
155
|
3
|
50
|
|
|
|
10
|
if($self->internal_disorder_status eq 'Peace') |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
156
|
|
|
|
|
|
|
{ |
157
|
3
|
|
|
|
|
6
|
$war_points += 1; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
elsif($self->internal_disorder_status eq 'Terrorism') |
160
|
|
|
|
|
|
|
{ |
161
|
0
|
|
|
|
|
0
|
$war_points += 0; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
elsif($self->internal_disorder_status eq 'Insurgence') |
164
|
|
|
|
|
|
|
{ |
165
|
0
|
|
|
|
|
0
|
$war_points += -1; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
#WEALTH EVALUATION/PROGRES EVALUATION |
169
|
3
|
|
|
|
|
19
|
my $wealth = $world->get_statistics_value(prev_turn($self->current_year), $self->name, 'wealth'); |
170
|
3
|
|
|
|
|
12
|
my $enemy_wealth = $world->get_statistics_value(prev_turn($self->current_year), $enemy->name, 'wealth'); |
171
|
3
|
|
|
|
|
18
|
my $progress_delta = $enemy->progress - $self->progress; |
172
|
3
|
100
|
66
|
|
|
17
|
if($wealth && $enemy_wealth) |
173
|
|
|
|
|
|
|
{ |
174
|
1
|
50
|
|
|
|
4
|
if($enemy_wealth > $wealth) |
175
|
|
|
|
|
|
|
{ |
176
|
0
|
|
|
|
|
0
|
$war_points += 1 |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
else |
179
|
|
|
|
|
|
|
{ |
180
|
1
|
50
|
33
|
|
|
5
|
if($progress_delta > 0 && $progress_delta < MAX_AFFORDABLE_PROGRESS) |
181
|
|
|
|
|
|
|
{ |
182
|
0
|
|
|
|
|
0
|
$war_points += 1 |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
else |
188
|
|
|
|
|
|
|
{ |
189
|
2
|
|
|
|
|
3
|
$war_points += 1; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#COALITION EVALUATION |
194
|
3
|
50
|
33
|
|
|
26
|
if($world->empire($self->name) && $world->empire($enemy->name) && $world->empire($self->name) > $world->empire($enemy->name)) |
|
|
|
33
|
|
|
|
|
195
|
|
|
|
|
|
|
{ |
196
|
0
|
|
|
|
|
0
|
$war_points += 1; |
197
|
|
|
|
|
|
|
} |
198
|
3
|
50
|
|
|
|
12
|
if($war_points + $level >= 4) |
199
|
|
|
|
|
|
|
{ |
200
|
3
|
|
|
|
|
14
|
return 1; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
else |
203
|
|
|
|
|
|
|
{ |
204
|
0
|
|
|
|
|
|
return 0; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
1; |
209
|
|
|
|
|
|
|
|