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.400115';
3 13     13   54 use Moo;
  13         20  
  13         69  
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 56     56 0 60 my $self = shift;
15 56         102 my $player = $self->actor;
16 56         70 my @out = ();
17 56         179 for($self->SUPER::get_available_targets())
18             {
19 224         224 my $n = $_;
20 224         203 my $push = 0;
21 224 100       821 if($self->world->in_military_range($player, $n))
22             {
23 84 100       249 if($self->crisis_needed)
24             {
25 45 100       158 if($self->world->crisis_exists($player, $n))
26             {
27 10         20 $push = 1;
28             }
29             }
30             else
31             {
32 39         58 $push = 1;
33             }
34             }
35 224 100       513 if($push)
36             {
37 49         105 push @out, $n;
38             }
39             }
40 56         233 return @out;
41             }
42              
43             1;