line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Executive; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Executive::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
43
|
use strict; |
|
13
|
|
|
|
|
13
|
|
|
13
|
|
|
|
|
295
|
|
4
|
13
|
|
|
13
|
|
92
|
use v5.10; |
|
13
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
43
|
use Moo; |
|
13
|
|
|
|
|
14
|
|
|
13
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'BalanceOfPower::Role::Logger'; |
9
|
|
|
|
|
|
|
|
10
|
13
|
|
|
13
|
|
2570
|
use BalanceOfPower::Constants ":all"; |
|
13
|
|
|
|
|
17
|
|
|
13
|
|
|
|
|
5087
|
|
11
|
13
|
|
|
13
|
|
59
|
use BalanceOfPower::Utils qw(as_active as_title); |
|
13
|
|
|
|
|
21
|
|
|
13
|
|
|
|
|
582
|
|
12
|
13
|
|
|
13
|
|
3461
|
use BalanceOfPower::Commands::BuildTroops; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
333
|
|
13
|
13
|
|
|
13
|
|
3549
|
use BalanceOfPower::Commands::InMilitaryRange; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
357
|
|
14
|
13
|
|
|
13
|
|
3669
|
use BalanceOfPower::Commands::DeleteRoute; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
312
|
|
15
|
13
|
|
|
13
|
|
3272
|
use BalanceOfPower::Commands::MilitarySupport; |
|
13
|
|
|
|
|
22
|
|
|
13
|
|
|
|
|
289
|
|
16
|
13
|
|
|
13
|
|
3469
|
use BalanceOfPower::Commands::RebelMilitarySupport; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
291
|
|
17
|
13
|
|
|
13
|
|
3327
|
use BalanceOfPower::Commands::RecallRebelMilitarySupport; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
296
|
|
18
|
13
|
|
|
13
|
|
3532
|
use BalanceOfPower::Commands::RecallMilitarySupport; |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
292
|
|
19
|
13
|
|
|
13
|
|
3279
|
use BalanceOfPower::Commands::ComTreaty; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
335
|
|
20
|
13
|
|
|
13
|
|
3560
|
use BalanceOfPower::Commands::NagTreaty; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
295
|
|
21
|
13
|
|
|
13
|
|
3374
|
use BalanceOfPower::Commands::LowerDisorder; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
280
|
|
22
|
13
|
|
|
13
|
|
3338
|
use BalanceOfPower::Commands::BoostProduction; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
279
|
|
23
|
13
|
|
|
13
|
|
3306
|
use BalanceOfPower::Commands::AddRoute; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
277
|
|
24
|
13
|
|
|
13
|
|
3466
|
use BalanceOfPower::Commands::EconomicAid; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
284
|
|
25
|
13
|
|
|
13
|
|
3141
|
use BalanceOfPower::Commands::DeclareWar; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
282
|
|
26
|
13
|
|
|
13
|
|
3455
|
use BalanceOfPower::Commands::AidInsurgents; |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
283
|
|
27
|
13
|
|
|
13
|
|
3568
|
use BalanceOfPower::Commands::DiplomaticPressure; |
|
13
|
|
|
|
|
23
|
|
|
13
|
|
|
|
|
282
|
|
28
|
13
|
|
|
13
|
|
3205
|
use BalanceOfPower::Commands::MilitaryAid; |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
283
|
|
29
|
13
|
|
|
13
|
|
3241
|
use BalanceOfPower::Commands::Progress; |
|
13
|
|
|
|
|
1693
|
|
|
13
|
|
|
|
|
10024
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has actor => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
default => sub { undef } |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has commands => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
default => sub { {} } |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub init |
42
|
|
|
|
|
|
|
{ |
43
|
73
|
|
|
73
|
0
|
95
|
my $self = shift; |
44
|
73
|
|
|
|
|
185
|
$self->log_name("bop-IA.log"); |
45
|
73
|
|
|
|
|
163
|
$self->delete_log(); |
46
|
73
|
|
|
|
|
150
|
$self->log_active(1); |
47
|
73
|
|
|
|
|
92
|
my $world = shift; |
48
|
73
|
|
|
|
|
1431
|
my $command = |
49
|
|
|
|
|
|
|
BalanceOfPower::Commands::BuildTroops->new( name => "BUILD TROOPS", |
50
|
|
|
|
|
|
|
domestic_cost => ARMY_COST, |
51
|
|
|
|
|
|
|
world => $world, |
52
|
|
|
|
|
|
|
allowed_at_war => 1, ); |
53
|
73
|
|
|
|
|
646
|
$self->commands->{"BUILD TROOPS"} = $command; |
54
|
73
|
|
|
|
|
1278
|
$command = |
55
|
|
|
|
|
|
|
BalanceOfPower::Commands::LowerDisorder->new( name => "LOWER DISORDER", |
56
|
|
|
|
|
|
|
world => $world, |
57
|
|
|
|
|
|
|
domestic_cost => RESOURCES_FOR_DISORDER ); |
58
|
73
|
|
|
|
|
544
|
$self->commands->{"LOWER DISORDER"} = $command; |
59
|
73
|
|
|
|
|
1243
|
$command = |
60
|
|
|
|
|
|
|
BalanceOfPower::Commands::AddRoute->new( name => "ADD ROUTE", |
61
|
|
|
|
|
|
|
world => $world, |
62
|
|
|
|
|
|
|
export_cost => ADDING_TRADEROUTE_COST ); |
63
|
73
|
|
|
|
|
559
|
$self->commands->{"ADD ROUTE"} = $command; |
64
|
73
|
|
|
|
|
1230
|
$command = |
65
|
|
|
|
|
|
|
BalanceOfPower::Commands::DeclareWar->new( name => "DECLARE WAR TO", |
66
|
|
|
|
|
|
|
synonyms => ["DECLARE WAR"], |
67
|
|
|
|
|
|
|
world => $world, |
68
|
|
|
|
|
|
|
crisis_needed => 1 ); |
69
|
73
|
|
|
|
|
599
|
$self->commands->{"DECLARE WAR TO"} = $command; |
70
|
73
|
|
|
|
|
1194
|
$command = |
71
|
|
|
|
|
|
|
BalanceOfPower::Commands::DeleteRoute->new( name => "DELETE TRADEROUTE", |
72
|
|
|
|
|
|
|
synonyms => ["DELETE ROUTE"], |
73
|
|
|
|
|
|
|
world => $world ); |
74
|
73
|
|
|
|
|
574
|
$self->commands->{"DELETE TRADEROUTE"} = $command; |
75
|
73
|
|
|
|
|
1218
|
$command = |
76
|
|
|
|
|
|
|
BalanceOfPower::Commands::BoostProduction->new( name => "BOOST PRODUCTION", |
77
|
|
|
|
|
|
|
world => $world, |
78
|
|
|
|
|
|
|
); |
79
|
73
|
|
|
|
|
503
|
$self->commands->{"BOOST PRODUCTION"} = $command; |
80
|
73
|
|
|
|
|
1362
|
$command = |
81
|
|
|
|
|
|
|
BalanceOfPower::Commands::MilitarySupport->new( name => "MILITARY SUPPORT", |
82
|
|
|
|
|
|
|
world => $world, |
83
|
|
|
|
|
|
|
army_limit => { '>' => ARMY_FOR_SUPPORT } |
84
|
|
|
|
|
|
|
); |
85
|
73
|
|
|
|
|
524
|
$self->commands->{"MILITARY SUPPORT"} = $command; |
86
|
73
|
|
|
|
|
1425
|
$command = |
87
|
|
|
|
|
|
|
BalanceOfPower::Commands::RecallMilitarySupport->new( name => "RECALL MILITARY SUPPORT", |
88
|
|
|
|
|
|
|
synonyms => ["RECALL SUPPORT"], |
89
|
|
|
|
|
|
|
world => $world, |
90
|
|
|
|
|
|
|
allowed_at_war => 1, |
91
|
|
|
|
|
|
|
); |
92
|
73
|
|
|
|
|
612
|
$self->commands->{"RECALL MILITARY SUPPORT"} = $command; |
93
|
73
|
|
|
|
|
1302
|
$command = |
94
|
|
|
|
|
|
|
BalanceOfPower::Commands::AidInsurgents->new( name => "AID INSURGENTS IN", |
95
|
|
|
|
|
|
|
synonyms => ["AID INSURGENTS", "AID INSURGENCE"], |
96
|
|
|
|
|
|
|
world => $world, |
97
|
|
|
|
|
|
|
export_cost => AID_INSURGENTS_COST ); |
98
|
73
|
|
|
|
|
600
|
$self->commands->{"AID INSURGENTS IN"} = $command; |
99
|
73
|
|
|
|
|
1345
|
$command = |
100
|
|
|
|
|
|
|
BalanceOfPower::Commands::ComTreaty->new( name => "TREATY COM WITH", |
101
|
|
|
|
|
|
|
synonyms => ["COM TREATY", |
102
|
|
|
|
|
|
|
"COM TREATY WITH", |
103
|
|
|
|
|
|
|
"TREATY COM", |
104
|
|
|
|
|
|
|
], |
105
|
|
|
|
|
|
|
world => $world, |
106
|
|
|
|
|
|
|
prestige_cost => TREATY_PRESTIGE_COST, |
107
|
|
|
|
|
|
|
treaty_limit => 1, |
108
|
|
|
|
|
|
|
); |
109
|
73
|
|
|
|
|
564
|
$self->commands->{"TREATY COM WITH"} = $command; |
110
|
73
|
|
|
|
|
1242
|
$command = |
111
|
|
|
|
|
|
|
BalanceOfPower::Commands::NagTreaty->new( name => "TREATY NAG WITH", |
112
|
|
|
|
|
|
|
synonyms => ["NAG TREATY", |
113
|
|
|
|
|
|
|
"NAG TREATY WITH", |
114
|
|
|
|
|
|
|
"TREATY NAG" |
115
|
|
|
|
|
|
|
], |
116
|
|
|
|
|
|
|
world => $world, |
117
|
|
|
|
|
|
|
prestige_cost => TREATY_PRESTIGE_COST, |
118
|
|
|
|
|
|
|
treaty_limit => 1, |
119
|
|
|
|
|
|
|
); |
120
|
73
|
|
|
|
|
621
|
$self->commands->{"TREATY NAG WITH"} = $command; |
121
|
73
|
|
|
|
|
1553
|
$command = |
122
|
|
|
|
|
|
|
BalanceOfPower::Commands::EconomicAid->new( name => "ECONOMIC AID FOR", |
123
|
|
|
|
|
|
|
synonyms => ["ECONOMIC AID"], |
124
|
|
|
|
|
|
|
world => $world, |
125
|
|
|
|
|
|
|
export_cost => ECONOMIC_AID_COST, |
126
|
|
|
|
|
|
|
); |
127
|
73
|
|
|
|
|
586
|
$self->commands->{"ECONOMIC AID FOR"} = $command; |
128
|
73
|
|
|
|
|
1296
|
$command = |
129
|
|
|
|
|
|
|
BalanceOfPower::Commands::RebelMilitarySupport->new( name => "REBEL MILITARY SUPPORT", |
130
|
|
|
|
|
|
|
world => $world, |
131
|
|
|
|
|
|
|
army_limit => { '>' => ARMY_FOR_SUPPORT } |
132
|
|
|
|
|
|
|
); |
133
|
73
|
|
|
|
|
527
|
$self->commands->{"REBEL MILITARY SUPPORT"} = $command; |
134
|
73
|
|
|
|
|
1248
|
$command = |
135
|
|
|
|
|
|
|
BalanceOfPower::Commands::DiplomaticPressure->new( name => "DIPLOMATIC PRESSURE ON", |
136
|
|
|
|
|
|
|
world => $world, |
137
|
|
|
|
|
|
|
prestige_cost => DIPLOMATIC_PRESSURE_PRESTIGE_COST |
138
|
|
|
|
|
|
|
); |
139
|
73
|
|
|
|
|
497
|
$self->commands->{"DIPLOMATIC PRESSURE ON"} = $command; |
140
|
73
|
|
|
|
|
1212
|
$command = |
141
|
|
|
|
|
|
|
BalanceOfPower::Commands::RecallRebelMilitarySupport->new( name => "RECALL REBEL MILITARY SUPPORT", |
142
|
|
|
|
|
|
|
world => $world, |
143
|
|
|
|
|
|
|
); |
144
|
73
|
|
|
|
|
480
|
$self->commands->{"RECALL REBEL MILITARY SUPPORT"} = $command; |
145
|
73
|
|
|
|
|
1269
|
$command = |
146
|
|
|
|
|
|
|
BalanceOfPower::Commands::MilitaryAid->new( name => "MILITARY AID FOR", |
147
|
|
|
|
|
|
|
synonyms => ["MILITARY AID"], |
148
|
|
|
|
|
|
|
world => $world, |
149
|
|
|
|
|
|
|
export_cost => MILITARY_AID_COST, |
150
|
|
|
|
|
|
|
); |
151
|
73
|
|
|
|
|
634
|
$self->commands->{"MILITARY AID FOR"} = $command; |
152
|
73
|
|
|
|
|
1233
|
$command = |
153
|
|
|
|
|
|
|
BalanceOfPower::Commands::Progress->new( name => "PROGRESS", |
154
|
|
|
|
|
|
|
world => $world, |
155
|
|
|
|
|
|
|
domestic_cost => PROGRESS_COST, |
156
|
|
|
|
|
|
|
); |
157
|
73
|
|
|
|
|
549
|
$self->commands->{"PROGRESS"} = $command; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub recognize_command |
162
|
|
|
|
|
|
|
{ |
163
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
164
|
0
|
|
|
|
|
0
|
my $nation = shift; |
165
|
0
|
|
|
|
|
0
|
my $query = shift; |
166
|
0
|
|
|
|
|
0
|
my $actor = $self->actor; |
167
|
0
|
|
|
|
|
0
|
for(keys %{$self->commands}) |
|
0
|
|
|
|
|
0
|
|
168
|
|
|
|
|
|
|
{ |
169
|
0
|
|
|
|
|
0
|
my $c = $self->commands->{$_}; |
170
|
0
|
|
|
|
|
0
|
$c->actor($actor); |
171
|
0
|
0
|
|
|
|
0
|
if($c->recognize($query)) |
172
|
|
|
|
|
|
|
{ |
173
|
0
|
0
|
|
|
|
0
|
if($c->allowed()) |
174
|
|
|
|
|
|
|
{ |
175
|
0
|
|
|
|
|
0
|
return $c->execute($query, $nation); |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
else |
178
|
|
|
|
|
|
|
{ |
179
|
0
|
|
|
|
|
0
|
return { status => -1 }; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
0
|
|
|
|
|
0
|
return { status => 0 }; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub decide |
188
|
|
|
|
|
|
|
{ |
189
|
224
|
|
|
224
|
0
|
11889
|
my $self = shift; |
190
|
224
|
|
|
|
|
183
|
my $order = shift; |
191
|
224
|
100
|
|
|
|
579
|
if(! exists $self->commands->{$order}) |
192
|
|
|
|
|
|
|
{ |
193
|
4
|
|
|
|
|
23
|
$self->log($self->actor . ": $order doesn't exists!"); |
194
|
4
|
|
|
|
|
10
|
return undef; |
195
|
|
|
|
|
|
|
} |
196
|
220
|
|
|
|
|
274
|
my $c = $self->commands->{$order}; |
197
|
220
|
|
|
|
|
933
|
$c->actor($self->actor); |
198
|
220
|
100
|
|
|
|
523
|
if($c->allowed()) |
199
|
|
|
|
|
|
|
{ |
200
|
152
|
|
|
|
|
443
|
my $command = $c->IA(); |
201
|
152
|
100
|
|
|
|
225
|
my $exit_log = $command ? $command : "KO"; |
202
|
152
|
|
|
|
|
550
|
$self->log($self->actor . ": executing $order: $exit_log"); |
203
|
152
|
|
|
|
|
423
|
return $command; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
else |
206
|
|
|
|
|
|
|
{ |
207
|
68
|
|
|
|
|
233
|
$self->log($self->actor . ": $order not allowed"); |
208
|
68
|
|
|
|
|
164
|
return undef; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub allowed_orders |
213
|
|
|
|
|
|
|
{ |
214
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
215
|
0
|
|
|
|
|
|
my @out; |
216
|
0
|
|
|
|
|
|
for(keys %{$self->commands}) |
|
0
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
{ |
218
|
0
|
|
|
|
|
|
my $c = $self->commands->{$_}; |
219
|
0
|
|
|
|
|
|
$c->actor($self->actor); |
220
|
0
|
0
|
|
|
|
|
if( $c->allowed() ) |
221
|
|
|
|
|
|
|
{ |
222
|
0
|
|
|
|
|
|
push @out, $c->print; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
} |
225
|
0
|
|
|
|
|
|
return @out; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub print_orders |
229
|
|
|
|
|
|
|
{ |
230
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
231
|
0
|
|
|
|
|
|
my $out = as_title("ORDERS FOR " . $self->actor); |
232
|
0
|
|
|
|
|
|
$out .= "\n\n"; |
233
|
0
|
|
|
|
|
|
for(keys %{$self->commands}) |
|
0
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
{ |
235
|
0
|
|
|
|
|
|
my $c = $self->commands->{$_}; |
236
|
0
|
|
|
|
|
|
$c->actor($self->actor); |
237
|
0
|
0
|
|
|
|
|
if( $c->allowed() ) |
238
|
|
|
|
|
|
|
{ |
239
|
0
|
|
|
|
|
|
$out .= as_active($c->print) . "\n"; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
else |
242
|
|
|
|
|
|
|
{ |
243
|
0
|
|
|
|
|
|
$out .= $c->print . "\n"; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
} |
246
|
0
|
|
|
|
|
|
return $out; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |