lib/BalanceOfPower/Commands/DeclareWar.pm

filter: Statementstmt 100% 33 / 33 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 81.8% 45 / 55 CC 7 SCAR 11.9
CC
7
Cov
88%
get_available_targets
5.8
IA
3.0
BEGIN
1.0
CRAP 3.3
« lib/BalanceOfPower/Role/Supporter.pm ↑ Summary lib/BalanceOfPower/Role/Diplomat.pm »
1 package BalanceOfPower::Commands::DeclareWar;
2 11 $BalanceOfPower::Commands::DeclareWar::VERSION = '0.200000';
3 11 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use Array::Utils qw(intersect);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use BalanceOfPower::Constants ":all";
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use BalanceOfPower::Utils qw( prev_turn );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 extends 'BalanceOfPower::Commands::InMilitaryRange';
12  
13 sub get_available_targets
14 {
15 22 ▶ my $self = shift;
Subroutine get_available_targets: called CC=5 SCAR=17.5
Pod undocumented
16 22 my @targets = $self->SUPER::get_available_targets();
17 22 my @out = ();
18 22 for(@targets)
19 {
20 17 my $t = $_;
21 17 ▶ if((! $self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor) &&
Branch: 1 branch
BranchTrueFalseTotal
if (!$self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor and not $self->world->war_busy($t)) 17 0 17
Condition33%2/6
!$self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor and not $self->world->war_busy($t)
!ll&&!rl&&r
0017
not $self->world->is_under_influence($t) or $self->world->is_under_influence($t) ne $self->actor
l!l&&r!l&&!r
1700
MC/DC0%0/3
!$self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor and not $self->world->war_busy($t)
not $self->world->is_under_influence($t) $self->world->is_under_influence($t) ne $self->actor not $self->world->war_busy($t)
Truth table20%1/5
not(A) or B and not(C)
A= not $self->world->is_under_influence($t)B= $self->world->is_under_influence($t) ne $self->actorC= not $self->world->war_busy($t)
ABCresult
00X0
1X00
0100
1X11
0111
22 ! $self->world->war_busy($t))
23 {
24 17 push @out, $t;
25 }
26 }
27 22 return @out;
28 }
29  
30  
31 sub IA
32 {
33 22 ▶ my $self = shift;
Subroutine IA: called CC=3 SCAR=11.0
Pod undocumented
34 22 my $actor = $self->get_nation();
35 22 my @choose = $self->world->shuffle("Choosing someone to declare war to for ". $actor->name , $self->get_available_targets());
36 22 for(@choose)
37 {
38 17 my $enemy = $self->world->get_nation($_);
39 17 ▶ if($actor->good_prey($enemy, $self->world))
Branch: 1 branch
BranchTrueFalseTotal
if ($actor->good_prey($enemy, $self->world)) 1 16 17
40 {
41 1 return "DECLARE WAR TO " . $enemy->name;
42 }
43 }
44 21 return undef;
45 }
46  
47 11 1;
« lib/BalanceOfPower/Role/Supporter.pm ↑ Summary lib/BalanceOfPower/Role/Diplomat.pm »