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.400115';
3 13     13   65 use Moo;
  13         30  
  13         66  
4              
5 13     13   3288 use BalanceOfPower::Constants ':all';
  13         24  
  13         9306  
6              
7             extends 'BalanceOfPower::Commands::TargetNation';
8              
9             sub get_available_targets
10             {
11 17     17 0 25 my $self = shift;
12 17         76 my @supported = $self->world->supporter($self->actor);
13 17         39 my @out = ();
14 17         38 for(@supported)
15             {
16 1         5 push @out, $_->destination($self->actor);
17             }
18 17         38 return @out;
19             }
20              
21             sub IA
22             {
23 22     22 0 35 my $self = shift;
24 22         65 my $actor = $self->get_nation();
25 22 100       86 if($actor->army <= ARMY_TO_RECALL_SUPPORT)
26             {
27 17         64 my @supports = $self->get_available_targets();
28 17 100       53 if(@supports > 0)
29             {
30 1         20 @supports = $self->world->shuffle("Choosing support to recall", @supports);
31 1         5 return "RECALL MILITARY SUPPORT " . $supports[0];
32             }
33             }
34 21         40 return undef;
35             }
36              
37             1;