| 1 | package BalanceOfPower::Commands::DeclareWar; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | $BalanceOfPower::Commands::DeclareWar::VERSION = '0.200000'; | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Array::Utils qw(intersect); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use BalanceOfPower::Constants ":all"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use BalanceOfPower::Utils qw( prev_turn ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | extends 'BalanceOfPower::Commands::InMilitaryRange'; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | sub get_available_targets | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_available_targets: called CC=5 SCAR=17.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 22 | my @targets = $self->SUPER::get_available_targets(); | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | 22 | my @out = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 22 | for(@targets) | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | my $t = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | 17 | ▶ | if((! $self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
!$self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor and not $self->world->war_busy($t)
not $self->world->is_under_influence($t) or $self->world->is_under_influence($t) ne $self->actor
MC/DC0%0/3
!$self->world->is_under_influence($t) || $self->world->is_under_influence($t) ne $self->actor and not $self->world->war_busy($t)
not $self->world->is_under_influence($t)
$self->world->is_under_influence($t) ne $self->actor
not $self->world->war_busy($t)
Truth table20%1/5
not(A) or B and not(C)
A= not $self->world->is_under_influence($t)B= $self->world->is_under_influence($t) ne $self->actorC= not $self->world->war_busy($t)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ! $self->world->war_busy($t)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 17 | push @out, $t; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 22 | return @out; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub IA | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IA: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 22 | my $actor = $self->get_nation(); | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 22 | my @choose = $self->world->shuffle("Choosing someone to declare war to for ". $actor->name , $self->get_available_targets()); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 22 | for(@choose) | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 17 | my $enemy = $self->world->get_nation($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 17 | ▶ | if($actor->good_prey($enemy, $self->world)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | return "DECLARE WAR TO " . $enemy->name; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 21 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||