From 8be1dd54bb17b3ba3e20960aa3c3f696d09facf7 Mon Sep 17 00:00:00 2001 From: nshah25 <68348722+nshah25@users.noreply.github.com> Date: Mon, 3 May 2021 16:07:09 -0400 Subject: Add player statistics to API (#5193) * Fixed issue #5166 Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com> Co-authored-by: Tiger Wang --- src/Statistics.h | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/Statistics.h') diff --git a/src/Statistics.h b/src/Statistics.h index 5944ba8fa..38d2f0f7e 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -25,35 +25,19 @@ exported from the server https://wiki.vg/Data_Generators /** Class that manages the statistics and achievements of a single player. */ -class cStatManager +struct StatisticsManager { -public: - typedef unsigned StatValue; - typedef std::unordered_map CustomStore; - /** Set the value of the specified statistic. */ - void SetValue(Statistic a_Stat, StatValue a_Value); + // TODO: Block tallies, entities killed, all the others - /** Increments the specified statistic. Returns the new value. */ - StatValue AddValue(Statistic a_Stat, StatValue a_Delta = 1); + std::unordered_map Custom; /** Returns whether the prerequisite for awarding an achievement are satisfied. */ - bool SatisfiesPrerequisite(Statistic a_Stat); - - /** Invokes the given callbacks for each category of tracked statistics. */ - template - void ForEachStatisticType(CustomCallback a_Custom) const - { - a_Custom(m_CustomStatistics); - } + bool SatisfiesPrerequisite(CustomStatistic a_Stat) const; private: /** Returns if a statistic is both present and has nonzero value. */ - bool IsStatisticPresent(Statistic a_Stat) const; - - // TODO: Block tallies, entities killed, all the others - - CustomStore m_CustomStatistics; + bool IsStatisticPresent(CustomStatistic a_Stat) const; }; -- cgit v1.2.3