| 1 | package BalanceOfPower::Commands::BuildTroops; | ||
| 2 | $BalanceOfPower::Commands::BuildTroops::VERSION = '0.300010'; | ||
| 3 | use Moo; | ||
| 4 | |||
| 5 | use BalanceOfPower::Constants ':all'; | ||
| 6 | |||
| 7 | extends 'BalanceOfPower::Commands::NoArgs'; | ||
| 8 | |||
| 9 | sub allowed | ||
| 10 | { | ||
| 11 | my $self = shift; | ||
| 12 | my $nation = $self->world->get_nation($self->actor); | ||
| 13 | my $other_checks = $self->SUPER::allowed(); | ||
| 14 | if($other_checks) | ||
| 15 | { | ||
| 16 | my $export_cost = $nation->build_troops_cost(); | ||
| 17 | return $nation->production_for_export >= $export_cost; | ||
| 18 | } | ||
| 19 | else | ||
| 20 | { | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | sub IA | ||
| 26 | { | ||
| 27 | my $self = shift; | ||
| 28 | my $actor = $self->get_nation(); | ||
| 29 | if($actor->army < MAX_ARMY_FOR_SIZE->[ $actor->size ]) | ||
| 30 | { | ||
| 31 | if($actor->army < MINIMUM_ARMY_LIMIT) | ||
| 32 | { | ||
| 33 | return "BUILD TROOPS"; | ||
| 34 | } | ||
| 35 | elsif($actor->army < MEDIUM_ARMY_LIMIT) | ||
| 36 | { | ||
| 37 | if($actor->production_for_export > MEDIUM_ARMY_BUDGET) | ||
| 38 | { | ||
| 39 | return "BUILD TROOPS"; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | else | ||
| 43 | { | ||
| 44 | if($actor->production_for_export > MAX_ARMY_BUDGET) | ||
| 45 | { | ||
| 46 | return "BUILD TROOPS"; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
| 50 | return undef; | ||
| 51 | } | ||
| 52 | |||
| 53 | 1; |