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.400115';
3 13     13   130 use v5.10;
  13         34  
4 13     13   71 use Moo;
  13         17  
  13         60  
5              
6 13     13   3156 use Array::Utils qw(intersect);
  13         21  
  13         685  
7              
8 13     13   59 use BalanceOfPower::Constants ":all";
  13         23  
  13         7201  
9 13     13   75 use BalanceOfPower::Utils qw( prev_turn );
  13         32  
  13         2669  
10              
11             extends 'BalanceOfPower::Commands::InMilitaryRange';
12              
13              
14             sub IA
15             {
16 27     27 0 46 my $self = shift;
17 27         59 my $actor = $self->get_nation();
18              
19 27         85 my @available = $self->get_available_targets();
20 27         188 my @crises = $self->world->get_crises($actor->name);
21 27         33 my @crisis_enemies;
22 27         58 foreach my $c (@crises)
23             {
24 13         75 push @crisis_enemies, $c->destination($actor->name);
25             }
26 27         181 my @choose = $self->world->shuffle("Choosing insurgents to aid for ". $actor->name , intersect(@available, @crisis_enemies));
27 27 100       93 if(@choose > 0)
28             {
29 7         30 return "AID INSURGENTS IN " . $choose[0];
30             }
31             else
32             {
33 20         61 return undef;
34             }
35             }
36              
37             1;