« lib/BalanceOfPower/Commands/TargetRoute.pm
↑ Summary
lib/BalanceOfPower/Nation/Role/Shareholder.pm »
| 1 | package BalanceOfPower::Commands::AidInsurgents; | ||
| 2 | $BalanceOfPower::Commands::AidInsurgents::VERSION = '0.300010'; | ||
| 3 | use v5.10; | ||
| 4 | use Moo; | ||
| 5 | |||
| 6 | use Array::Utils qw(intersect); | ||
| 7 | |||
| 8 | use BalanceOfPower::Constants ":all"; | ||
| 9 | use BalanceOfPower::Utils qw( prev_turn ); | ||
| 10 | |||
| 11 | extends 'BalanceOfPower::Commands::InMilitaryRange'; | ||
| 12 | |||
| 13 | |||
| 14 | sub IA | ||
| 15 | { | ||
| 16 | my $self = shift; | ||
| 17 | my $actor = $self->get_nation(); | ||
| 18 | |||
| 19 | my @available = $self->get_available_targets(); | ||
| 20 | my @crises = $self->world->get_crises($actor->name); | ||
| 21 | my @crisis_enemies; | ||
| 22 | foreach my $c (@crises) | ||
| 23 | { | ||
| 24 | push @crisis_enemies, $c->destination($actor->name); | ||
| 25 | } | ||
| 26 | my @choose = $self->world->shuffle("Choosing insurgents to aid for ". $actor->name , intersect(@available, @crisis_enemies)); | ||
| 27 | if(@choose > 0) | ||
| 28 | { | ||
| 29 | return "AID INSURGENTS IN " . $choose[0]; | ||
| 30 | } | ||
| 31 | else | ||
| 32 | { | ||
| 33 | return undef; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; |