lib/BalanceOfPower/Commands/DeleteRoute.pm

filter: Statementstmt 36.5% 15 / 41 Branchbran 16.6% 2 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 3 totaltotal 32.7% 20 / 61 CC 8 SCAR 27.3
CC
8
Cov
32%
IA
24.1
execute
6.0
get_available_targets
2.0
CRAP 15.4
« lib/BalanceOfPower/Role/Warlord.pm ↑ Summary blib/lib/BalanceOfPower/Relations/Friendship.pm »
1 package BalanceOfPower::Commands::DeleteRoute;
2 11 $BalanceOfPower::Commands::DeleteRoute::VERSION = '0.200000';
3 11 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 ▶use BalanceOfPower::Utils qw( prev_turn );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 extends 'BalanceOfPower::Commands::TargetRoute';
8  
9 sub get_available_targets
10 {
11 0 ▶ my $self = shift;
Subroutine get_available_targets: not called CC=1 SCAR=6.9
Pod undocumented
12 0 my @targets = $self->SUPER::get_available_targets();
13 0 my $nation = $self->actor;
14 0 @targets = grep {! $self->world->exists_treaty_by_type($nation, $_, 'commercial') } @targets;
15 0 return @targets;
16 }
17  
18 sub execute
19 {
20 0 ▶ my $self = shift;
Subroutine execute: not called CC=2 SCAR=17.9
Pod undocumented
21 0 my $query = shift;
22 0 my $nation = shift;
23 0 my $result = $self->SUPER::execute($query, $nation);
24 0 ▶ if($result->{status} == 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($result->{'status'} == 1) { } 0 0 0
25 {
26 0 my $command = $result->{command};
27 0 $command .= "->" . $self->actor;
28 0 return { status => 1, command => $command };
29 }
30 else
31 {
32 0 return $result;
33 }
34 }
35  
36 sub IA
37 {
38 13 ▶ my $self = shift;
Subroutine IA: called CC=7 SCAR=31.8
Pod undocumented
39 13 my $actor = $self->get_nation();
40  
41 13 my $prev_year = prev_turn($actor->current_year);
42 13 my @trade_ko = $actor->get_events("TRADE KO", $prev_year);
43 13 ▶ if(@trade_ko > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (@trade_ko > 1) { } 0 13 13
elsif (@trade_ko == 1) { } 0 13 13
44 {
45 0 for(@trade_ko)
46 {
47 0 my $to_delete = $_;
48 0 $to_delete =~ s/TRADE KO //;
49 0 ▶ if(! $self->world->exists_treaty_by_type($actor->name, $to_delete, 'commercial'))
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->world->exists_treaty_by_type($actor->name, $to_delete, "commercial")) 0 0 0
50 {
51 0 return "DELETE TRADEROUTE " . $actor->name . "->" . $to_delete;
52 }
53 }
54 }
55 elsif(@trade_ko == 1)
56 {
57 0 my @older_trade_ko = $actor->get_events("TRADE KO", prev_turn($prev_year));
58 0 ▶ if(@older_trade_ko > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (@older_trade_ko > 0) 0 0 0
59 {
60 0 my $to_delete = $trade_ko[$#trade_ko];
61 0 $to_delete =~ s/TRADE KO //;
62 0 ▶ if(! $self->world->exists_treaty_by_type($actor->name, $to_delete, 'commercial'))
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->world->exists_treaty_by_type($actor->name, $to_delete, "commercial")) 0 0 0
63 {
64 0 return "DELETE TRADEROUTE " . $actor->name . "->" . $to_delete;
65 }
66 }
67 }
68 13 return undef;
69 }
70
71
72 11 1;
« lib/BalanceOfPower/Role/Warlord.pm ↑ Summary blib/lib/BalanceOfPower/Relations/Friendship.pm »