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-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-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-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();
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h)
|
|
|
|
{
|
|
|
|
h & data;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-08-01 22:36:32 +02:00
|
|
|
class DLL_LINKAGE Statistic
|
|
|
|
{
|
|
|
|
public:
|
2024-08-02 00:04:41 +02:00
|
|
|
using TStat = std::pair<PlayerColor, si64>;
|
|
|
|
|
2024-08-01 22:36:32 +02:00
|
|
|
static int getNumberOfArts(const PlayerState * ps);
|
|
|
|
static si64 getArmyStrength(const PlayerState * ps);
|
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 00:04:41 +02:00
|
|
|
static const CGHeroInstance * findBestHero(CGameState * gs, const PlayerColor & color);
|
|
|
|
static std::vector<std::vector<PlayerColor>> getRank(std::vector<TStat> stats);
|
2024-08-01 22:36:32 +02:00
|
|
|
};
|
|
|
|
|
2024-07-27 02:11:26 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|