blib/lib/BalanceOfPower/Commands/BuildTroops.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 CC 7 SCAR 32.9
CC
7
Cov
0%
IA
42.0
allowed
6.0
BEGIN
2.0
CRAP 26.8
1 package BalanceOfPower::Commands::BuildTroops;
2 $BalanceOfPower::Commands::BuildTroops::VERSION = '0.300010';
3 use Moo;
4  
5 use BalanceOfPower::Constants ':all';
6  
7 extends 'BalanceOfPower::Commands::NoArgs';
8  
9 sub allowed
10 {
11 my $self = shift;
12 my $nation = $self->world->get_nation($self->actor);
13 my $other_checks = $self->SUPER::allowed();
14 if($other_checks)
15 {
16 my $export_cost = $nation->build_troops_cost();
17 return $nation->production_for_export >= $export_cost;
18 }
19 else
20 {
21 return 0;
22 }
23 }
24  
25 sub IA
26 {
27 my $self = shift;
28 my $actor = $self->get_nation();
29 if($actor->army < MAX_ARMY_FOR_SIZE->[ $actor->size ])
30 {
31 if($actor->army < MINIMUM_ARMY_LIMIT)
32 {
33 return "BUILD TROOPS";
34 }
35 elsif($actor->army < MEDIUM_ARMY_LIMIT)
36 {
37 if($actor->production_for_export > MEDIUM_ARMY_BUDGET)
38 {
39 return "BUILD TROOPS";
40 }
41 }
42 else
43 {
44 if($actor->production_for_export > MAX_ARMY_BUDGET)
45 {
46 return "BUILD TROOPS";
47 }
48 }
49 }
50 return undef;
51 }
52  
53 1;