Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/lobby.js
Context not available. | |||||
var g_GameList = {}; | var g_GameList = {}; | ||||
/** | /** | ||||
* All games where buddy joined. | |||||
*/ | |||||
var g_GamesBuddy = undefined; | |||||
/** | |||||
* Used to restore the selection after updating the playerlist. | * Used to restore the selection after updating the playerlist. | ||||
*/ | */ | ||||
var g_SelectedPlayer = ""; | var g_SelectedPlayer = ""; | ||||
Context not available. | |||||
g_SelectedGamePort = g_GameList[gamesBox.selected].port; | g_SelectedGamePort = g_GameList[gamesBox.selected].port; | ||||
} | } | ||||
if (g_GamesBuddy) | |||||
g_GamesBuddy.aliveCompare = !g_GamesBuddy.aliveCompare; | |||||
g_GameList = Engine.GetGameList().map(game => { | g_GameList = Engine.GetGameList().map(game => { | ||||
game.hasBuddies = 0; | game.hasBuddies = 0; | ||||
Context not available. | |||||
// Compute average rating of participating players | // Compute average rating of participating players | ||||
let playerRatings = []; | let playerRatings = []; | ||||
let initGamesBuddy = !g_GamesBuddy; | |||||
if (initGamesBuddy) | |||||
g_GamesBuddy = {"games": [], "aliveCompare": true}; | |||||
if (!g_GamesBuddy.games[game]) | |||||
g_GamesBuddy.games[game] = {"alive": g_GamesBuddy.aliveCompare, "buddies": []}; | |||||
else | |||||
g_GamesBuddy.games[game].alive = g_GamesBuddy.aliveCompare; | |||||
for (let player of stringifiedTeamListToPlayerData(game.players)) | for (let player of stringifiedTeamListToPlayerData(game.players)) | ||||
{ | { | ||||
let [nick, rating] = splitRatingFromNick(player.Name); | let [nick, rating] = splitRatingFromNick(player.Name); | ||||
Context not available. | |||||
if (player.Team != "observer") | if (player.Team != "observer") | ||||
playerRatings.push(rating || g_DefaultLobbyRating); | playerRatings.push(rating || g_DefaultLobbyRating); | ||||
if (g_Buddies.indexOf(nick) != -1) | |||||
if (g_GamesBuddy.games[game].buddies.indexOf(nick) == -1) | |||||
{ | |||||
g_GamesBuddy.games[game].buddies.push(nick); | |||||
if (!initGamesBuddy) | |||||
addChatMessage({ | |||||
"from": "info", | |||||
"text": sprintf( | |||||
translate("Buddy %(buddy)s has joined game %(game)s."), | |||||
{"buddy": g_BuddySymbol + " " + nick, "game": g_BuddySymbol + " " + game.name} | |||||
)} | |||||
); | |||||
} | |||||
// Sort games with playing buddies above games with spectating buddies | // Sort games with playing buddies above games with spectating buddies | ||||
if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) | if (game.hasBuddies < 2 && g_Buddies.indexOf(nick) != -1) | ||||
game.hasBuddies = player.Team == "observer" ? 1 : 2; | game.hasBuddies = player.Team == "observer" ? 1 : 2; | ||||
Context not available. | |||||
return 0; | return 0; | ||||
}); | }); | ||||
if (g_GamesBuddy) | |||||
for (let game of Object.keys(g_GamesBuddy.games)) | |||||
if (g_GamesBuddy.games[game].alive != g_GamesBuddy.aliveCompare) | |||||
delete g_GamesBuddy.games[game]; | |||||
let list_buddy = []; | let list_buddy = []; | ||||
let list_name = []; | let list_name = []; | ||||
let list_mapName = []; | let list_mapName = []; | ||||
Context not available. |
Wildfire Games · Phabricator