diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-05-04 17:11:56 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-05-04 17:11:56 +0200 |
commit | 34bf5c0d9db195edf8b576d1273876966cf650b2 (patch) | |
tree | b9682f8226fef09d3625089ba06235f93ce5c976 /src/StatisticsManager.h | |
parent | Add player statistics to API (#5193) (diff) | |
download | cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.gz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.bz2 cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.lz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.xz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.zst cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.zip |
Diffstat (limited to 'src/StatisticsManager.h')
-rw-r--r-- | src/StatisticsManager.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/StatisticsManager.h b/src/StatisticsManager.h new file mode 100644 index 000000000..288f4aabc --- /dev/null +++ b/src/StatisticsManager.h @@ -0,0 +1,47 @@ + +// Statistics.h + +/* Hello fellow developer ! +In case you are trying to add new statistics to Cuberite you need to do a few things: +--------------------------------------------------------------------------- +1. add a new entry to the enum class Statistic in Registries\Statistics.h file +2. add this to serialization functions in WorldStorage\NamespaceSerializer.cpp + The String in the above is used for saving on disk! + so use the same string! + +In case you want to add a mapping of network IDs to the used stats +you will find a lua script in ../Tools/BlockTypePaletteGenerator/ExportStatMapping.lua +it will provide you with information how to use it. you need a registries.json +exported from the server https://wiki.vg/Data_Generators + + Greetings 12xx12 */ + + + + + +#pragma once + +#include "Registries/CustomStatistics.h" + + + + + +/** Class that manages the statistics and achievements of a single player. */ +struct StatisticsManager +{ + typedef unsigned StatValue; + + // TODO: Block tallies, entities killed, all the others + + std::unordered_map<CustomStatistic, StatValue> Custom; + + /** Returns whether the prerequisite for awarding an achievement are satisfied. */ + bool SatisfiesPrerequisite(CustomStatistic a_Stat) const; + +private: + + /** Returns if a statistic is both present and has nonzero value. */ + bool IsStatisticPresent(CustomStatistic a_Stat) const; +}; |