Changeset View
Standalone View
binaries/data/mods/public/gui/session/session.js
Show First 20 Lines • Show All 1,435 Lines • ▼ Show 20 Lines | function reportGame() | ||||
]; | ]; | ||||
let resourcesTypes = [ | let resourcesTypes = [ | ||||
"wood", | "wood", | ||||
"food", | "food", | ||||
"stone", | "stone", | ||||
"metal" | "metal" | ||||
]; | ]; | ||||
elexis: Last time we changed something in this function, we broke the bot and the bots database!
See… | |||||
Not Done Inline ActionsWhy should this break the ratingbot? Imarok: Why should this break the ratingbot?
The data sent to the bot is the same as before. | |||||
let resourcesCounterTypes = [ | let resourcesCounterTypes = [ | ||||
"resourcesGathered", | "resourcesGathered", | ||||
"resourcesUsed", | "resourcesUsed", | ||||
"resourcesSold", | "resourcesSold", | ||||
"resourcesBought" | "resourcesBought" | ||||
]; | ]; | ||||
let misc = [ | |||||
Not Done Inline Actionsin a cleanup round these should be globals but out of scope bb: in a cleanup round these should be globals but out of scope | |||||
Not Done Inline Actions(The session.js diff is independent from the rest? So maybe we can get this committed separately if it makes things easier for rewriting the rest. Same for the test_GUIInterface) elexis: (The session.js diff is independent from the rest? So maybe we can get this committed… | |||||
Not Done Inline Actionsnope. The only thing I could split apart, is the charts itself, so the most xml changes and about 4 functions. Though I don't really see the sense.. Imarok: nope. The only thing I could split apart, is the charts itself, so the most xml changes and… | |||||
"tradeIncome", | |||||
"tributesSent", | |||||
"tributesReceived", | |||||
"treasuresCollected", | |||||
"lootCollected", | |||||
"feminisation", | |||||
"percentMapExplored" | |||||
]; | |||||
let playerStatistics = {}; | let playerStatistics = {}; | ||||
// Unit Stats | // Unit Stats | ||||
for (let unitCounterType of unitsCountersTypes) | for (let unitCounterType of unitsCountersTypes) | ||||
{ | { | ||||
if (!playerStatistics[unitCounterType]) | if (!playerStatistics[unitCounterType]) | ||||
playerStatistics[unitCounterType] = { }; | playerStatistics[unitCounterType] = { }; | ||||
for (let unitsClass of unitsClasses) | for (let unitsClass of unitsClasses) | ||||
Show All 18 Lines | function reportGame() | ||||
{ | { | ||||
if (!playerStatistics[resourcesCounterType]) | if (!playerStatistics[resourcesCounterType]) | ||||
playerStatistics[resourcesCounterType] = { }; | playerStatistics[resourcesCounterType] = { }; | ||||
for (let resourcesType of resourcesTypes) | for (let resourcesType of resourcesTypes) | ||||
playerStatistics[resourcesCounterType][resourcesType] = ""; | playerStatistics[resourcesCounterType][resourcesType] = ""; | ||||
} | } | ||||
playerStatistics.resourcesGathered.vegetarianFood = ""; | playerStatistics.resourcesGathered.vegetarianFood = ""; | ||||
playerStatistics.tradeIncome = ""; | for (let type of misc) | ||||
// Tribute | playerStatistics[type] = ""; | ||||
playerStatistics.tributesSent = ""; | |||||
playerStatistics.tributesReceived = ""; | |||||
// Total | // Total | ||||
playerStatistics.economyScore = ""; | playerStatistics.economyScore = ""; | ||||
playerStatistics.militaryScore = ""; | playerStatistics.militaryScore = ""; | ||||
playerStatistics.totalScore = ""; | playerStatistics.totalScore = ""; | ||||
// Various | |||||
playerStatistics.treasuresCollected = ""; | |||||
playerStatistics.lootCollected = ""; | |||||
playerStatistics.feminisation = ""; | |||||
playerStatistics.percentMapExplored = ""; | |||||
let mapName = g_GameAttributes.settings.Name; | let mapName = g_GameAttributes.settings.Name; | ||||
let playerStates = ""; | let playerStates = ""; | ||||
let playerCivs = ""; | let playerCivs = ""; | ||||
let teams = ""; | let teams = ""; | ||||
let teamsLocked = true; | let teamsLocked = true; | ||||
// Serialize the statistics for each player into a comma-separated list. | // Serialize the statistics for each player into a comma-separated list. | ||||
// Ignore gaia | // Ignore gaia | ||||
for (let i = 1; i < extendedSimState.players.length; ++i) | for (let i = 1; i < extendedSimState.players.length; ++i) | ||||
Not Done Inline Actionsthis function looks so inefficient but also out of scope bb: this function looks so inefficient but also out of scope | |||||
{ | { | ||||
let player = extendedSimState.players[i]; | let player = extendedSimState.players[i]; | ||||
let maxIndex = player.sequences.time.length - 1; | |||||
Not Done Inline ActionsOne could instead of this use .slice(-1), Don't think that makes things better bb: One could instead of this use .slice(-1), Don't think that makes things better | |||||
Done Inline Actionsadd spaces, since that is more common bb: add spaces, since that is more common | |||||
playerStates += player.state + ","; | playerStates += player.state + ","; | ||||
playerCivs += player.civ + ","; | playerCivs += player.civ + ","; | ||||
teams += player.team + ","; | teams += player.team + ","; | ||||
teamsLocked = teamsLocked && player.teamsLocked; | teamsLocked = teamsLocked && player.teamsLocked; | ||||
for (let resourcesCounterType of resourcesCounterTypes) | for (let resourcesCounterType of resourcesCounterTypes) | ||||
for (let resourcesType of resourcesTypes) | for (let resourcesType of resourcesTypes) | ||||
playerStatistics[resourcesCounterType][resourcesType] += player.statistics[resourcesCounterType][resourcesType] + ","; | playerStatistics[resourcesCounterType][resourcesType] += player.sequences[resourcesCounterType][resourcesType][maxIndex] + ","; | ||||
playerStatistics.resourcesGathered.vegetarianFood += player.statistics.resourcesGathered.vegetarianFood + ","; | playerStatistics.resourcesGathered.vegetarianFood += player.sequences.resourcesGathered.vegetarianFood[maxIndex] + ","; | ||||
for (let unitCounterType of unitsCountersTypes) | for (let unitCounterType of unitsCountersTypes) | ||||
for (let unitsClass of unitsClasses) | for (let unitsClass of unitsClasses) | ||||
playerStatistics[unitCounterType][unitsClass] += player.statistics[unitCounterType][unitsClass] + ","; | playerStatistics[unitCounterType][unitsClass] += player.sequences[unitCounterType][unitsClass][maxIndex] + ","; | ||||
for (let buildingCounterType of buildingsCountersTypes) | for (let buildingCounterType of buildingsCountersTypes) | ||||
for (let buildingsClass of buildingsClasses) | for (let buildingsClass of buildingsClasses) | ||||
playerStatistics[buildingCounterType][buildingsClass] += player.statistics[buildingCounterType][buildingsClass] + ","; | playerStatistics[buildingCounterType][buildingsClass] += player.sequences[buildingCounterType][buildingsClass][maxIndex] + ","; | ||||
let total = 0; | let total = 0; | ||||
for (let type in player.statistics.resourcesGathered) | for (let type in player.sequences.resourcesGathered) | ||||
total += player.statistics.resourcesGathered[type]; | total += player.sequences.resourcesGathered[type][maxIndex]; | ||||
playerStatistics.economyScore += total + ","; | playerStatistics.economyScore += total + ","; | ||||
playerStatistics.militaryScore += Math.round((player.statistics.enemyUnitsKilledValue + | playerStatistics.militaryScore += Math.round((player.sequences.enemyUnitsKilledValue[maxIndex] + | ||||
player.statistics.enemyBuildingsDestroyedValue) / 10) + ","; | player.sequences.enemyBuildingsDestroyedValue[maxIndex]) / 10) + ","; | ||||
playerStatistics.totalScore += (total + Math.round((player.statistics.enemyUnitsKilledValue + | playerStatistics.totalScore += (total + Math.round((player.sequences.enemyUnitsKilledValue[maxIndex] + | ||||
player.statistics.enemyBuildingsDestroyedValue) / 10)) + ","; | player.sequences.enemyBuildingsDestroyedValue[maxIndex]) / 10)) + ","; | ||||
Done Inline ActionsSome duplicated code here, maybe meh bb: Some duplicated code here, maybe meh | |||||
playerStatistics.tradeIncome += player.statistics.tradeIncome + ","; | |||||
playerStatistics.tributesSent += player.statistics.tributesSent + ","; | for (let type of misc) | ||||
playerStatistics.tributesReceived += player.statistics.tributesReceived + ","; | playerStatistics[type] += player.sequences[type][maxIndex] + ","; | ||||
Done Inline ActionsIn original code feminisation wasn't filled, but it was created, also feminisation doesn't seem to exist in the statisticTracker, so not sure i this is correct. Also in some code down we use feminization, so make it consistent bb: In original code `feminisation` wasn't filled, but it was created, also `feminisation` doesn't… | |||||
Done Inline ActionsI know, I think someone forgot to add that. Though, as changing the reportObject bugs the lobby bot I think its better to remove ' feminisation' . Imarok: I know, I think someone forgot to add that. Though, as changing the reportObject bugs the lobby… | |||||
playerStatistics.percentMapExplored += player.statistics.percentMapExplored + ","; | |||||
playerStatistics.treasuresCollected += player.statistics.treasuresCollected + ","; | |||||
playerStatistics.lootCollected += player.statistics.lootCollected + ","; | |||||
} | } | ||||
// Send the report with serialized data | // Send the report with serialized data | ||||
let reportObject = {}; | let reportObject = {}; | ||||
reportObject.timeElapsed = extendedSimState.timeElapsed; | reportObject.timeElapsed = extendedSimState.timeElapsed; | ||||
reportObject.playerStates = playerStates; | reportObject.playerStates = playerStates; | ||||
reportObject.playerID = Engine.GetPlayerID(); | reportObject.playerID = Engine.GetPlayerID(); | ||||
reportObject.matchID = g_GameAttributes.matchID; | reportObject.matchID = g_GameAttributes.matchID; | ||||
Show All 21 Lines | for (let type of unitsClasses) | ||||
reportObject["enemy"+type+"UnitsKilled"] = playerStatistics.enemyUnitsKilled[type]; | reportObject["enemy"+type+"UnitsKilled"] = playerStatistics.enemyUnitsKilled[type]; | ||||
} | } | ||||
for (let type of buildingsClasses) | for (let type of buildingsClasses) | ||||
{ | { | ||||
reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsConstructed"] = playerStatistics.buildingsConstructed[type]; | reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsConstructed"] = playerStatistics.buildingsConstructed[type]; | ||||
reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsLost"] = playerStatistics.buildingsLost[type]; | reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsLost"] = playerStatistics.buildingsLost[type]; | ||||
reportObject["enemy"+type+"BuildingsDestroyed"] = playerStatistics.enemyBuildingsDestroyed[type]; | reportObject["enemy"+type+"BuildingsDestroyed"] = playerStatistics.enemyBuildingsDestroyed[type]; | ||||
} | } | ||||
reportObject.tributesSent = playerStatistics.tributesSent; | for (let type of misc) | ||||
reportObject.tributesReceived = playerStatistics.tributesReceived; | reportObject[type] = playerStatistics[type]; | ||||
reportObject.percentMapExplored = playerStatistics.percentMapExplored; | |||||
reportObject.treasuresCollected = playerStatistics.treasuresCollected; | |||||
reportObject.lootCollected = playerStatistics.lootCollected; | |||||
reportObject.tradeIncome = playerStatistics.tradeIncome; | |||||
Engine.SendGameReport(reportObject); | Engine.SendGameReport(reportObject); | ||||
} | } |
Last time we changed something in this function, we broke the bot and the bots database!
See rP19329
So needs to update the ratingbot accordingly and we will have to rename some table or something in the sqlite.db