| 1 | package BalanceOfPower::Commands::DeleteRoute; | ||||||||||||||
| 2 | 11 | $BalanceOfPower::Commands::DeleteRoute::VERSION = '0.300010'; | |||||||||||||
| 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
| |||||||||||||||
| 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 | 0 | ▶ | my $self = shift; | ||||||||||||
|
Subroutine
IA: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||
| 39 | 0 | my $actor = $self->get_nation(); | |||||||||||||
| 40 | |||||||||||||||
| 41 | 0 | my $prev_year = prev_turn($actor->current_year); | |||||||||||||
| 42 | 0 | my @trade_ko = $actor->get_events("TRADE KO", $prev_year); | |||||||||||||
| 43 | 0 | ▶ | if(@trade_ko > 1) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 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
| |||||||||||||||
| 63 | { | ||||||||||||||
| 64 | 0 | return "DELETE TRADEROUTE " . $actor->name . "->" . $to_delete; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | } | ||||||||||||||
| 67 | } | ||||||||||||||
| 68 | 0 | return undef; | |||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | |||||||||||||||
| 72 | 11 | 1; | |||||||||||||