Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/lobby/LobbyGamelistReporter.js
/** | /** | ||||
* Send the current list of players, teams, AIs, observers and defeated/won and offline states to the lobby. | * Send the current list of players, teams, AIs, observers and defeated/won and offline states to the lobby. | ||||
* This report excludes the matchsettings, since they do not change during the match. | * This report excludes the matchsettings, since they do not change during the match. | ||||
* | * | ||||
* The playerData format from g_GameAttributes is kept to reuse the GUI function presenting the data, | * The playerData format from g_InitAttributes is kept to reuse the GUI function presenting the data, | ||||
* but the payload size is minimized by only extracting properties relevant for display. | * but the payload size is minimized by only extracting properties relevant for display. | ||||
*/ | */ | ||||
class LobbyGamelistReporter | class LobbyGamelistReporter | ||||
{ | { | ||||
constructor() | constructor() | ||||
{ | { | ||||
if (!LobbyGamelistReporter.Available()) | if (!LobbyGamelistReporter.Available()) | ||||
throw new Error("Lobby gamelist service not available"); | throw new Error("Lobby gamelist service not available"); | ||||
Show All 11 Lines | Engine.SendChangeStateGame( | ||||
playerDataToStringifiedTeamList([...this.getPlayers(), ...this.getObservers()])); | playerDataToStringifiedTeamList([...this.getPlayers(), ...this.getObservers()])); | ||||
} | } | ||||
getPlayers() | getPlayers() | ||||
{ | { | ||||
let players = []; | let players = []; | ||||
// Skip gaia | // Skip gaia | ||||
for (let playerID = 1; playerID < g_GameAttributes.settings.PlayerData.length; ++playerID) | for (let playerID = 1; playerID < g_InitAttributes.settings.PlayerData.length; ++playerID) | ||||
{ | { | ||||
let pData = g_GameAttributes.settings.PlayerData[playerID]; | let pData = g_InitAttributes.settings.PlayerData[playerID]; | ||||
let player = { | let player = { | ||||
"Name": pData.Name, | "Name": pData.Name, | ||||
"Civ": pData.Civ | "Civ": pData.Civ | ||||
}; | }; | ||||
if (g_GameAttributes.settings.LockTeams) | if (g_InitAttributes.settings.LockTeams) | ||||
player.Team = pData.Team; | player.Team = pData.Team; | ||||
if (pData.AI) | if (pData.AI) | ||||
{ | { | ||||
player.AI = pData.AI; | player.AI = pData.AI; | ||||
player.AIDiff = pData.AIDiff; | player.AIDiff = pData.AIDiff; | ||||
player.AIBehavior = pData.AIBehavior; | player.AIBehavior = pData.AIBehavior; | ||||
} | } | ||||
Show All 40 Lines |
Wildfire Games · Phabricator