@gameye/sdk
Version:
Node.js SDK for Gameye
43 lines • 1.34 kB
JavaScript
/**
* List all players in the match.
* @param statisticState statistic state
*/
export function selectPlayerList(statisticState) {
const playerIndex = statisticState.statistic.player;
if (!playerIndex)
return [];
return Object.values(playerIndex);
}
/**
* Get a list if all players in a team.
* @param statisticState statistic state
* @param teamKey identifier of the team
*/
export function selectPlayerListForTeam(statisticState, teamKey) {
const teamIndex = statisticState.statistic.team;
if (!teamIndex)
return [];
if (!teamIndex[teamKey])
return [];
const playerIndex = statisticState.statistic.player;
if (!playerIndex)
return [];
return Object.entries(teamIndex[teamKey].player).
filter(([, playerEnabled]) => playerEnabled).
map(([playerKey]) => playerIndex[playerKey]);
}
/**
* Get a single player in the match.
* @param statisticState statistic state
* @param playerKey identifier of the player to get the details for
*/
export function selectPlayerItem(statisticState, playerKey) {
const playerIndex = statisticState.statistic.player;
if (!playerIndex)
return null;
const playerItem = playerIndex[playerKey];
if (!playerItem)
return null;
return playerItem;
}
//# sourceMappingURL=player.js.map