Browse Source

add dwellings & expirience

Laserlicht 1 year ago
parent
commit
de128eb471
2 changed files with 22 additions and 0 deletions
  1. 17 0
      lib/gameState/GameStatistics.cpp
  2. 5 0
      lib/gameState/GameStatistics.h

+ 17 - 0
lib/gameState/GameStatistics.cpp

@@ -49,7 +49,9 @@ StatisticDataSetEntry StatisticDataSet::createEntry(const PlayerState * ps, cons
 	data.numberHeroes = ps->heroes.size();
 	data.numberTowns = gs->howManyTowns(ps->color);
 	data.numberArtifacts = Statistic::getNumberOfArts(ps);
+	data.numberDwellings = gs->getPlayerState(ps->color)->dwellings.size();
 	data.armyStrength = Statistic::getArmyStrength(ps, true);
+	data.totalExperience = Statistic::getTotalExperience(ps);
 	data.income = Statistic::getIncome(gs, ps);
 	data.mapExploredRatio = Statistic::getMapExploredRatio(gs, ps->color);
 	data.obeliskVisitedRatio = Statistic::getObeliskVisitedRatio(gs, ps->team);
@@ -82,7 +84,9 @@ std::string StatisticDataSet::toCsv()
 	ss << "NumberHeroes" << ";";
 	ss << "NumberTowns" << ";";
 	ss << "NumberArtifacts" << ";";
+	ss << "NumberDwellings" << ";";
 	ss << "ArmyStrength" << ";";
+	ss << "TotalExperience" << ";";
 	ss << "Income" << ";";
 	ss << "MapExploredRatio" << ";";
 	ss << "ObeliskVisitedRatio" << ";";
@@ -112,7 +116,9 @@ std::string StatisticDataSet::toCsv()
 		ss << entry.numberHeroes << ";";
 		ss << entry.numberTowns <<  ";";
 		ss << entry.numberArtifacts << ";";
+		ss << entry.numberDwellings << ";";
 		ss << entry.armyStrength << ";";
+		ss << entry.totalExperience << ";";
 		ss << entry.income << ";";
 		ss << entry.mapExploredRatio << ";";
 		ss << entry.obeliskVisitedRatio << ";";
@@ -188,6 +194,17 @@ si64 Statistic::getArmyStrength(const PlayerState * ps, bool withTownGarrison)
 	return str;
 }
 
+// get total experience of all heroes
+si64 Statistic::getTotalExperience(const PlayerState * ps)
+{
+	si64 tmp = 0;
+
+	for(auto h : ps->heroes)
+		tmp += h->exp;
+	
+	return tmp;
+}
+
 // get total gold income
 int Statistic::getIncome(const CGameState * gs, const PlayerState * ps)
 {

+ 5 - 0
lib/gameState/GameStatistics.h

@@ -32,7 +32,9 @@ struct DLL_LINKAGE StatisticDataSetEntry
 	int numberHeroes;
 	int numberTowns;
 	int numberArtifacts;
+	int numberDwellings;
 	si64 armyStrength;
+	si64 totalExperience;
 	int income;
 	float mapExploredRatio;
 	float obeliskVisitedRatio;
@@ -59,7 +61,9 @@ struct DLL_LINKAGE StatisticDataSetEntry
 		h & numberHeroes;
 		h & numberTowns;
 		h & numberArtifacts;
+		h & numberDwellings;
 		h & armyStrength;
+		h & totalExperience;
 		h & income;
 		h & mapExploredRatio;
 		h & obeliskVisitedRatio;
@@ -118,6 +122,7 @@ class DLL_LINKAGE Statistic
 public:
 	static int getNumberOfArts(const PlayerState * ps);
 	static si64 getArmyStrength(const PlayerState * ps, bool withTownGarrison = false);
+	static si64 getTotalExperience(const PlayerState * ps);
 	static int getIncome(const CGameState * gs, const PlayerState * ps);
 	static float getMapExploredRatio(const CGameState * gs, PlayerColor player);
 	static const CGHeroInstance * findBestHero(const CGameState * gs, const PlayerColor & color);