lib/BalanceOfPower/Commands/MilitarySupport.pm

filter: Statementstmt 35.2% 12 / 34 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 29.4% 15 / 51 CC 8 SCAR 38.8
CC
8
Cov
27%
IA
72.0
get_available_targets
2.0
BEGIN
1.0
CRAP 48.4
« blib/lib/BalanceOfPower/Role/Broker.pm ↑ Summary lib/BalanceOfPower/Nation.pm »
1 package BalanceOfPower::Commands::MilitarySupport;
2 11 $BalanceOfPower::Commands::MilitarySupport::VERSION = '0.300010';
3 11 ▶use BalanceOfPower::Constants ":all";
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Array::Utils qw(intersect);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 extends 'BalanceOfPower::Commands::TargetNation';
8  
9 sub get_available_targets
10 {
11 0 ▶ my $self = shift;
Subroutine get_available_targets: not called CC=1 SCAR=6.9
Pod undocumented
12 0 my $player = $self->actor;
13 0 return grep { $self->world->get_nation($_)->accept_military_support($player, $self->world) } $self->world->get_friends($player);
14 }
15  
16 sub IA
17 {
18 0 ▶ my $self = shift;
Subroutine IA: not called CC=8 SCAR=42.8
Pod undocumented
19 0 my $actor = $self->get_nation();
20 0 ▶ return undef if($actor->army < ARMY_TO_GIVE_MILITARY_SUPPORT);
Branch: 1 branch
BranchTrueFalseTotal
if $actor->army < 6 0 0 0
21  
22 0 my @crises = $self->world->get_crises($actor->name);
23 0 my @friends = $self->world->shuffle("Choosing friend to support for " . $actor->name, $self->world->get_friends($actor->name));
24 0 my @targets = $self->get_available_targets();
25 0 @friends = $self->world->shuffle("Mixing friends for military support for " . $actor->name, intersect(@friends, @targets));
26 0 ▶ if(@crises > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (@crises > 0) 0 0 0
27 {
28 0 foreach my $c ($self->world->shuffle("Mixing crisis for war for " . $actor->name, @crises))
29 {
30 0 my $enemy = $self->world->get_nation($c->destination($actor->name));
31 0 ▶ next if $self->world->war_busy($enemy->name);
Branch: 1 branch
BranchTrueFalseTotal
if $self->world->war_busy($enemy->name) 0 0 0
32 0 for(@friends)
33 {
34 0 ▶ if($self->world->border_exists($_, $enemy->name))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->world->border_exists($_, $enemy->name)) 0 0 0
35 {
36 0 return "MILITARY SUPPORT " . $_;
37 }
38 }
39 }
40 }
41 0 ▶ if(@friends)
Branch: 1 branch
BranchTrueFalseTotal
if (@friends) 0 0 0
42 {
43 0 my $f = $friends[0];
44 0 return "MILITARY SUPPORT " . $f;
45 }
46 0 return undef;
47 }
48  
49 11 1;
« blib/lib/BalanceOfPower/Role/Broker.pm ↑ Summary lib/BalanceOfPower/Nation.pm »