Many changes to bring in the Advancement system for upgrading player stats via dice

This commit is contained in:
2025-01-18 11:29:21 -05:00
parent d4fa53d435
commit 7d1a9018df
7 changed files with 38 additions and 27 deletions

View File

@@ -8,6 +8,7 @@
#include <string_view>
#include <tuple>
#include <mutex>
/**
* Table schema for upgrade ranks populated by go script:
@@ -35,7 +36,7 @@
* This loads the ranks from the database and stores them into memory for access. This should only be
* called on server start-up as it is static data that should only change no new builds.
*/
int32 AdvancementMgr::LoadAdvencementRanks() {
int32 AdvancementMgr::LoadAdvancementRanks() {
_advancementRanks.clear();
//
@@ -127,6 +128,8 @@ int32 AdvancementMgr::LoadAdvencementRanks() {
*/
int32 AdvancementMgr::LoadPlayerAdvancements(Player* player) {
std::lock_guard<std::mutex> lock(_playerAdvancementMutex);
constexpr std::string_view query = R"(
SELECT
guid,
@@ -140,7 +143,7 @@ int32 AdvancementMgr::LoadPlayerAdvancements(Player* player) {
QueryResult result = CharacterDatabase.Query(query, player->GetGUID().GetCounter());
// If the player does not have any upgrades just return not a problem until they purchase one.
// If the player does not have any upgrades just return perfectly fine not a problem until they purchase one.
if(!result) {
return 0;
}
@@ -206,7 +209,7 @@ MpAdvancementRank* AdvancementMgr::GetAdvancementRank(uint32 rank, MpAdvancement
}
else
{
MpLogger::error("Advancment Id {} and rank {} could not be found", rank, advancement);
MpLogger::error("Advancement Id {} and rank {} could not be found", rank, advancement);
return nullptr;
}
}
@@ -228,6 +231,8 @@ MpPlayerRank* AdvancementMgr::GetPlayerAdvancementRank(Player* player, MpAdvance
bool AdvancementMgr::UpgradeAdvancement(Player* player, MpAdvancements advancement, uint32 diceCostLevel, uint32 itemEntry1, uint32 itemEntry2, uint32 itemEntry3)
{
std::lock_guard<std::mutex> lock(_playerAdvancementMutex);
// Validators to make sure inputs are correct to perform the upgrade
if(!player) {
MpLogger::error("Could not upgrade advancement for player, player was nullpointer");
@@ -238,7 +243,7 @@ bool AdvancementMgr::UpgradeAdvancement(Player* player, MpAdvancements advanceme
return false;
}
if(itemEntry1 == 0) {
MpLogger::error("Material1 can not be 0 can not perform advancement upgrade for player {} Advancment {}", player->GetName(), advancement);
MpLogger::error("Material1 can not be 0 can not perform advancement upgrade for player {} Advancement {}", player->GetName(), advancement);
return false;
}
@@ -286,20 +291,17 @@ bool AdvancementMgr::UpgradeAdvancement(Player* player, MpAdvancements advanceme
return true;
}
bool AdvancementMgr::ResetPlayerAdvancements(Player* player)
bool AdvancementMgr::ResetPlayerAdvancements(Player* /*player*/)
{
std::lock_guard<std::mutex> lock(_playerAdvancementMutex);
return true;
}
/******************
*
* Private Methods
*
******************/
void AdvancementMgr::_ResetPlayerAdvancement(Player* player, MpAdvancements advancement)
{
std::lock_guard<std::mutex> lock(_playerAdvancementMutex);
return;
}
// Roll them stats DnD style.

View File

@@ -7,8 +7,10 @@
#include <memory>
#include <unordered_map>
#include <map>
#include <mutex>
enum MpAdvancements {
enum MpAdvancements
{
MP_ADV_STRENGTH = 0,
MP_ADV_AGILITY = 1,
MP_ADV_STAMINA = 2,
@@ -72,6 +74,9 @@ struct MpPlayerRank
class AdvancementMgr
{
// Shared mutex for handling writes to shared player advancement data
std::mutex _playerAdvancementMutex;
// All advancement levels for each stat [rank][advancement_id] = AdvancementLevel
std::map<std::pair<uint32 /*rank*/, MpAdvancements>, MpAdvancementRank> _advancementRanks;

View File

@@ -2,7 +2,8 @@
#ifndef MP_CONSTANTS_H
#define MP_CONSTANTS_H
namespace MpConstants {
namespace MpConstants
{
constexpr int ANCIENT_DICE = 911000;
constexpr int DARK_SPIKE = 911001;
}

View File

@@ -15,7 +15,8 @@
#include <vector>
#include <memory>
enum MpDifficulty {
enum MpDifficulty
{
MP_DIFFICULTY_NORMAL = 0,
MP_DIFFICULTY_HEROIC = 1,
MP_DIFFICULTY_EPIC = 2,
@@ -26,7 +27,8 @@ enum MpDifficulty {
class MpDataStore;
struct MpPlayerInstanceData {
struct MpPlayerInstanceData
{
uint32 deaths = 0;
};
@@ -284,7 +286,8 @@ struct MpCreatureData
/**@todo Add Affixes and Aura Spell methods */
};
class MpDataStore {
class MpDataStore
{
private:
MpDataStore()
: _playerData(std::make_unique<std::unordered_map<ObjectGuid, MpPlayerData*>>()),

View File

@@ -6,7 +6,8 @@
#include "TaskScheduler.h"
#include <chrono>
enum MP_SCHEDULE_GROUP {
enum MP_SCHEDULE_GROUP
{
MP_WORLD_TASK_GROUP = 100
};
@@ -25,8 +26,7 @@ enum MP_SCHEDULE_GROUP {
class MpScheduler
{
public:
static MpScheduler* instance ()
{
static MpScheduler* instance () {
static MpScheduler instance;
return &instance;
}

View File

@@ -1,6 +1,6 @@
#include "Creature.h"
#include "CreatureAI.h"
#include "CreatureHooks.h"
// #include "CreatureHooks.h"
#include "MpLogger.h"
#include "MythicPlus.h"
#include "ScriptMgr.h"
@@ -27,12 +27,12 @@ public:
}
void JustDied(Unit* killer) override {
sCreatureHooks->JustDied(me->ToCreature(), killer);
// sCreatureHooks->JustDied(me->ToCreature(), killer);
BaseAI::JustDied(killer);
}
void Reset() override {
sCreatureHooks->JustSpawned(me->ToCreature());
// sCreatureHooks->JustSpawned(me->ToCreature());
BaseAI::Reset();
}

View File

@@ -7,8 +7,7 @@ enum {
};
// This adds schedulers for use across scripts scoped to MythicPlus
void Add_MP_Schedulers()
{
void Add_MP_Schedulers() {
MpLogger::debug("Add_MP_Schedulers()");
new MpScheduler_WorldScript();
}
@@ -22,9 +21,9 @@ void Add_MP_GroupScripts();
void Add_MP_PlayerScripts();
void Add_MP_UnitScripts();
void Add_MP_WorldScripts();
void Add_MP_PlayerMessageEvents();
void Addmod_mythic_plusScripts()
{
void Addmod_mythic_plusScripts() {
Add_MP_AllCreatureScripts();
Add_MP_AllMapScripts();
Add_MP_CommandScripts();
@@ -34,6 +33,7 @@ void Addmod_mythic_plusScripts()
Add_MP_UnitScripts();
Add_MP_WorldScripts();
Add_MP_Schedulers();
Add_MP_PlayerMessageEvents();
// new Ragefire_Bazzalan_Mythic();