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.400110';
3 13     13   48 use Moo;
  13         12  
  13         53  
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 43     43 0 43 my $self = shift;
15 43         55 my $player = $self->actor;
16 43         47 my @out = ();
17 43         100 for($self->SUPER::get_available_targets())
18             {
19 172         130 my $n = $_;
20 172         120 my $push = 0;
21 172 100       377 if($self->world->in_military_range($player, $n))
22             {
23 73 100       145 if($self->crisis_needed)
24             {
25 42 100       100 if($self->world->crisis_exists($player, $n))
26             {
27 7         8 $push = 1;
28             }
29             }
30             else
31             {
32 31         30 $push = 1;
33             }
34             }
35 172 100       366 if($push)
36             {
37 38         57 push @out, $n;
38             }
39             }
40 43         106 return @out;
41             }
42              
43             1;