| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package BalanceOfPower::Commands::DeleteRoute; |
|
2
|
|
|
|
|
|
|
$BalanceOfPower::Commands::DeleteRoute::VERSION = '0.400105'; |
|
3
|
13
|
|
|
13
|
|
43
|
use Moo; |
|
|
13
|
|
|
|
|
13
|
|
|
|
13
|
|
|
|
|
59
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
13
|
|
|
13
|
|
2420
|
use BalanceOfPower::Utils qw( prev_turn ); |
|
|
13
|
|
|
|
|
17
|
|
|
|
13
|
|
|
|
|
4561
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
extends 'BalanceOfPower::Commands::TargetRoute'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_available_targets |
|
10
|
|
|
|
|
|
|
{ |
|
11
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
12
|
0
|
|
|
|
|
0
|
my @targets = $self->SUPER::get_available_targets(); |
|
13
|
0
|
|
|
|
|
0
|
my $nation = $self->actor; |
|
14
|
0
|
|
|
|
|
0
|
@targets = grep {! $self->world->exists_treaty_by_type($nation, $_, 'commercial') } @targets; |
|
|
0
|
|
|
|
|
0
|
|
|
15
|
0
|
|
|
|
|
0
|
return @targets; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub execute |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
21
|
0
|
|
|
|
|
0
|
my $query = shift; |
|
22
|
0
|
|
|
|
|
0
|
my $nation = shift; |
|
23
|
0
|
|
|
|
|
0
|
my $result = $self->SUPER::execute($query, $nation); |
|
24
|
0
|
0
|
|
|
|
0
|
if($result->{status} == 1) |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
0
|
|
|
|
|
0
|
my $command = $result->{command}; |
|
27
|
0
|
|
|
|
|
0
|
$command .= "->" . $self->actor; |
|
28
|
0
|
|
|
|
|
0
|
return { status => 1, command => $command }; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
else |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
|
|
0
|
return $result; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub IA |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
9
|
|
|
9
|
0
|
10
|
my $self = shift; |
|
39
|
9
|
|
|
|
|
18
|
my $actor = $self->get_nation(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
28
|
my $prev_year = prev_turn($actor->current_year); |
|
42
|
9
|
|
|
|
|
28
|
my @trade_ko = $actor->get_events("TRADE KO", $prev_year); |
|
43
|
9
|
50
|
|
|
|
30
|
if(@trade_ko > 1) |
|
|
|
50
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
{ |
|
45
|
0
|
|
|
|
|
0
|
for(@trade_ko) |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
0
|
|
|
|
|
0
|
my $to_delete = $_; |
|
48
|
0
|
|
|
|
|
0
|
$to_delete =~ s/TRADE KO //; |
|
49
|
0
|
0
|
|
|
|
0
|
if(! $self->world->exists_treaty_by_type($actor->name, $to_delete, 'commercial')) |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
0
|
|
|
|
|
0
|
return "DELETE TRADEROUTE " . $actor->name . "->" . $to_delete; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
elsif(@trade_ko == 1) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
|
|
0
|
my @older_trade_ko = $actor->get_events("TRADE KO", prev_turn($prev_year)); |
|
58
|
0
|
0
|
|
|
|
0
|
if(@older_trade_ko > 0) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
0
|
|
|
|
|
0
|
my $to_delete = $trade_ko[$#trade_ko]; |
|
61
|
0
|
|
|
|
|
0
|
$to_delete =~ s/TRADE KO //; |
|
62
|
0
|
0
|
|
|
|
0
|
if(! $self->world->exists_treaty_by_type($actor->name, $to_delete, 'commercial')) |
|
63
|
|
|
|
|
|
|
{ |
|
64
|
0
|
|
|
|
|
0
|
return "DELETE TRADEROUTE " . $actor->name . "->" . $to_delete; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
9
|
|
|
|
|
14
|
return undef; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |