Some more code for parsing units

This commit is contained in:
mdiluzio 2014-12-17 08:49:27 +00:00
parent c0ef1f88b6
commit 0d61b64517

View file

@ -75,10 +75,30 @@ sub OutputCommandsFile
system ("echo $commands > $orderFile"); system ("echo $commands > $orderFile");
} }
# Sort units into teams
sub getUnitsOnTeam
{
my $theTeam = shift;
my @allUnits = @_;;
my @myUnits;
for my $unit (@allUnits)
{
my ($unitTeam) = $unit =~ /tm:(\d+)/;
if ( $unitTeam == $theTeam )
{
push(@myUnits,$unit);
}
}
return @myUnits;
}
# Get commands for a turn # Get commands for a turn
sub GetCommandsForTurn sub GetCommandsForTurn
{ {
my @units = @_; my @units = @_;
my @myUnits = getUnitsOnTeam($team,@units);
# perform AI here # perform AI here