Some more code for parsing units
This commit is contained in:
parent
c0ef1f88b6
commit
0d61b64517
1 changed files with 20 additions and 0 deletions
|
@ -75,10 +75,30 @@ sub OutputCommandsFile
|
|||
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
|
||||
sub GetCommandsForTurn
|
||||
{
|
||||
my @units = @_;
|
||||
my @myUnits = getUnitsOnTeam($team,@units);
|
||||
|
||||
# perform AI here
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue