mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-04-09 17:26:58 +00:00
test: add property and character reputation unit tests
Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/603b2808-f042-447c-ba49-e4a8d9f87856 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6ad65fcfca
commit
ce7b771a7c
@@ -1,6 +1,7 @@
|
||||
#ifndef TESTSQLDATABASE_H
|
||||
#define TESTSQLDATABASE_H
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include "GameDatabase.h"
|
||||
|
||||
@@ -113,11 +114,36 @@ class TestSQLDatabase : public GameDatabase {
|
||||
m_CharacterReputation[charId] = reputation;
|
||||
};
|
||||
std::vector<IPropertyReputationContribution::ContributionInfo> GetPropertyReputationContributions(
|
||||
const LWOOBJID propertyId, const std::string& date) override { return {}; };
|
||||
const LWOOBJID propertyId, const std::string& date) override {
|
||||
const auto key = std::make_pair(propertyId, date);
|
||||
if (m_PropertyContributions.contains(key)) {
|
||||
return m_PropertyContributions.at(key);
|
||||
}
|
||||
return {};
|
||||
};
|
||||
void UpdatePropertyReputationContribution(
|
||||
const LWOOBJID propertyId, const LWOOBJID playerId,
|
||||
const std::string& date, const uint32_t reputationGained) override {};
|
||||
void UpdatePropertyReputation(const LWOOBJID propertyId, const uint32_t reputation) override {};
|
||||
const std::string& date, const uint32_t reputationGained) override {
|
||||
const auto key = std::make_pair(propertyId, date);
|
||||
auto& entries = m_PropertyContributions[key];
|
||||
for (auto& entry : entries) {
|
||||
if (entry.playerId == playerId) {
|
||||
entry.reputationGained = reputationGained;
|
||||
return;
|
||||
}
|
||||
}
|
||||
entries.push_back({ playerId, reputationGained });
|
||||
};
|
||||
void UpdatePropertyReputation(const LWOOBJID propertyId, const uint32_t reputation) override {
|
||||
m_PropertyReputation[propertyId] = reputation;
|
||||
};
|
||||
// Test helper: retrieve the property reputation stored via UpdatePropertyReputation.
|
||||
uint32_t GetPropertyReputation(const LWOOBJID propertyId) const {
|
||||
if (m_PropertyReputation.contains(propertyId)) {
|
||||
return m_PropertyReputation.at(propertyId);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IsNameInUse(const std::string_view name) override { return false; };
|
||||
std::optional<IPropertyContents::Model> GetModel(const LWOOBJID modelID) override { return {}; }
|
||||
@@ -125,6 +151,8 @@ class TestSQLDatabase : public GameDatabase {
|
||||
std::optional<IUgc::Model> GetUgcModel(const LWOOBJID ugcId) override { return {}; }
|
||||
private:
|
||||
std::unordered_map<LWOOBJID, int64_t> m_CharacterReputation;
|
||||
std::unordered_map<LWOOBJID, uint32_t> m_PropertyReputation;
|
||||
std::map<std::pair<LWOOBJID, std::string>, std::vector<IPropertyReputationContribution::ContributionInfo>> m_PropertyContributions;
|
||||
};
|
||||
|
||||
#endif //!TESTSQLDATABASE_H
|
||||
|
||||
Reference in New Issue
Block a user