File Coverage

lib/BalanceOfPower/Commands/RecallMilitarySupport.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package BalanceOfPower::Commands::RecallMilitarySupport;
2             $BalanceOfPower::Commands::RecallMilitarySupport::VERSION = '0.400105';
3 13     13   45 use Moo;
  13         17  
  13         58  
4              
5 13     13   2342 use BalanceOfPower::Constants ':all';
  13         20  
  13         7238  
6              
7             extends 'BalanceOfPower::Commands::TargetNation';
8              
9             sub get_available_targets
10             {
11 13     13 0 13 my $self = shift;
12 13         45 my @supported = $self->world->supporter($self->actor);
13 13         17 my @out = ();
14 13         23 for(@supported)
15             {
16 1         5 push @out, $_->destination($self->actor);
17             }
18 13         18 return @out;
19             }
20              
21             sub IA
22             {
23 15     15 0 14 my $self = shift;
24 15         28 my $actor = $self->get_nation();
25 15 100       67 if($actor->army <= ARMY_TO_RECALL_SUPPORT)
26             {
27 13         32 my @supports = $self->get_available_targets();
28 13 100       31 if(@supports > 0)
29             {
30 1         18 @supports = $self->world->shuffle("Choosing support to recall", @supports);
31 1         4 return "RECALL MILITARY SUPPORT " . $supports[0];
32             }
33             }
34 14         21 return undef;
35             }
36              
37             1;