File Coverage

lib/BalanceOfPower/Commands/DiplomaticPressure.pm
Criterion Covered Total %
statement 9 15 60.0
branch 2 4 50.0
condition n/a
subroutine 2 3 66.6
pod 0 2 0.0
total 13 24 54.1


line stmt bran cond sub pod time code
1             package BalanceOfPower::Commands::DiplomaticPressure;
2             $BalanceOfPower::Commands::DiplomaticPressure::VERSION = '0.400105';
3 13     13   42 use Moo;
  13         14  
  13         55  
4              
5             extends 'BalanceOfPower::Commands::TargetNation';
6              
7             sub get_available_targets
8             {
9 0     0 0 0 my $self = shift;
10 0         0 my @targets = $self->SUPER::get_available_targets();
11 0         0 my $nation = $self->actor;
12 0 0       0 @targets = grep { (! $self->world->is_under_influence($_)
  0         0  
13             || $self->world->is_under_influence($_) ne $nation) } @targets;
14 0         0 return @targets;
15             }
16              
17              
18             sub IA
19             {
20 6     6 0 4 my $self = shift;
21 6         12 my $actor = $self->get_nation();
22 6         31 my @hates = $self->world->shuffle("Choosing target for diplomatic pressure for ". $self->actor, $self->world->get_nations_with_status($self->actor, ['HATE']));
23 6 100       17 if(@hates)
24             {
25 5         18 return "DIPLOMATIC PRESSURE ON " . $hates[0];
26             }
27             else
28             {
29 1         3 return undef;
30             }
31             }
32             1;