lib/BalanceOfPower/Commands/BuildTroops.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 2 totaltotal 79.5% 35 / 44 CC 7 SCAR 16.3
CC
7
Cov
82%
IA
7.5
allowed
2.0
BEGIN
1.0
CRAP 5.1
« lib/BalanceOfPower/Commands/InMilitaryRange.pm ↑ Summary blib/lib/BalanceOfPower/Role/Mapmaker.pm »
1 package BalanceOfPower::Commands::BuildTroops;
2 11 $BalanceOfPower::Commands::BuildTroops::VERSION = '0.200000';
3 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 ▶use BalanceOfPower::Constants ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 extends 'BalanceOfPower::Commands::NoArgs';
8  
9 sub allowed
10 {
11 14 ▶ my $self = shift;
Subroutine allowed: called CC=2 SCAR=6.9
Pod undocumented
12 14 my $nation = $self->world->get_nation($self->actor);
13 14 my $other_checks = $self->SUPER::allowed();
14 14 ▶ if($other_checks)
Branch: 1 branch
BranchTrueFalseTotal
if ($other_checks) { } 12 2 14
15 {
16 12 my $export_cost = $nation->build_troops_cost();
17 12 return $nation->production_for_export >= $export_cost;
18 }
19 else
20 {
21 2 return 0;
22 }
23 }
24  
25 sub IA
26 {
27 12 ▶ my $self = shift;
Subroutine IA: called CC=6 SCAR=20.2
Pod undocumented
28 12 my $actor = $self->get_nation();
29 12 ▶ if($actor->army < MAX_ARMY_FOR_SIZE->[ $actor->size ])
Branch: 1 branch
BranchTrueFalseTotal
if ($actor->army < [9,12,15]->[$actor->size]) 11 1 12
30 {
31 11 ▶ if($actor->army < MINIMUM_ARMY_LIMIT)
Branch: 2 branches
BranchTrueFalseTotal
if ($actor->army < 5) { } 10 1 11
elsif ($actor->army < 10) { } 0 1 1
32 {
33 10 return "BUILD TROOPS";
34 }
35 elsif($actor->army < MEDIUM_ARMY_LIMIT)
36 {
37 0 ▶ if($actor->production_for_export > MEDIUM_ARMY_BUDGET)
Branch: 1 branch
BranchTrueFalseTotal
if ($actor->production_for_export > 40) 0 0 0
38 {
39 0 return "BUILD TROOPS";
40 }
41 }
42 else
43 {
44 1 ▶ if($actor->production_for_export > MAX_ARMY_BUDGET)
Branch: 1 branch
BranchTrueFalseTotal
if ($actor->production_for_export > 60) 0 1 1
45 {
46 0 return "BUILD TROOPS";
47 }
48 }
49 }
50 2 return undef;
51 }
52  
53 11 1;
« lib/BalanceOfPower/Commands/InMilitaryRange.pm ↑ Summary blib/lib/BalanceOfPower/Role/Mapmaker.pm »