Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/summary/counters.js
Show All 11 Lines | |||||
function formatSummaryValue(values) | function formatSummaryValue(values) | ||||
{ | { | ||||
if (typeof values != "object") | if (typeof values != "object") | ||||
return values === Infinity ? g_InfinitySymbol : values; | return values === Infinity ? g_InfinitySymbol : values; | ||||
let ret = ""; | let ret = ""; | ||||
for (let type in values) | for (let type in values) | ||||
if (!g_SummaryTypes[type].hideInSummary) | |||||
ret += (g_SummaryTypes[type].color ? | ret += (g_SummaryTypes[type].color ? | ||||
coloredText(values[type], g_SummaryTypes[type].color) : | coloredText(values[type], g_SummaryTypes[type].color) : | ||||
values[type]) + g_SummaryTypes[type].postfix; | values[type]) + g_SummaryTypes[type].postfix; | ||||
return ret; | return ret; | ||||
} | } | ||||
function getPlayerValuesPerTeam(team, index, type, counters, headings) | function getPlayerValuesPerTeam(team, index, type, counters, headings) | ||||
{ | { | ||||
let fn = counters[headings.map(heading => heading.identifier).indexOf(type) - 1].fn; | let fn = counters[headings.map(heading => heading.identifier).indexOf(type) - 1].fn; | ||||
return g_Teams[team].map(player => fn(g_GameData.sim.playerStates[player], index, type)); | return g_Teams[team].map(player => fn(g_GameData.sim.playerStates[player], index, type)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | |||||
function calculateExplorationScore(playerState, index) | function calculateExplorationScore(playerState, index) | ||||
{ | { | ||||
return playerState.sequences.percentMapExplored[index] * 10; | return playerState.sequences.percentMapExplored[index] * 10; | ||||
} | } | ||||
/** | /** | ||||
* Keep this in sync with the score computation in session/ for the lobby rating reports! | * Keep this in sync with the score computation in session/ for the lobby rating reports! | ||||
*/ | */ | ||||
function calculateScoreTotal(playerState, index) | function calculateScoreTotal(playerState, index) | ||||
{ | { | ||||
return calculateEconomyScore(playerState, index) + | return calculateEconomyScore(playerState, index) + | ||||
calculateMilitaryScore(playerState, index) + | calculateMilitaryScore(playerState, index) + | ||||
calculateExplorationScore(playerState, index); | calculateExplorationScore(playerState, index); | ||||
} | } | ||||
function calculateScoreTeam(team, index, type, counters, headings) | function calculateScoreTeam(team, index, type, counters, headings) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | return { | ||||
"killed": playerState.sequences.enemyUnitsKilled[type][index], | "killed": playerState.sequences.enemyUnitsKilled[type][index], | ||||
"lost": playerState.sequences.unitsLost[type][index] | "lost": playerState.sequences.unitsLost[type][index] | ||||
}; | }; | ||||
} | } | ||||
function calculateResources(playerState, index, type) | function calculateResources(playerState, index, type) | ||||
{ | { | ||||
return { | return { | ||||
"count": playerState.sequences.resourcesCount[type][index], | |||||
"gathered": playerState.sequences.resourcesGathered[type][index], | "gathered": playerState.sequences.resourcesGathered[type][index], | ||||
"used": playerState.sequences.resourcesUsed[type][index] - playerState.sequences.resourcesSold[type][index] | "used": playerState.sequences.resourcesUsed[type][index] - playerState.sequences.resourcesSold[type][index] | ||||
}; | }; | ||||
} | } | ||||
function calculateTotalResources(playerState, index) | function calculateTotalResources(playerState, index) | ||||
{ | { | ||||
let totalGathered = 0; | let totalGathered = 0; | ||||
let totalUsed = 0; | let totalUsed = 0; | ||||
let totalCount = 0; | |||||
for (let type of g_ResourceData.GetCodes()) | for (let type of g_ResourceData.GetCodes()) | ||||
{ | { | ||||
totalCount += playerState.sequences.resourcesCount[type][index]; | |||||
totalGathered += playerState.sequences.resourcesGathered[type][index]; | totalGathered += playerState.sequences.resourcesGathered[type][index]; | ||||
totalUsed += playerState.sequences.resourcesUsed[type][index] - playerState.sequences.resourcesSold[type][index]; | totalUsed += playerState.sequences.resourcesUsed[type][index] - playerState.sequences.resourcesSold[type][index]; | ||||
} | } | ||||
return { "gathered": totalGathered, "used": totalUsed }; | return { "count": totalCount, "gathered": totalGathered, "used": totalUsed }; | ||||
} | } | ||||
function calculateTreasureCollected(playerState, index) | function calculateTreasureCollected(playerState, index) | ||||
{ | { | ||||
return playerState.sequences.treasuresCollected[index]; | return playerState.sequences.treasuresCollected[index]; | ||||
} | } | ||||
function calculateLootCollected(playerState, index) | function calculateLootCollected(playerState, index) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
function calculateKillDeathRatio(playerState, index) | function calculateKillDeathRatio(playerState, index) | ||||
{ | { | ||||
return calculateRatio( | return calculateRatio( | ||||
playerState.sequences.enemyUnitsKilled.total[index], | playerState.sequences.enemyUnitsKilled.total[index], | ||||
playerState.sequences.unitsLost.total[index]); | playerState.sequences.unitsLost.total[index]); | ||||
} | } | ||||
function calculatePopulationCount(playerState, index) | |||||
{ | |||||
return { "population": playerState.sequences.populationCount[index] }; | |||||
} | |||||
function calculateMapExploration(playerState, index) | function calculateMapExploration(playerState, index) | ||||
{ | { | ||||
return { "percent": playerState.sequences.percentMapExplored[index] }; | return { "percent": playerState.sequences.percentMapExplored[index] }; | ||||
} | } | ||||
function calculateMapFinalControl(playerState, index) | function calculateMapFinalControl(playerState, index) | ||||
{ | { | ||||
return { "percent": playerState.sequences.percentMapControlled[index] }; | return { "percent": playerState.sequences.percentMapControlled[index] }; | ||||
Show All 31 Lines |
Wildfire Games · Phabricator