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