File Coverage

lib/BalanceOfPower/Commands/InMilitaryRange.pm
Criterion Covered Total %
statement 17 17 100.0
branch 8 8 100.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 27 28 96.4


line stmt bran cond sub pod time code
1             package BalanceOfPower::Commands::InMilitaryRange;
2             $BalanceOfPower::Commands::InMilitaryRange::VERSION = '0.400105';
3 13     13   41 use Moo;
  13         18  
  13         54  
4              
5             extends 'BalanceOfPower::Commands::TargetNation';
6              
7             has crisis_needed => (
8             is => 'ro',
9             default => 0
10             );
11              
12             sub get_available_targets
13             {
14 37     37 0 32 my $self = shift;
15 37         48 my $player = $self->actor;
16 37         38 my @out = ();
17 37         92 for($self->SUPER::get_available_targets())
18             {
19 148         121 my $n = $_;
20 148         134 my $push = 0;
21 148 100       346 if($self->world->in_military_range($player, $n))
22             {
23 57 100       148 if($self->crisis_needed)
24             {
25 31 100       81 if($self->world->crisis_exists($player, $n))
26             {
27 6         9 $push = 1;
28             }
29             }
30             else
31             {
32 26         24 $push = 1;
33             }
34             }
35 148 100       293 if($push)
36             {
37 32         54 push @out, $n;
38             }
39             }
40 37         100 return @out;
41             }
42              
43             1;