File Coverage

lib/BalanceOfPower/Commands/RebelMilitarySupport.pm
Criterion Covered Total %
statement 18 24 75.0
branch 1 6 16.6
condition n/a
subroutine 3 3 100.0
pod 0 2 0.0
total 22 35 62.8


line stmt bran cond sub pod time code
1             package BalanceOfPower::Commands::RebelMilitarySupport;
2             $BalanceOfPower::Commands::RebelMilitarySupport::VERSION = '0.400115';
3 13     13   59 use Moo;
  13         23  
  13         67  
4              
5             extends 'BalanceOfPower::Commands::TargetNation';
6              
7             sub get_available_targets
8             {
9 2     2 0 3 my $self = shift;
10 2         4 my $player = $self->actor;
11 2         3 my @ns = grep { $self->world->at_civil_war($_) } @{$self->world->nation_names};
  10         18  
  2         6  
12 2         4 my @out = ();
13 2         4 for(@ns)
14             {
15 0         0 my $rebsup = $self->world->rebel_supported($_);
16 0 0       0 if($rebsup)
17             {
18 0 0       0 if($rebsup->node1 eq $player)
19             {
20 0         0 push @out, $_;
21             }
22             }
23             else
24             {
25 0         0 push @out, $_;
26             }
27             }
28 2         4 return @out;
29             }
30              
31             sub IA
32             {
33 1     1 0 3 my $self = shift;
34 1         47 my $player = $self->actor;
35 1         13 my @enemies = $self->world->get_hates($self->actor);
36 1         31 @enemies = $self->world->shuffle("Choosing enemy for rebel support for " . $self->actor, @enemies);
37 1         5 foreach my $e (@enemies)
38             {
39 2         18 my $target = $e->destination($self->actor);
40 2 50       20 if($self->good_target($target))
41             {
42 0           return "REBEL MILITARY SUPPORT " . $e->destination($self->actor);
43             }
44             }
45             }
46              
47             1;