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