mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
The NexusDashboard-parity dashboard (dDashboardServer) and everything built on it on the experimental branch: accounts, characters, properties and moderation tools, permissions shared with in-game slash commands, economy reports, World 3D and property 3D views with client scenery, scheduled events (features, vanity changes, live events, announcements, restarts), vanity files and events, the CDClient browser, the message inspector with saved captures, chat filter tools, community challenges, live ops, the AI moderator helper, and the server-side changes they need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
2.7 KiB
C++
71 lines
2.7 KiB
C++
#ifndef __ILEADERBOARD__H__
|
|
#define __ILEADERBOARD__H__
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "dCommonVars.h"
|
|
#include "eLeaderboardType.h"
|
|
|
|
class ILeaderboard {
|
|
public:
|
|
|
|
struct Entry {
|
|
LWOOBJID charId{};
|
|
uint32_t lastPlayedTimestamp{};
|
|
float primaryScore{};
|
|
float secondaryScore{};
|
|
float tertiaryScore{};
|
|
uint32_t numWins{};
|
|
uint32_t numTimesPlayed{};
|
|
uint32_t ranking{};
|
|
std::string name{};
|
|
};
|
|
|
|
struct Score {
|
|
auto operator<=>(const Score& rhs) const = default;
|
|
|
|
float primaryScore{ 0.0f };
|
|
float secondaryScore{ 0.0f };
|
|
float tertiaryScore{ 0.0f };
|
|
};
|
|
|
|
// Whether a lower primary score ranks higher: races store the time taken. Foot races store the time left on
|
|
// their countdown, so more is better there, like points.
|
|
static bool LowerIsBetter(const eLeaderboardType type) {
|
|
return type == eLeaderboardType::Racing || type == eLeaderboardType::MonumentRace;
|
|
}
|
|
|
|
// Every score on an activity's leaderboard, best first, in the order the game ranks it (it numbers rows in this order)
|
|
std::vector<Entry> GetRankedLeaderboard(const eLeaderboardType type, const uint32_t activityId) {
|
|
switch (type) {
|
|
case eLeaderboardType::SurvivalNS: return GetNsLeaderboard(activityId);
|
|
case eLeaderboardType::Survival: return GetAgsLeaderboard(activityId);
|
|
default: return LowerIsBetter(type) ? GetAscendingLeaderboard(activityId) : GetDescendingLeaderboard(activityId);
|
|
}
|
|
}
|
|
|
|
// Get the donation total for the given activity id.
|
|
virtual std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) = 0;
|
|
|
|
virtual std::vector<ILeaderboard::Entry> GetDescendingLeaderboard(const uint32_t activityId) = 0;
|
|
virtual std::vector<ILeaderboard::Entry> GetAscendingLeaderboard(const uint32_t activityId) = 0;
|
|
virtual std::vector<ILeaderboard::Entry> GetNsLeaderboard(const uint32_t activityId) = 0;
|
|
virtual std::vector<ILeaderboard::Entry> GetAgsLeaderboard(const uint32_t activityId) = 0;
|
|
virtual std::optional<Score> GetPlayerScore(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
|
|
|
virtual void SaveScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) = 0;
|
|
virtual void UpdateScore(const LWOOBJID playerId, const uint32_t gameId, const Score& score) = 0;
|
|
virtual void IncrementNumWins(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
|
virtual void IncrementTimesPlayed(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
|
|
|
// For the dashboard: how many scores each activity has, and removing scores (e.g. cheated ones)
|
|
virtual std::map<uint32_t, uint32_t> GetLeaderboardSizes() = 0;
|
|
virtual void DeleteLeaderboardScore(const LWOOBJID playerId, const uint32_t gameId) = 0;
|
|
virtual void ResetLeaderboard(const uint32_t gameId) = 0;
|
|
};
|
|
|
|
#endif //!__ILEADERBOARD__H__
|