2024-07-27 02:11:26 +02:00
|
|
|
/*
|
|
|
|
* GameSTatistics.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../GameConstants.h"
|
2024-08-01 21:30:53 +02:00
|
|
|
#include "../ResourceSet.h"
|
2024-07-27 02:11:26 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2024-08-01 21:30:53 +02:00
|
|
|
struct PlayerState;
|
|
|
|
class CGameState;
|
2024-08-02 00:04:41 +02:00
|
|
|
class CGHeroInstance;
|
2024-08-02 01:18:39 +02:00
|
|
|
class CGMine;
|
2024-08-01 21:30:53 +02:00
|
|
|
|
2024-07-27 02:11:26 +02:00
|
|
|
struct DLL_LINKAGE StatisticDataSetEntry
|
|
|
|
{
|
|
|
|
int day;
|
|
|
|
PlayerColor player;
|
2024-08-01 21:30:53 +02:00
|
|
|
TeamID team;
|
2024-08-01 23:21:41 +02:00
|
|
|
bool isHuman;
|
|
|
|
EPlayerStatus status;
|
2024-08-01 21:30:53 +02:00
|
|
|
TResources resources;
|
2024-08-01 22:36:32 +02:00
|
|
|
int numberHeroes;
|
|
|
|
int numberTowns;
|
|
|
|
int numberArtifacts;
|
|
|
|
si64 armyStrength;
|
|
|
|
int income;
|
2024-08-01 23:21:41 +02:00
|
|
|
double mapVisitedRatio;
|
2024-08-02 01:18:39 +02:00
|
|
|
int obeliskVisited;
|
|
|
|
double mightMagicRatio;
|
|
|
|
std::map<EGameResID, int> numMines;
|
2024-08-02 19:37:46 +02:00
|
|
|
int score;
|
2024-08-02 19:38:33 +02:00
|
|
|
int maxHeroLevel;
|
|
|
|
int numBattlesNeutral;
|
|
|
|
int numBattlesPlayer;
|
|
|
|
int numWinBattlesNeutral;
|
|
|
|
int numWinBattlesPlayer;
|
2024-07-27 02:11:26 +02:00
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h)
|
|
|
|
{
|
|
|
|
h & day;
|
|
|
|
h & player;
|
2024-08-01 21:30:53 +02:00
|
|
|
h & team;
|
2024-08-01 23:21:41 +02:00
|
|
|
h & isHuman;
|
|
|
|
h & status;
|
2024-08-01 21:30:53 +02:00
|
|
|
h & resources;
|
2024-08-01 22:36:32 +02:00
|
|
|
h & numberHeroes;
|
|
|
|
h & numberTowns;
|
|
|
|
h & numberArtifacts;
|
|
|
|
h & armyStrength;
|
|
|
|
h & income;
|
2024-08-01 23:21:41 +02:00
|
|
|
h & mapVisitedRatio;
|
2024-08-02 01:18:39 +02:00
|
|
|
h & obeliskVisited;
|
|
|
|
h & mightMagicRatio;
|
|
|
|
h & numMines;
|
2024-08-02 19:37:46 +02:00
|
|
|
h & score;
|
2024-08-02 19:38:33 +02:00
|
|
|
h & maxHeroLevel;
|
|
|
|
h & numBattlesNeutral;
|
|
|
|
h & numBattlesPlayer;
|
|
|
|
h & numWinBattlesNeutral;
|
|
|
|
h & numWinBattlesPlayer;
|
2024-07-27 02:11:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE StatisticDataSet
|
|
|
|
{
|
|
|
|
std::vector<StatisticDataSetEntry> data;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void add(StatisticDataSetEntry entry);
|
2024-08-01 21:30:53 +02:00
|
|
|
static StatisticDataSetEntry createEntry(const PlayerState * ps, const CGameState * gs);
|
2024-07-27 02:11:26 +02:00
|
|
|
std::string toCsv();
|
|
|
|
|
2024-08-02 19:38:33 +02:00
|
|
|
struct ValueStorage
|
|
|
|
{
|
|
|
|
std::map<PlayerColor, int> numBattlesNeutral;
|
|
|
|
std::map<PlayerColor, int> numBattlesPlayer;
|
|
|
|
std::map<PlayerColor, int> numWinBattlesNeutral;
|
|
|
|
std::map<PlayerColor, int> numWinBattlesPlayer;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h)
|
|
|
|
{
|
|
|
|
h & numBattlesNeutral;
|
|
|
|
h & numBattlesPlayer;
|
|
|
|
h & numWinBattlesNeutral;
|
|
|
|
h & numWinBattlesPlayer;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
ValueStorage values;
|
|
|
|
|
2024-07-27 02:11:26 +02:00
|
|
|
template <typename Handler> void serialize(Handler &h)
|
|
|
|
{
|
|
|
|
h & data;
|
2024-08-02 19:38:33 +02:00
|
|
|
h & values;
|
2024-07-27 02:11:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-08-01 22:36:32 +02:00
|
|
|
class DLL_LINKAGE Statistic
|
|
|
|
{
|
2024-08-02 01:18:39 +02:00
|
|
|
static std::vector<const CGMine *> getMines(const CGameState * gs, const PlayerState * ps);
|
2024-08-01 22:36:32 +02:00
|
|
|
public:
|
2024-08-02 00:04:41 +02:00
|
|
|
using TStat = std::pair<PlayerColor, si64>;
|
|
|
|
|
2024-08-02 01:18:39 +02:00
|
|
|
static int getNumberOfArts(const PlayerState * ps);
|
|
|
|
static si64 getArmyStrength(const PlayerState * ps, bool withTownGarrison = false);
|
2024-08-01 23:56:06 +02:00
|
|
|
static int getIncome(const CGameState * gs, const PlayerState * ps);
|
2024-08-01 23:21:41 +02:00
|
|
|
static double getMapVisitedRatio(const CGameState * gs, PlayerColor player);
|
2024-08-02 19:38:33 +02:00
|
|
|
static const CGHeroInstance * findBestHero(const CGameState * gs, const PlayerColor & color);
|
2024-08-02 00:04:41 +02:00
|
|
|
static std::vector<std::vector<PlayerColor>> getRank(std::vector<TStat> stats);
|
2024-08-02 01:18:39 +02:00
|
|
|
static int getObeliskVisited(const CGameState * gs, const TeamID & t);
|
|
|
|
static double getMightMagicRatio(const PlayerState * ps);
|
|
|
|
static std::map<EGameResID, int> getNumMines(const CGameState * gs, const PlayerState * ps);
|
2024-08-01 22:36:32 +02:00
|
|
|
};
|
|
|
|
|
2024-07-27 02:11:26 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|