From 0d61b645172f4c1164b84ccfcd551f1408b9b206 Mon Sep 17 00:00:00 2001 From: mdiluzio Date: Wed, 17 Dec 2014 08:49:27 +0000 Subject: [PATCH] Some more code for parsing units --- simplePlayer.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/simplePlayer.pl b/simplePlayer.pl index fb42a89..093fff9 100755 --- a/simplePlayer.pl +++ b/simplePlayer.pl @@ -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