« blib/lib/BalanceOfPower/Commands/AddRoute.pm
↑ Summary
blib/lib/BalanceOfPower/Commands/RecallRebelMilitarySupport.pm »
| 1 | package BalanceOfPower::Commands::RecallMilitarySupport; | ||
| 2 | $BalanceOfPower::Commands::RecallMilitarySupport::VERSION = '0.300010'; | ||
| 3 | use Moo; | ||
| 4 | |||
| 5 | use BalanceOfPower::Constants ':all'; | ||
| 6 | |||
| 7 | extends 'BalanceOfPower::Commands::TargetNation'; | ||
| 8 | |||
| 9 | sub get_available_targets | ||
| 10 | { | ||
| 11 | my $self = shift; | ||
| 12 | my @supported = $self->world->supporter($self->actor); | ||
| 13 | my @out = (); | ||
| 14 | for(@supported) | ||
| 15 | { | ||
| 16 | push @out, $_->destination($self->actor); | ||
| 17 | } | ||
| 18 | return @out; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub IA | ||
| 22 | { | ||
| 23 | my $self = shift; | ||
| 24 | my $actor = $self->get_nation(); | ||
| 25 | if($actor->army <= ARMY_TO_RECALL_SUPPORT) | ||
| 26 | { | ||
| 27 | my @supports = $self->get_available_targets(); | ||
| 28 | if(@supports > 0) | ||
| 29 | { | ||
| 30 | @supports = $self->world->shuffle("Choosing support to recall", @supports); | ||
| 31 | return "RECALL MILITARY SUPPORT " . $supports[0]; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | return undef; | ||
| 35 | } | ||
| 36 | |||
| 37 | 1; |