Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/lobby/LobbyRatingReporter.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
/** | |||||
* This class is extended in subclasses defined in the files in the subfolder. | |||||
* Each subclass has an InsertValues function that extends the report object. | |||||
elexis: The wording is wrong, because there is the `extends` keyword for inheritance in JS and this… | |||||
* | |||||
* Keep in sync with | |||||
* source/tools/lobbybots/EcheLOn/LobbyRanking.py | |||||
* simulation/components/StatisticsTracker.js | |||||
*/ | |||||
class LobbyRatingReport | |||||
{ | |||||
} | |||||
/** | |||||
* This class reports the state of the current game to the lobby bot when the current player has been defeated or won. | |||||
*/ | |||||
class LobbyRatingReporter | |||||
{ | |||||
constructor() | |||||
{ | |||||
if (!LobbyRatingReporter.Available()) | |||||
throw new Error("Lobby rating service is not available"); | |||||
registerPlayersFinishedHandler(this.onPlayersFinished.bind(this)); | |||||
} | |||||
onPlayersFinished(players) | |||||
{ | |||||
// Observers don't send the state, players send it only once per match | |||||
if (players.indexOf(Engine.GetPlayerID()) != -1) | |||||
Not Done Inline Actions. Stan: . | |||||
return; | |||||
let report = { | |||||
"playerID": Engine.GetPlayerID(), | |||||
"matchID": g_GameAttributes.matchID, | |||||
"mapName": g_GameAttributes.settings.Name, | |||||
Not Done Inline Actions. Stan: . | |||||
}; | |||||
let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState"); | |||||
// Remove gaia | |||||
let playerStates = clone(extendedSimState.players).slice(1); | |||||
for (let name in LobbyRatingReport.prototype) | |||||
new LobbyRatingReport.prototype[name]().InsertValues(report, extendedSimState, playerStates); | |||||
Engine.SendGameReport(report); | |||||
} | |||||
Not Done Inline ActionsOversight, commented code. Stan: Oversight, commented code. | |||||
} | |||||
/** | |||||
* Only 1v1 games are rated, account for gaia. | |||||
*/ | |||||
LobbyRatingReporter.Available = function() | |||||
{ | |||||
return Engine.HasXmppClient() && Engine.IsRankedGame() && g_GameAttributes.settings.PlayerData.length == 3; | |||||
}; |
Wildfire Games · Phabricator
The wording is wrong, because there is the extends keyword for inheritance in JS and this doesnt use inheritance.