php_bw_get_actions
object php_bw_get_actions(string replay_path, string player_name, action_type = REPASM_ALL_ACTIONS, int frequency = 10)
Lists the given type of actions made by the specified player, split in several arrays according to the given frequency. Tough, huh ? ;p
The idea is to allow the creation of charts "à la BWChart". Let's review the input parameters :
- replay_path : easy, it's the full path of the replay you want to parse.
- player_name : easy again, it's the EXACT name of the player you want to list the actions. e.g if you enter "Pusan" but player's full name in the replay is "Pusan[S.G]", it won't find anything. So be sure to use the full name ; for example, get it from the Players info you can get from php_bw_load_replay()
- action_type : another easy one, it's the kind of actions you want to list. You can use the following constants : REPASM_ALL_ACTIONS, REPASM_BUILD_ACTIONS, REPASM_HOTKEY_ACTIONS, REPASM_RESEARCH_ACTIONS, REPASM_UPGRADE_ACTIONS, REPASM_APM. These are, I hope, quite self-explanatory. You can combine them using the "|" operator, except for REPASM_APM which must be used alone. For example, if you want to list build and research actions, you will use REPASM_BUILD_ACTIONS | REPASM_RESEARCH_ACTIONS as a parameter.
- frequency : this one is easy once you understand the concept. The idea is to list all actions for every XX seconds. That way, you can group your data with more or less precision to build more or less precise charts. Got it ? Well the frequency parameter is the XX you want to specify :)
Now, what do we get in return ? An object containing as always ErrorCode and ErrorString and an array. This array contains arrays of objects and these objects are the actions where you will find the action's name (Name member), the time in seconds when it was made (Time member) and its parameters (Params member).
A small example now. Using
this replay of Pusan vs Tossgirl, let's use the function this way : php_bw_get_actions($path_to_the_replay, "pusan[S.G]", REPASM_BUILD_ACTIONS, 10);
This should return an array containing arrays of build actions for Pusan only. Here's a print_r of the object RepASM returns :
stdClass Object
(
[ErrorCode] => 0
[ErrorString] => OK
[Actions] => Array
(
[0] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 49
[Params] => Warp,(115,46),Pylon
)
[1] => stdClass Object
(
[Name] => Build
[Time] => 49
[Params] => Warp,(114,45),Pylon
)
)
[1] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 50
[Params] => Warp,(114,45),Pylon
)
)
[2] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 85
[Params] => Warp,(116,47),Gateway
)
)
[3] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 106
[Params] => Warp,(115,22),Assimilator
)
)
[4] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 131
[Params] => Warp,(116,45),Cybernetics Core
)
)
[5] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 145
[Params] => Warp,(108,27),Pylon
)
)
[6] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 199
[Params] => Warp,(105,27),Robotics Facility
)
)
[7] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 231
[Params] => Warp,(118,31),Pylon
)
)
[8] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 255
[Params] => Warp,(112,47),Gateway
)
)
[9] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 270
[Params] => Warp,(114,32),Observatory
)
[1] => stdClass Object
(
[Name] => Build
[Time] => 270
[Params] => Warp,(115,31),Observatory
)
)
[10] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 280
[Params] => Warp,(115,31),Observatory
)
)
[11] => Array
(
[0] => stdClass Object
(
[Name] => Build
[Time] => 289
[Params] => Warp,(126,20),Pylon
)
)
)
)
Since : 4.0