object php_bw_load_replay(string path)
WARNING : from version 3.0, php_bw_load_replay() does NOT return FALSE anymore when failing to load a replay ! See the ErrorCode and ErrorString members below for more information on how to test if a replay failed to be loaded.
php_bw_load_replay opens the replay specified as the path argument, extracts all information it can and returns the result.
The returned object has the following members :
- ErrorCode : the code of the error that occurred when loading the replay. 0 means everything went OK.
- ErrorString : the message (in English) related to the error code. OK means, well... evreything went OK :)
- GameName : the name of the game.
- GameType : the type of the game (Melee, One vs One, Free For All, etc...).
- GameLength : the duration of the game (in seconds).
- GameDate : a timestamp stating when the game was played. This timestamp is usable through the date() function.
- Map : an object containing information about the map the game was played on. Detailed specifications about this object can be found below.
- NumPlayer : the total number of players in this game.
- IsBroodWar : 1 if the game was played with the Brood War extension. Does not exist otherwise.
- Players : an array of objects containing information for each player. See below for details. Detailed specifications about the object can be found below.
- Teams : an array of arrays containing the names of each member. The Teams member WILL NOT EXIST if there was no allying during the game whatsoever.
- Matchup : a string based on the races used by the players or the teams, e.g. : PvZ or PPvZT, etc...
- IsRWT : 1 if the replay contains RWT data. 0 if it doesn't.
- IsFPREP : 1 if the replay is an FPREP. 0 if it doesn't.
- Winner : an object containing information on the probable winner of the game. Detailed specifications about this object can be found below. WARNING : this object is present only in duels (i.e. when there are only 2 real players, no matter the number of observers). This is not implemented for 2v2 or other types of games.
- Version : an object containing miscallaneous information about the version of the replay. This is a guess based on the replay's timestamp. Detailed specifications about this object can be found below.
The Players member contains the following members :
- Name : the name of the player.
- IsObserver : if the player was detected as an observer, this flag will be set to 1. Otherwise, it will be empty.
- Race : an integer stating the race of the player. 0 means Zerg, 1 means Terran, 2 means Protoss.
- RaceName : the string and human-readable version of the Race member.
- Number : the ID of the player on the map. This shouldn't be very useful to you :)
- APM : well... this should be obvious :)
- Human : if set to 1, the player was human. For a computer player, this variable is empty.
- Computer : the opposite of the previous member : set to 1 if the player is a CPU, empty otherwise.
- Color : the ID of the color. Like in the player ID case, this shouldn't be very useful to you. We put this in so that there could be some workaround if you have replays involving maps whose colors were customized and are not currently supported by RepASM.
- ColorName : the name of the color (in English). Will display "Unsupported" if the color is a weird one and is not listed in RepASM.
- ColorHTML : the RGB value of the color, as an integer. In order to be fully usable in a HTML code, see the sample code below :
<?php
$colHTML = dechex($player->ColorHTML);
if(strlen($colHTML) < 6) {
$padding = str_repeat("0", 6 - strlen($colHTML));
$colHTML = $padding . $colHTML; }
; echo "<font color=\"#$colHTML\">" . $player->Name . "</font>";
?>
- StartingLocation12 : the starting location of the player if the map was split in 12 like a clock. This is the usual "standard" way of getting a starting location.
- StartingLocation4 : the starting location of the player if the map was split in 4 according to the diagonals. That way, the only values you'll get will be 3, 6, 9 or 12. Look at this example on LT for a better explanation :) This is not the usual method to get starting locations, but it can be helpful to clarify things for maps like LT where the StartingLocation12 info can lead to miscomprehensions.
- normXpos and normYpos form a 2D coordinate. Origin (0,0) is the top left corner of the map while (1,1) is the bottom right corner. It may be useful if you want to plot the starting location of each player on a minimap.
The Teams array contains one array per team, each of them containing only the names of its members.
The
Map object contains the following members :
- Name : the name of the map (might contain "control characters" that colorize the map's name in SC)
- Width : the width of the map, in number of tiles (e.g. 128 for LT)
- Height : the height of the map, in number of tiles (e.g. 128 for LT)
- Tileset : the used tileset, as a numeric value (useful for switch/cases), e.g. 4 for Jungle tileset
- TilesetName : the used tileset as an English string, e.g. "Jungle"
- StartingLocations : an array of integers, giving all starting locations of the map using a 12-clock reference. This can be messy with maps containing observers spots :p
The
Winner object contains the following members :
- Name : the name of the player that might have won the game.
- Probability : probability, in %, that this guess is true. Because the replay does not include any information about who really won a game, we can only guess who won.
The
Version object contains the following members :
- Version : the main version number of the replay. Should be 1.
- Subversion : the subversion number of the replay. Depends on the patch, e.g. will be 12 for a 1.12 replay and so on.
- Revision : internal code to Blizzard. Don't know if it really has a meaning for us mere mortals.
- Code : same as above :)
- VersionName : a human-readable string of the version e.g. "1.13c" or "1.12"
See example here