File Coverage

lib/BalanceOfPower/Commands/AidInsurgents.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package BalanceOfPower::Commands::AidInsurgents;
2             $BalanceOfPower::Commands::AidInsurgents::VERSION = '0.400110';
3 13     13   96 use v5.10;
  13         25  
4 13     13   36 use Moo;
  13         12  
  13         49  
5              
6 13     13   2338 use Array::Utils qw(intersect);
  13         14  
  13         459  
7              
8 13     13   44 use BalanceOfPower::Constants ":all";
  13         12  
  13         5466  
9 13     13   67 use BalanceOfPower::Utils qw( prev_turn );
  13         20  
  13         2047  
10              
11             extends 'BalanceOfPower::Commands::InMilitaryRange';
12              
13              
14             sub IA
15             {
16 19     19 0 17 my $self = shift;
17 19         36 my $actor = $self->get_nation();
18              
19 19         52 my @available = $self->get_available_targets();
20 19         81 my @crises = $self->world->get_crises($actor->name);
21 19         25 my @crisis_enemies;
22 19         26 foreach my $c (@crises)
23             {
24 7         25 push @crisis_enemies, $c->destination($actor->name);
25             }
26 19         87 my @choose = $self->world->shuffle("Choosing insurgents to aid for ". $actor->name , intersect(@available, @crisis_enemies));
27 19 100       48 if(@choose > 0)
28             {
29 4         16 return "AID INSURGENTS IN " . $choose[0];
30             }
31             else
32             {
33 15         41 return undef;
34             }
35             }
36              
37             1;