| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package BalanceOfPower::Commands::DeclareWar; | 
| 2 |  |  |  |  |  |  | $BalanceOfPower::Commands::DeclareWar::VERSION = '0.400105'; | 
| 3 | 13 |  |  | 13 |  | 107 | use v5.10; | 
|  | 13 |  |  |  |  | 28 |  | 
| 4 | 13 |  |  | 13 |  | 41 | use Moo; | 
|  | 13 |  |  |  |  | 15 |  | 
|  | 13 |  |  |  |  | 52 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 13 |  |  | 13 |  | 2411 | use Array::Utils qw(intersect); | 
|  | 13 |  |  |  |  | 25 |  | 
|  | 13 |  |  |  |  | 477 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 13 |  |  | 13 |  | 49 | use BalanceOfPower::Constants ":all"; | 
|  | 13 |  |  |  |  | 13 |  | 
|  | 13 |  |  |  |  | 5318 |  | 
| 9 | 13 |  |  | 13 |  | 57 | use BalanceOfPower::Utils qw( prev_turn ); | 
|  | 13 |  |  |  |  | 18 |  | 
|  | 13 |  |  |  |  | 2585 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | extends 'BalanceOfPower::Commands::InMilitaryRange'; | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub get_available_targets | 
| 14 |  |  |  |  |  |  | { | 
| 15 | 20 |  |  | 20 | 0 | 21 | my $self = shift; | 
| 16 | 20 |  |  |  |  | 62 | my @targets = $self->SUPER::get_available_targets(); | 
| 17 | 20 |  |  |  |  | 25 | my @out = (); | 
| 18 | 20 |  |  |  |  | 29 | for(@targets) | 
| 19 |  |  |  |  |  |  | { | 
| 20 | 6 |  |  |  |  | 8 | my $t = $_; | 
| 21 | 6 | 100 | 33 |  |  | 23 | if((! $self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor) && | 
|  |  |  | 66 |  |  |  |  | 
| 22 |  |  |  |  |  |  | ! $self->world->war_busy($t)) | 
| 23 |  |  |  |  |  |  | { | 
| 24 | 5 |  |  |  |  | 9 | push @out, $t; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  | } | 
| 27 | 20 |  |  |  |  | 304 | return @out; | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub IA | 
| 32 |  |  |  |  |  |  | { | 
| 33 | 20 |  |  | 20 | 0 | 20 | my $self = shift; | 
| 34 | 20 |  |  |  |  | 40 | my $actor = $self->get_nation(); | 
| 35 | 20 |  |  |  |  | 157 | my @choose = $self->world->shuffle("Choosing someone to declare war to for ". $actor->name , $self->get_available_targets()); | 
| 36 | 20 |  |  |  |  | 47 | for(@choose) | 
| 37 |  |  |  |  |  |  | { | 
| 38 | 5 |  |  |  |  | 16 | my $enemy = $self->world->get_nation($_); | 
| 39 | 5 | 100 |  |  |  | 16 | if($actor->good_prey($enemy, $self->world)) | 
| 40 |  |  |  |  |  |  | { | 
| 41 | 1 |  |  |  |  | 5 | return "DECLARE WAR TO " . $enemy->name; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | } | 
| 44 | 19 |  |  |  |  | 40 | return undef; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | 1; |