Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/LobbyPage/Game.js
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | class Game | ||||
* The performance benefit arises from the fact that for a new gamelist stanza | * The performance benefit arises from the fact that for a new gamelist stanza | ||||
* many if not most games and game properties did not change. | * many if not most games and game properties did not change. | ||||
*/ | */ | ||||
update(newStanza, sortKey) | update(newStanza, sortKey) | ||||
{ | { | ||||
let oldStanza = this.stanza; | let oldStanza = this.stanza; | ||||
let displayData = this.displayData; | let displayData = this.displayData; | ||||
let sortValues = this.sortValues; | let sortValues = this.sortValues; | ||||
g_BuddySymbol = "★"; | |||||
if (oldStanza.name != newStanza.name) | if (oldStanza.name != newStanza.name) | ||||
{ | { | ||||
Engine.ProfileStart("gameName"); | Engine.ProfileStart("gameName"); | ||||
sortValues.gameName = newStanza.name.toLowerCase(); | sortValues.gameName = newStanza.name.toLowerCase(); | ||||
this.updateGameName(newStanza); | this.updateGameName(newStanza); | ||||
Engine.ProfileStop(); | Engine.ProfileStop(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | let players; | ||||
if (player.Team == "observer") | if (player.Team == "observer") | ||||
++observerCount; | ++observerCount; | ||||
else | else | ||||
playerRatingTotal += playerNickRating.rating || g_DefaultLobbyRating; | playerRatingTotal += playerNickRating.rating || g_DefaultLobbyRating; | ||||
// Sort games with playing buddies above games with spectating buddies | // Sort games with playing buddies above games with spectating buddies | ||||
if (hasBuddies < 2 && g_Buddies.indexOf(playerNickRating.nick) != -1) | if (hasBuddies < 2 && g_Buddies.indexOf(playerNickRating.nick) != -1) | ||||
hasBuddies = player.Team == "observer" ? 1 : 2; | hasBuddies = player.Team == "observer" ? 1 : 2; | ||||
} | } | ||||
GrapjasAuthorUnsubmitted Not Done Inline ActionsGrapjas: ```
++playerCount;
``` | |||||
this.observerCount = observerCount; | this.observerCount = observerCount; | ||||
this.hasBuddies = hasBuddies; | this.hasBuddies = hasBuddies; | ||||
let displayData = this.displayData; | let displayData = this.displayData; | ||||
let sortValues = this.sortValues; | let sortValues = this.sortValues; | ||||
displayData.buddy = this.hasBuddies ? setStringTags(g_BuddySymbol, displayData.tags) : ""; | displayData.buddy = this.hasBuddies ? setStringTags(g_BuddySymbol, displayData.tags) : ""; | ||||
Done Inline ActionsDuplication is bad, should be a constant like g_BuddySymbol. vladislavbelov: Duplication is bad, should be a constant like `g_BuddySymbol`. | |||||
sortValues.hasBuddyString = String(hasBuddies); | sortValues.hasBuddyString = String(hasBuddies); | ||||
sortValues.buddy = sortValues.hasBuddyString + sortValues.gameName; | sortValues.buddy = sortValues.hasBuddyString + sortValues.gameName; | ||||
let playerCount = players.length - observerCount; | let playerCount = players.length - observerCount; | ||||
let gameRating = | let gameRating = | ||||
playerCount ? | playerCount ? | ||||
Math.round(playerRatingTotal / playerCount) : | Math.round(playerRatingTotal / playerCount) : | ||||
g_DefaultLobbyRating; | g_DefaultLobbyRating; | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator