X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fworld%2FRecord.hpp;h=f90e9f079e4be024cfda58e55aa39fc3d7aa347f;hp=0f4ea7dc8abd86b9934ad781941fd3aa750ab54b;hb=1f8fe0fd81053821f26787e9809cd1a13f747819;hpb=8d3258ace004e89a8cd6b44880b5938c18314401 diff --git a/src/world/Record.hpp b/src/world/Record.hpp index 0f4ea7d..f90e9f0 100644 --- a/src/world/Record.hpp +++ b/src/world/Record.hpp @@ -12,10 +12,9 @@ namespace world { struct Record { + static constexpr int MAX = 10; + std::string name = ""; - creature::Creature *holder = nullptr; - double value = 0.0; - double time = 0.0; enum Type { VALUE, LENGTH, @@ -23,10 +22,27 @@ struct Record { PERCENTAGE, TIME, } type = VALUE; + struct Rank { + creature::Creature *holder = nullptr; + double value = 0.0; + double time = 0.0; + operator bool() const noexcept { return holder; } + } rank[MAX]; + + operator bool() const noexcept { return rank[0]; } + + Rank *begin() noexcept { return rank; } + const Rank *begin() const noexcept { return rank; } + const Rank *cbegin() const noexcept { return rank; } + + Rank *end() noexcept { return rank + 10; } + const Rank *end() const noexcept { return rank + 10; } + const Rank *cend() const noexcept { return rank + 10; } - operator bool() const noexcept { return holder; } + /// update hiscore table, returns rank of given creature or -1 if not ranked + int Update(creature::Creature &, double value, double time) noexcept; - std::string ValueString() const; + std::string ValueString(int i) const; };