1
0
forked from 0ad/0ad

Show the number of trade carts and looted resources in the summary screen. Patch by bb, fixes #3311

This was SVN commit r16932.
This commit is contained in:
Nicolas Auvray 2015-08-22 17:57:41 +00:00
parent 74c420f658
commit b694ab41d9
9 changed files with 55 additions and 13 deletions

View File

@ -912,7 +912,8 @@ function reportGame(extendedSimState)
"Cavalry",
"Champion",
"Hero",
"Ship"
"Ship",
"Trader"
];
var unitsCountersTypes = [
"unitsTrained",
@ -993,6 +994,7 @@ function reportGame(extendedSimState)
playerStatistics.totalScore = "";
// Various
playerStatistics.treasuresCollected = "";
playerStatistics.lootCollected = "";
playerStatistics.feminisation = "";
playerStatistics.percentMapExplored = "";
var mapName = Engine.GetMapSettings().Name;
@ -1036,6 +1038,7 @@ function reportGame(extendedSimState)
playerStatistics.tributesReceived += player.statistics.tributesReceived + ",";
playerStatistics.percentMapExplored += player.statistics.percentMapExplored + ",";
playerStatistics.treasuresCollected += player.statistics.treasuresCollected + ",";
playerStatistics.lootCollected += player.statistics.lootCollected + ",";
}
// Send the report with serialized data
@ -1077,6 +1080,7 @@ function reportGame(extendedSimState)
reportObject.tributesReceived = playerStatistics.tributesReceived;
reportObject.percentMapExplored = playerStatistics.percentMapExplored;
reportObject.treasuresCollected = playerStatistics.treasuresCollected;
reportObject.lootCollected = playerStatistics.lootCollected;
reportObject.tradeIncome = playerStatistics.tradeIncome;
Engine.SendGameReport(reportObject);

View File

@ -136,6 +136,11 @@ function calculateTreasureCollected(playerState, position)
return playerState.statistics.treasuresCollected;
}
function calculateLootCollected(playerState, position)
{
return playerState.statistics.lootCollected;
}
function calculateTributeSent(playerState, position)
{
return INCOME_COLOR + playerState.statistics.tributesSent + "[/color] / " + OUTCOME_COLOR + playerState.statistics.tributesReceived + "[/color]";

View File

@ -29,7 +29,7 @@ var panelsData = [
{ "caption": translate("Wonders"), "yStart": 34, "width": 85 }
],
"titleHeadings": [
{ "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) }, // width = 735
{ "caption": translate("Buildings Statistics (Constructed / Lost / Destroyed)"), "yStart": 16, "width": (85 * 7 + 105) }, // width = 700
],
"counters": [ // counters on buildings panel
{"width": 105, "fn": calculateBuildings},
@ -52,10 +52,11 @@ var panelsData = [
{ "caption": translate("Cavalry"), "yStart": 34, "width": 100 },
{ "caption": translate("Champion"), "yStart": 34, "width": 100 },
{ "caption": translate("Heroes"), "yStart": 34, "width": 100 },
{ "caption": translate("Navy"), "yStart": 34, "width": 100 }
{ "caption": translate("Navy"), "yStart": 34, "width": 100 },
{ "caption": translate("Traders"), "yStart": 34, "width": 100 }
],
"titleHeadings": [
{ "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 6 + 120) }, // width = 720
{ "caption": translate("Units Statistics (Trained / Lost / Killed)"), "yStart": 16, "width": (100 * 7 + 120) }, // width = 820
],
"counters": [ // counters on units panel
{"width": 120, "fn": calculateUnits},
@ -64,6 +65,7 @@ var panelsData = [
{"width": 100, "fn": calculateUnits},
{"width": 100, "fn": calculateUnits},
{"width": 100, "fn": calculateUnits},
{"width": 100, "fn": calculateUnits},
{"width": 100, "fn": calculateUnits}
],
"teamCounterFn": calculateColorsTeam
@ -77,7 +79,8 @@ var panelsData = [
{ "caption": translate("Metal"), "yStart": 34, "width": 100 },
{ "caption": translate("Total"), "yStart": 34, "width": 110 },
{ "caption": translate("Treasures collected"), "yStart": 16, "width": 100 },
{ "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 }
{ "caption": translate("Tributes (Sent / Received)"), "yStart": 16, "width": 121 },
{ "caption": translate("Loot"), "yStart": 16, "width": 100 }
],
"titleHeadings": [
{ "caption": translate("Resource Statistics (Gathered / Used)"), "yStart": 16, "width": (100 * 4 + 110) }, // width = 510
@ -88,8 +91,9 @@ var panelsData = [
{"width": 100, "fn": calculateResources},
{"width": 100, "fn": calculateResources},
{"width": 110, "fn": calculateTotalResources},
{"width": 100, "fn": calculateTreasureCollected},
{"width": 121, "fn": calculateTributeSent}
{"width": 100, "fn": calculateTreasureCollected},
{"width": 121, "fn": calculateTributeSent},
{"width": 100, "fn": calculateLootCollected}
],
"teamCounterFn": calculateResourcesTeam
},
@ -118,7 +122,7 @@ var panelsData = [
"headings": [ // headings on miscellaneous panel
{ "caption": translate("Player name"), "yStart": 26, "width": 200 },
{ "caption": translate("Vegetarian\nratio"), "yStart": 16, "width": 100 },
{ "caption": translate("Feminisation"), "yStart": 26, "width": 100 },
{ "caption": translate("Feminisation"), "yStart": 16, "width": 100 },
{ "caption": translate("Kill / Death\nratio"), "yStart": 16, "width": 100 },
{ "caption": translate("Map\nexploration"), "yStart": 16, "width": 100 }
],

View File

@ -21,7 +21,7 @@ const LOST_COLOR = '[color="255 213 213"]';
const KILLED_COLOR = '[color="196 198 255"]';
const BUILDINGS_TYPES = [ "total", "House", "Economic", "Outpost", "Military", "Fortress", "CivCentre", "Wonder" ];
const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship" ];
const UNITS_TYPES = [ "total", "Infantry", "Worker", "Cavalry", "Champion", "Hero", "Ship", "Trader" ];
const RESOURCES_TYPES = [ "food", "wood", "stone", "metal" ];
// Colors used for gathered and traded resources

View File

@ -27,6 +27,10 @@ Looter.prototype.Collect = function(targetEntity)
}
cmpPlayer.AddResources(resources);
let cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
if (cmpStatisticsTracker)
cmpStatisticsTracker.IncreaseLootCollectedCounter(resources);
// If target entity has trader component, add carried goods to loot too
var cmpTrader = Engine.QueryInterface(targetEntity, IID_Trader);
if (cmpTrader)
@ -42,6 +46,10 @@ Looter.prototype.Collect = function(targetEntity)
if (carriedGoods.amount.market2Gain)
resourcesToAdd[carriedGoods.type] += carriedGoods.amount.market2Gain;
cmpPlayer.AddResources(resourcesToAdd);
let cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
if (cmpStatisticsTracker)
cmpStatisticsTracker.IncreaseLootCollectedCounter(resourcesToAdd);
}
}
}

View File

@ -13,7 +13,8 @@ StatisticsTracker.prototype.Init = function()
"Cavalry",
"Champion",
"Hero",
"Ship"
"Ship",
"Trader"
];
this.unitsTrained = {
"Infantry": 0,
@ -23,6 +24,7 @@ StatisticsTracker.prototype.Init = function()
"Champion": 0,
"Hero": 0,
"Ship": 0,
"Trader": 0,
"total": 0
};
this.unitsLost = {
@ -33,6 +35,7 @@ StatisticsTracker.prototype.Init = function()
"Champion": 0,
"Hero": 0,
"Ship": 0,
"Trader": 0,
"total": 0
};
this.unitsLostValue = 0;
@ -44,6 +47,7 @@ StatisticsTracker.prototype.Init = function()
"Champion": 0,
"Hero": 0,
"Ship": 0,
"Trader": 0,
"total": 0
};
this.enemyUnitsKilledValue = 0;
@ -119,6 +123,7 @@ StatisticsTracker.prototype.Init = function()
this.tributesReceived = 0;
this.tradeIncome = 0;
this.treasuresCollected = 0;
this.lootCollected = 0;
};
/**
@ -158,6 +163,7 @@ StatisticsTracker.prototype.GetStatistics = function()
"tributesReceived": this.tributesReceived,
"tradeIncome": this.tradeIncome,
"treasuresCollected": this.treasuresCollected,
"lootCollected": this.lootCollected,
"percentMapExplored": this.GetPercentMapExplored(),
"teamPercentMapExplored": this.GetTeamPercentMapExplored()
};
@ -309,7 +315,7 @@ StatisticsTracker.prototype.IncreaseResourceGatheredCounter = function(type, amo
/**
* @param type Generic type of resource (string)
* @param amount Amount of resource, whick should be added (integer)
* @param amount Amount of resource, which should be added (integer)
*/
StatisticsTracker.prototype.IncreaseResourceUsedCounter = function(type, amount)
{
@ -321,6 +327,12 @@ StatisticsTracker.prototype.IncreaseTreasuresCollectedCounter = function()
this.treasuresCollected++;
};
StatisticsTracker.prototype.IncreaseLootCollectedCounter = function(amount)
{
for (let type in amount)
this.lootCollected += amount[type];
};
StatisticsTracker.prototype.IncreaseResourcesSoldCounter = function(type, amount)
{
this.resourcesSold[type] += amount;

View File

@ -130,6 +130,7 @@ AddMock(100, IID_StatisticsTracker, {
"vegetarianFood": 0,
},
"treasuresCollected": 0,
"lootCollected": 0,
"percentMapExplored": 10,
"teamPercentMapExplored": 10
};
@ -205,6 +206,7 @@ AddMock(101, IID_StatisticsTracker, {
"vegetarianFood": 0,
},
"treasuresCollected": 0,
"lootCollected": 0,
"percentMapExplored": 10,
"teamPercentMapExplored": 10
};
@ -348,6 +350,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
vegetarianFood: 0,
},
treasuresCollected: 0,
lootCollected: 0,
percentMapExplored: 10,
teamPercentMapExplored: 10
},
@ -394,6 +397,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), {
vegetarianFood: 0,
},
treasuresCollected: 0,
lootCollected: 0,
percentMapExplored: 10,
teamPercentMapExplored: 10
},

View File

@ -61,6 +61,7 @@ class PlayerInfo(Base):
metalUsed = Column(Integer)
vegetarianFoodGathered = Column(Integer)
treasuresCollected = Column(Integer)
lootCollected = Column(Integer)
tributesSent = Column(Integer)
tributesReceived = Column(Integer)
totalUnitsTrained = Column(Integer)
@ -87,6 +88,9 @@ class PlayerInfo(Base):
shipUnitsTrained = Column(Integer)
shipUnitsLost = Column(Integer)
enemyShipUnitsKilled = Column(Integer)
traderUnitsTrained = Column(Integer)
traderUnitsLost = Column(Integer)
enemyTraderUnitsKilled = Column(Integer)
totalBuildingsConstructed = Column(Integer)
totalBuildingsLost = Column(Integer)
enemytotalBuildingsDestroyed = Column(Integer)

View File

@ -122,13 +122,14 @@ class LeaderboardList():
totalScoreStats = {'economyScore', 'militaryScore', 'totalScore'}
resourceStats = {'foodGathered', 'foodUsed', 'woodGathered', 'woodUsed',
'stoneGathered', 'stoneUsed', 'metalGathered', 'metalUsed', 'vegetarianFoodGathered',
'treasuresCollected', 'tributesSent', 'tributesReceived'}
'treasuresCollected', 'lootCollected', 'tributesSent', 'tributesReceived'}
unitsStats = {'totalUnitsTrained', 'totalUnitsLost', 'enemytotalUnitsKilled', 'infantryUnitsTrained',
'infantryUnitsLost', 'enemyInfantryUnitsKilled', 'workerUnitsTrained', 'workerUnitsLost',
'enemyWorkerUnitsKilled', 'femaleUnitsTrained', 'femaleUnitsLost', 'enemyFemaleUnitsKilled',
'cavalryUnitsTrained', 'cavalryUnitsLost', 'enemyCavalryUnitsKilled', 'championUnitsTrained',
'championUnitsLost', 'enemyChampionUnitsKilled', 'heroUnitsTrained', 'heroUnitsLost',
'enemyHeroUnitsKilled', 'shipUnitsTrained', 'shipUnitsLost', 'enemyShipUnitsKilled'}
'enemyHeroUnitsKilled', 'shipUnitsTrained', 'shipUnitsLost', 'enemyShipUnitsKilled', 'traderUnitsTrained',
'traderUnitsLost', 'enemyTraderUnitsKilled'}
buildingsStats = {'totalBuildingsConstructed', 'totalBuildingsLost', 'enemytotalBuildingsDestroyed',
'civCentreBuildingsConstructed', 'civCentreBuildingsLost', 'enemyCivCentreBuildingsDestroyed',
'houseBuildingsConstructed', 'houseBuildingsLost', 'enemyHouseBuildingsDestroyed',