1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

statisic basic

This commit is contained in:
Laserlicht
2024-07-27 02:11:26 +02:00
parent b7b25bffd2
commit fb171ab3a2
9 changed files with 126 additions and 1 deletions

View File

@@ -355,6 +355,22 @@ void ClientCommandManager::handleGetScriptsCommand()
#endif
}
void ClientCommandManager::handleGetStatistic()
{
printCommandMessage("Command accepted.\t");
const boost::filesystem::path outPath = VCMIDirs::get().userExtractedPath() / "statistic";
boost::filesystem::create_directories(outPath);
const boost::filesystem::path filePath = outPath / (vstd::getDateTimeISO8601Basic(std::time(nullptr)) + ".csv");
std::ofstream file(filePath.c_str());
std::string csv = CSH->client->gameState()->statistic.toCsv();
file << csv;
printCommandMessage("Writing statistic done :)\n");
printCommandMessage("Statistic files can be found in " + outPath.string() + " directory\n");
}
void ClientCommandManager::handleGetTextCommand()
{
printCommandMessage("Command accepted.\t");
@@ -597,6 +613,9 @@ void ClientCommandManager::processCommand(const std::string & message, bool call
else if(message=="get scripts")
handleGetScriptsCommand();
else if(message=="get statistic")
handleGetStatistic();
else if(message=="get txt")
handleGetTextCommand();