1
0
forked from 0ad/0ad

Do not count domestic animals as units in statistics, based on patch by Deiz. Fixes #1439

This was SVN commit r11922.
This commit is contained in:
fcxSanya 2012-05-29 04:04:41 +00:00
parent 636896dd7f
commit d7752438fe

View File

@ -30,18 +30,18 @@ StatisticsTracker.prototype.Init = function()
StatisticsTracker.prototype.GetStatistics = function()
{
return {
"unitsTrained": this.unitsTrained,
"unitsLost": this.unitsLost,
"enemyUnitsKilled": this.enemyUnitsKilled,
"buildingsConstructed": this.buildingsConstructed,
"buildingsLost": this.buildingsLost,
"enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
"civCentresBuilt": this.civCentresBuilt,
"enemyCivCentresDestroyed": this.enemyCivCentresDestroyed,
"resourcesGathered": this.resourcesGathered,
"unitsTrained": this.unitsTrained,
"unitsLost": this.unitsLost,
"enemyUnitsKilled": this.enemyUnitsKilled,
"buildingsConstructed": this.buildingsConstructed,
"buildingsLost": this.buildingsLost,
"enemyBuildingsDestroyed": this.enemyBuildingsDestroyed,
"civCentresBuilt": this.civCentresBuilt,
"enemyCivCentresDestroyed": this.enemyCivCentresDestroyed,
"resourcesGathered": this.resourcesGathered,
"treasuresCollected": this.treasuresCollected,
"percentMapExplored": this.GetPercentMapExplored()
};
};
};
StatisticsTracker.prototype.IncreaseTrainedUnitsCounter = function()
@ -64,21 +64,25 @@ StatisticsTracker.prototype.KilledEntity = function(targetEntity)
var cmpTargetEntityIdentity = Engine.QueryInterface(targetEntity, IID_Identity);
if (cmpTargetEntityIdentity)
{
var classes = cmpTargetEntityIdentity.GetClassesList();
// we want to deal only with real structures, not foundations
var cmpFoundation = Engine.QueryInterface(targetEntity, IID_Foundation);
var targetIsStructure = classes.indexOf("Structure") != -1 && cmpFoundation == null;
var targetIsUnit = classes.indexOf("Unit") != -1;
var targetIsCivCentre = classes.indexOf("CivCentre") != -1;
// We want to deal only with real structures, not foundations
var targetIsStructure = cmpTargetEntityIdentity.HasClass("Structure") && cmpFoundation == null;
var targetIsDomesticAnimal = cmpTargetEntityIdentity.HasClass("Animal") && cmpTargetEntityIdentity.HasClass("Domestic");
// Don't count domestic animals as units
var targetIsUnit = cmpTargetEntityIdentity.HasClass("Unit") && !targetIsDomesticAnimal;
var targetIsCivCentre = cmpTargetEntityIdentity.HasClass("CivCentre");
var cmpTargetOwnership = Engine.QueryInterface(targetEntity, IID_Ownership);
// don't increase counters if target player is gaia (player 0)
// Don't increase counters if target player is gaia (player 0)
if (cmpTargetOwnership.GetOwner() != 0)
{
if (targetIsUnit) this.enemyUnitsKilled++;
if (targetIsStructure) this.enemyBuildingsDestroyed++;
if (targetIsCivCentre) this.enemyCivCentresDestroyed++;
if (targetIsUnit)
this.enemyUnitsKilled++;
if (targetIsStructure)
this.enemyBuildingsDestroyed++;
if (targetIsCivCentre)
this.enemyCivCentresDestroyed++;
}
}
};
@ -88,14 +92,17 @@ StatisticsTracker.prototype.LostEntity = function(lostEntity)
var cmpLostEntityIdentity = Engine.QueryInterface(lostEntity, IID_Identity);
if (cmpLostEntityIdentity)
{
var classes = cmpLostEntityIdentity.GetClassesList();
// we want to deal only with real structures, not foundations
var cmpFoundation = Engine.QueryInterface(lostEntity, IID_Foundation);
var lostEntityIsStructure = classes.indexOf("Structure") != -1 && cmpFoundation == null;
var lostEntityIsUnit = classes.indexOf("Unit") != -1;
// We want to deal only with real structures, not foundations
var lostEntityIsStructure = cmpLostEntityIdentity.HasClass("Structure") && cmpFoundation == null;
var lostEntityIsDomesticAnimal = cmpLostEntityIdentity.HasClass("Animal") && cmpLostEntityIdentity.HasClass("Domestic");
// Don't count domestic animals as units
var lostEntityIsUnit = cmpLostEntityIdentity.HasClass("Unit") && !lostEntityIsDomesticAnimal;
if (lostEntityIsUnit) this.unitsLost++;
if (lostEntityIsStructure) this.buildingsLost++;
if (lostEntityIsUnit)
this.unitsLost++;
if (lostEntityIsStructure)
this.buildingsLost++;
}
};