| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BalanceOfPower::Commands::MilitarySupport; |
|
2
|
|
|
|
|
|
|
$BalanceOfPower::Commands::MilitarySupport::VERSION = '0.400110'; |
|
3
|
13
|
|
|
13
|
|
44
|
use BalanceOfPower::Constants ":all"; |
|
|
13
|
|
|
|
|
14
|
|
|
|
13
|
|
|
|
|
5692
|
|
|
4
|
13
|
|
|
13
|
|
66
|
use Moo; |
|
|
13
|
|
|
|
|
14
|
|
|
|
13
|
|
|
|
|
57
|
|
|
5
|
13
|
|
|
13
|
|
2621
|
use Array::Utils qw(intersect); |
|
|
13
|
|
|
|
|
22
|
|
|
|
13
|
|
|
|
|
3572
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'BalanceOfPower::Commands::TargetNation'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_available_targets |
|
10
|
|
|
|
|
|
|
{ |
|
11
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
|
12
|
1
|
|
|
|
|
3
|
my $player = $self->actor; |
|
13
|
1
|
|
|
|
|
4
|
return grep { $self->world->get_nation($_)->accept_military_support($player, $self->world) } $self->world->get_friends($player); |
|
|
1
|
|
|
|
|
4
|
|
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub IA |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
|
19
|
3
|
|
|
|
|
7
|
my $actor = $self->get_nation(); |
|
20
|
3
|
100
|
|
|
|
14
|
return undef if($actor->army < ARMY_TO_GIVE_MILITARY_SUPPORT); |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
5
|
my @crises = $self->world->get_crises($actor->name); |
|
23
|
1
|
|
|
|
|
9
|
my @friends = $self->world->shuffle("Choosing friend to support for " . $actor->name, $self->world->get_friends($actor->name)); |
|
24
|
1
|
|
|
|
|
4
|
my @targets = $self->get_available_targets(); |
|
25
|
1
|
|
|
|
|
8
|
@friends = $self->world->shuffle("Mixing friends for military support for " . $actor->name, intersect(@friends, @targets)); |
|
26
|
1
|
50
|
|
|
|
4
|
if(@crises > 0) |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
1
|
|
|
|
|
22
|
foreach my $c ($self->world->shuffle("Mixing crisis for war for " . $actor->name, @crises)) |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
1
|
|
|
|
|
7
|
my $enemy = $self->world->get_nation($c->destination($actor->name)); |
|
31
|
1
|
50
|
|
|
|
5
|
next if $self->world->war_busy($enemy->name); |
|
32
|
1
|
|
|
|
|
2
|
for(@friends) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
1
|
50
|
|
|
|
5
|
if($self->world->border_exists($_, $enemy->name)) |
|
35
|
|
|
|
|
|
|
{ |
|
36
|
1
|
|
|
|
|
6
|
return "MILITARY SUPPORT " . $_; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
0
|
|
|
|
|
if(@friends) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
|
my $f = $friends[0]; |
|
44
|
0
|
|
|
|
|
|
return "MILITARY SUPPORT " . $f; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
|
return undef; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |