line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BalanceOfPower::Commands::MilitarySupport; |
2
|
|
|
|
|
|
|
$BalanceOfPower::Commands::MilitarySupport::VERSION = '0.400105'; |
3
|
13
|
|
|
13
|
|
48
|
use BalanceOfPower::Constants ":all"; |
|
13
|
|
|
|
|
15
|
|
|
13
|
|
|
|
|
5975
|
|
4
|
13
|
|
|
13
|
|
60
|
use Moo; |
|
13
|
|
|
|
|
16
|
|
|
13
|
|
|
|
|
61
|
|
5
|
13
|
|
|
13
|
|
2705
|
use Array::Utils qw(intersect); |
|
13
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
3509
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'BalanceOfPower::Commands::TargetNation'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_available_targets |
10
|
|
|
|
|
|
|
{ |
11
|
1
|
|
|
1
|
0
|
1
|
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
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub IA |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
19
|
1
|
|
|
|
|
2
|
my $actor = $self->get_nation(); |
20
|
1
|
50
|
|
|
|
5
|
return undef if($actor->army < ARMY_TO_GIVE_MILITARY_SUPPORT); |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
5
|
my @crises = $self->world->get_crises($actor->name); |
23
|
1
|
|
|
|
|
8
|
my @friends = $self->world->shuffle("Choosing friend to support for " . $actor->name, $self->world->get_friends($actor->name)); |
24
|
1
|
|
|
|
|
5
|
my @targets = $self->get_available_targets(); |
25
|
1
|
|
|
|
|
7
|
@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
|
|
|
|
|
5
|
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
|
|
|
|
7
|
if($self->world->border_exists($_, $enemy->name)) |
35
|
|
|
|
|
|
|
{ |
36
|
1
|
|
|
|
|
4
|
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; |