Update using player instead of team and matching new file formats

This commit is contained in:
mdiluzio 2014-12-22 20:03:31 +00:00
parent 19623c6711
commit ac9ed13be8

View file

@ -8,7 +8,7 @@ our $ttrts_perlai_versioncompat_minor = 1;
# Get information about a unit from it's descriptor # Get information about a unit from it's descriptor
sub getUnit sub getUnit
{ {
return ($_[0] =~ /UNIT:(\d+) tm:(\d+) vs:([^ ]+) dr:([^ ]+) ps:\[(\d+),(\d+)\]/); return ($_[0] =~ /UNIT:(\d+) pl:(\d+) vs:([^ ]+) dr:([^ ]+) ps:\[(\d+),(\d+)\]/);
} }
# Get the units from a turn file # Get the units from a turn file
@ -84,17 +84,17 @@ sub GetHeaderForTurn
return ($gameName,$gameX,$gameY); return ($gameName,$gameX,$gameY);
} }
# Get units from a specific team # Get units from a specific player
sub getUnitsOnTeam sub getUnitsOnPlayer
{ {
my $theTeam = shift; my $thePlayer = shift;
my @allUnits = @_; my @allUnits = @_;
my @myUnits; my @myUnits;
for my $unit (@allUnits) for my $unit (@allUnits)
{ {
my ($unitTeam) = $unit =~ /tm:(\d+)/; my ($unitplayer) = $unit =~ /pl:(\d+)/;
if ( $unitTeam == $theTeam ) if ( $unitplayer == $thePlayer )
{ {
push(@myUnits,$unit); push(@myUnits,$unit);
} }
@ -114,10 +114,10 @@ sub GetTurnFile
sub GetCommandFile sub GetCommandFile
{ {
my $turn = shift; my $turn = shift;
my $team = shift; my $player = shift;
my $cmdFileName = "Turn_TURN_Team_TEAM.txt"; my $cmdFileName = "Player_PLAYER_Turn_TURN.txt";
$cmdFileName =~ s/TURN/$turn/; $cmdFileName =~ s/TURN/$turn/;
$cmdFileName =~ s/TEAM/$team/; $cmdFileName =~ s/PLAYER/$player/;
return $cmdFileName; return $cmdFileName;
} }
@ -125,11 +125,11 @@ sub GetCommandFile
sub OutputCommandsFile sub OutputCommandsFile
{ {
my $turn = shift; my $turn = shift;
my $team = shift; my $player = shift;
my $commands = shift; my $commands = shift;
# Get output file # Get output file
our $cmdFileName = GetCommandFile($turn,$team); our $cmdFileName = GetCommandFile($turn,$player);
if (! -e $cmdFileName) if (! -e $cmdFileName)
{ {
@ -172,10 +172,10 @@ sub PrintGameMap
# Fill with units # Fill with units
for my $unit (@units) for my $unit (@units)
{ {
my ($id,$tm,$vs,$dr,$psx,$psy) = getUnit($unit); my ($id,$pl,$vs,$dr,$psx,$psy) = getUnit($unit);
$tm += 31; $pl += 31;
$vs = "\e[".$tm."m".$vs."\e[0m"; $vs = "\e[".$pl."m".$vs."\e[0m";
$map[$psx][$psy] = $vs; $map[$psx][$psy] = $vs;
} }