lib/BalanceOfPower/Commands/DeclareWar.pm

filter: Statementstmt 51.5% 17 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 40.0% 22 / 55 CC 7 SCAR 26.9
CC
7
Cov
40%
get_available_targets
30.0
IA
12.0
BEGIN
1.0
CRAP 14.7
« lib/BalanceOfPower/Relations/Influence.pm ↑ Summary blib/lib/BalanceOfPower/Role/Supporter.pm »
1 package BalanceOfPower::Commands::DeclareWar;
2 11 $BalanceOfPower::Commands::DeclareWar::VERSION = '0.300010';
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 0 ▶ my $self = shift;
Subroutine get_available_targets: not called CC=5 SCAR=34.0
Pod undocumented
16 0 my @targets = $self->SUPER::get_available_targets();
17 0 my @out = ();
18 0 for(@targets)
19 {
20 0 my $t = $_;
21 0 ▶ 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)) 0 0 0
Condition0%0/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
000
not $self->world->is_under_influence($t) or $self->world->is_under_influence($t) ne $self->actor
l!l&&r!l&&!r
000
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 table0%0/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 0 push @out, $t;
25 }
26 }
27 0 return @out;
28 }
29  
30  
31 sub IA
32 {
33 0 ▶ my $self = shift;
Subroutine IA: not called CC=3 SCAR=24.8
Pod undocumented
34 0 my $actor = $self->get_nation();
35 0 my @choose = $self->world->shuffle("Choosing someone to declare war to for ". $actor->name , $self->get_available_targets());
36 0 for(@choose)
37 {
38 0 my $enemy = $self->world->get_nation($_);
39 0 ▶ if($actor->good_prey($enemy, $self->world))
Branch: 1 branch
BranchTrueFalseTotal
if ($actor->good_prey($enemy, $self->world)) 0 0 0
40 {
41 0 return "DECLARE WAR TO " . $enemy->name;
42 }
43 }
44 0 return undef;
45 }
46  
47 11 1;
« lib/BalanceOfPower/Relations/Influence.pm ↑ Summary blib/lib/BalanceOfPower/Role/Supporter.pm »