8 #include "../Statistics.h" 15 : m_Manager(a_Manager)
24 m_Path = StatsPath +
"/" + a_FileName +
".json";
49 if (Reader.parse(Data, Root,
false))
72 Json::StyledWriter Writer;
73 AString JsonData = Writer.write(Root);
75 File.
Write(JsonData.data(), JsonData.size());
87 for (
unsigned int i = 0; i < static_cast<unsigned int>(
statCount); ++i)
95 a_Out[StatName] = Value;
110 for (Json::Value::const_iterator it = a_In.begin() ; it != a_In.end() ; ++it)
112 AString StatName = it.key().asString();
118 LOGWARNING(
"Invalid statistic type \"%s\"", StatName.c_str());
122 const Json::Value & Node = *it;
128 else if (Node.isObject())
130 StatValue Value = Node.get(
"value", 0).asInt();
138 LOGWARNING(
"Invalid statistic value for type \"%s\"", StatName.c_str());
StatValue GetValue(const eStatistic a_Stat) const
Return the value of the specified stat.
Class that manages the statistics and achievements of a single player.
bool LoadStatFromJSON(const Json::Value &a_In)
static bool CreateFolder(const AString &a_FolderPath)
Creates a new folder with the specified name.
cStatSerializer(const AString &a_WorldName, const AString &a_PlayerName, const AString &a_FileName, cStatManager *a_Manager)
static AString ReadWholeFile(const AString &a_FileName)
Returns the entire contents of the specified file as a string.
static char PathSeparator()
bool Open(const AString &iFileName, eMode iMode)
AString & Printf(AString &str, const char *format, fmt::ArgList args)
Output the formatted text into the string.
void LOGWARNING(const char *a_Format, fmt::ArgList a_ArgList)
static eStatistic GetType(const AString &a_Name)
Name -> Type.
int Write(const void *a_Buffer, size_t a_NumBytes)
Writes up to a_NumBytes bytes from a_Buffer, returns the number of bytes actually written...
void SetValue(const eStatistic a_Stat, const StatValue a_Value)
Set the value of the specified stat.
void Reset()
Reset everything.
static const AString & GetName(const eStatistic a_Type)
Type -> Name.
void SaveStatToJSON(Json::Value &a_Out)