mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-19 23:40:39 +00:00
Add resource and population counts to the summary screen.
Patch by: @toonijn Differential revision: D3395 Fixes: #4554 Reviewed by: @Freagarach, @wraitii Comments by: @Angen, @Imarok, @Stan This was SVN commit r24721.
This commit is contained in:
@@ -251,6 +251,7 @@
|
|||||||
{ "nick": "thamlett", "name": "Timothy Hamlett" },
|
{ "nick": "thamlett", "name": "Timothy Hamlett" },
|
||||||
{ "nick": "thedrunkyak", "name": "Dan Fuhr" },
|
{ "nick": "thedrunkyak", "name": "Dan Fuhr" },
|
||||||
{ "nick": "Tobbi" },
|
{ "nick": "Tobbi" },
|
||||||
|
{ "nick": "Toonijn", "name": "Toon Baeyens" },
|
||||||
{ "nick": "TrinityDeath", "name": "Jethro Lu" },
|
{ "nick": "TrinityDeath", "name": "Jethro Lu" },
|
||||||
{ "nick": "triumvir", "name": "Corin Schedler" },
|
{ "nick": "triumvir", "name": "Corin Schedler" },
|
||||||
{ "nick": "trompetin17", "name": "Juan Guillermo" },
|
{ "nick": "trompetin17", "name": "Juan Guillermo" },
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ function formatSummaryValue(values)
|
|||||||
|
|
||||||
let ret = "";
|
let ret = "";
|
||||||
for (let type in values)
|
for (let type in values)
|
||||||
ret += (g_SummaryTypes[type].color ?
|
if (!g_SummaryTypes[type].hideInSummary)
|
||||||
coloredText(values[type], g_SummaryTypes[type].color) :
|
ret += (g_SummaryTypes[type].color ?
|
||||||
values[type]) + g_SummaryTypes[type].postfix;
|
coloredText(values[type], g_SummaryTypes[type].color) :
|
||||||
|
values[type]) + g_SummaryTypes[type].postfix;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ function calculateExplorationScore(playerState, index)
|
|||||||
/**
|
/**
|
||||||
* 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) +
|
||||||
@@ -218,6 +219,7 @@ function calculateUnits(playerState, index, type)
|
|||||||
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]
|
||||||
};
|
};
|
||||||
@@ -227,14 +229,16 @@ 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)
|
||||||
@@ -321,6 +325,11 @@ function calculateKillDeathRatio(playerState, 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] };
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ var getScorePanelsData = () => [
|
|||||||
"headings": [
|
"headings": [
|
||||||
{ "identifier": "playername", "caption": translate("Player name"), "yStart": 26, "width": 200 },
|
{ "identifier": "playername", "caption": translate("Player name"), "yStart": 26, "width": 200 },
|
||||||
{ "identifier": "killDeath", "caption": translate("Kill / Death ratio"), "yStart": 16, "width": 100, "format": "DECIMAL2" },
|
{ "identifier": "killDeath", "caption": translate("Kill / Death ratio"), "yStart": 16, "width": 100, "format": "DECIMAL2" },
|
||||||
|
{ "identifier": "population", "caption": translate("Population"), "yStart": 16, "width": 100, "hideInSummary": true },
|
||||||
{ "identifier": "mapControlPeak", "caption": translate("Map control (peak)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
{ "identifier": "mapControlPeak", "caption": translate("Map control (peak)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||||
{ "identifier": "mapControl", "caption": translate("Map control (finish)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
{ "identifier": "mapControl", "caption": translate("Map control (finish)"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||||
{ "identifier": "mapExploration", "caption": translate("Map exploration"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
{ "identifier": "mapExploration", "caption": translate("Map exploration"), "yStart": 16, "width": 100, "format": "PERCENTAGE" },
|
||||||
@@ -213,6 +214,7 @@ var getScorePanelsData = () => [
|
|||||||
"titleHeadings": [],
|
"titleHeadings": [],
|
||||||
"counters": [
|
"counters": [
|
||||||
{ "width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12 },
|
{ "width": 100, "fn": calculateKillDeathRatio, "verticalOffset": 12 },
|
||||||
|
{ "width": 100, "fn": calculatePopulationCount, "verticalOffset": 12, "hideInSummary": true },
|
||||||
{ "width": 100, "fn": calculateMapPeakControl, "verticalOffset": 12 },
|
{ "width": 100, "fn": calculateMapPeakControl, "verticalOffset": 12 },
|
||||||
{ "width": 100, "fn": calculateMapFinalControl, "verticalOffset": 12 },
|
{ "width": 100, "fn": calculateMapFinalControl, "verticalOffset": 12 },
|
||||||
{ "width": 100, "fn": calculateMapExploration, "verticalOffset": 12 },
|
{ "width": 100, "fn": calculateMapExploration, "verticalOffset": 12 },
|
||||||
@@ -255,8 +257,10 @@ function resetGeneralPanel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGeneralPanelHeadings(headings)
|
function updateGeneralPanelHeadings(allHeadings)
|
||||||
{
|
{
|
||||||
|
let headings = allHeadings.filter(heading => !heading.hideInSummary);
|
||||||
|
|
||||||
let left = 50;
|
let left = 50;
|
||||||
for (let h in headings)
|
for (let h in headings)
|
||||||
{
|
{
|
||||||
@@ -295,8 +299,9 @@ function updateGeneralPanelTitles(titleHeadings)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGeneralPanelCounter(counters)
|
function updateGeneralPanelCounter(allCounters)
|
||||||
{
|
{
|
||||||
|
let counters = allCounters.filter(counter => !counter.hideInSummary);
|
||||||
let rowPlayerObjectWidth = 0;
|
let rowPlayerObjectWidth = 0;
|
||||||
let left = 0;
|
let left = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ var g_SummaryTypes = {
|
|||||||
"caption": translate("Gathered"),
|
"caption": translate("Gathered"),
|
||||||
"postfix": " / "
|
"postfix": " / "
|
||||||
},
|
},
|
||||||
|
"count": {
|
||||||
|
"caption": translate("Count"),
|
||||||
|
"hideInSummary": true
|
||||||
|
},
|
||||||
"sent": {
|
"sent": {
|
||||||
"color": g_TypeColors.green,
|
"color": g_TypeColors.green,
|
||||||
"caption": translate("Sent"),
|
"caption": translate("Sent"),
|
||||||
@@ -90,6 +94,11 @@ var g_SummaryTypes = {
|
|||||||
"caption": translate("Received"),
|
"caption": translate("Received"),
|
||||||
"postfix": ""
|
"postfix": ""
|
||||||
},
|
},
|
||||||
|
"population": {
|
||||||
|
"color": g_TypeColors.red,
|
||||||
|
"caption": translate("Population"),
|
||||||
|
"postfix": ""
|
||||||
|
},
|
||||||
"sold": {
|
"sold": {
|
||||||
"color": g_TypeColors.red,
|
"color": g_TypeColors.red,
|
||||||
"caption": translate("Sold"),
|
"caption": translate("Sold"),
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ StatisticsTracker.prototype.GetStatistics = function()
|
|||||||
"enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
|
"enemyBuildingsDestroyedValue": this.enemyBuildingsDestroyedValue,
|
||||||
"buildingsCaptured": this.buildingsCaptured,
|
"buildingsCaptured": this.buildingsCaptured,
|
||||||
"buildingsCapturedValue": this.buildingsCapturedValue,
|
"buildingsCapturedValue": this.buildingsCapturedValue,
|
||||||
|
"resourcesCount": this.GetResourceCounts(),
|
||||||
"resourcesGathered": this.resourcesGathered,
|
"resourcesGathered": this.resourcesGathered,
|
||||||
"resourcesUsed": this.resourcesUsed,
|
"resourcesUsed": this.resourcesUsed,
|
||||||
"resourcesSold": this.resourcesSold,
|
"resourcesSold": this.resourcesSold,
|
||||||
@@ -140,6 +141,7 @@ StatisticsTracker.prototype.GetStatistics = function()
|
|||||||
"tradeIncome": this.tradeIncome,
|
"tradeIncome": this.tradeIncome,
|
||||||
"treasuresCollected": this.treasuresCollected,
|
"treasuresCollected": this.treasuresCollected,
|
||||||
"lootCollected": this.lootCollected,
|
"lootCollected": this.lootCollected,
|
||||||
|
"populationCount": this.GetPopulationCount(),
|
||||||
"percentMapExplored": this.GetPercentMapExplored(),
|
"percentMapExplored": this.GetPercentMapExplored(),
|
||||||
"teamPercentMapExplored": this.GetTeamPercentMapExplored(),
|
"teamPercentMapExplored": this.GetTeamPercentMapExplored(),
|
||||||
"percentMapControlled": this.GetPercentMapControlled(),
|
"percentMapControlled": this.GetPercentMapControlled(),
|
||||||
@@ -345,6 +347,17 @@ StatisticsTracker.prototype.CapturedEntity = function(capturedEntity)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Object} - The amount of available resources.
|
||||||
|
*/
|
||||||
|
StatisticsTracker.prototype.GetResourceCounts = function()
|
||||||
|
{
|
||||||
|
let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
||||||
|
return cmpPlayer ?
|
||||||
|
cmpPlayer.GetResourceCounts() :
|
||||||
|
Object.fromEntries(Resources.GetCodes().map(res => [res, 0]));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} type - generic type of resource.
|
* @param {string} type - generic type of resource.
|
||||||
* @param {number} amount - amount of resource, whick should be added.
|
* @param {number} amount - amount of resource, whick should be added.
|
||||||
@@ -403,6 +416,12 @@ StatisticsTracker.prototype.IncreaseTradeIncomeCounter = function(amount)
|
|||||||
this.tradeIncome += amount;
|
this.tradeIncome += amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StatisticsTracker.prototype.GetPopulationCount = function()
|
||||||
|
{
|
||||||
|
let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
|
||||||
|
return cmpPlayer ? cmpPlayer.GetPopulationCount() : 0;
|
||||||
|
};
|
||||||
|
|
||||||
StatisticsTracker.prototype.IncreaseSuccessfulBribesCounter = function()
|
StatisticsTracker.prototype.IncreaseSuccessfulBribesCounter = function()
|
||||||
{
|
{
|
||||||
++this.successfulBribes;
|
++this.successfulBribes;
|
||||||
|
|||||||
Reference in New Issue
Block a user