mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
92 lines
3.1 KiB
C++
92 lines
3.1 KiB
C++
/*
|
|
* Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
#ifndef __MANGOS_ACHIEVEMENTMGR_H
|
|
#define __MANGOS_ACHIEVEMENTMGR_H
|
|
|
|
#include "Common.h"
|
|
#include "Database/DBCEnums.h"
|
|
#include "Database/DBCStores.h"
|
|
#include "Database/DatabaseEnv.h"
|
|
|
|
#define CRITERIA_CAST_SPELL_REQ_COUNT 46
|
|
|
|
struct CriteriaProgress
|
|
{
|
|
CriteriaProgress(uint32 id, uint32 counter, time_t date = time(NULL))
|
|
{
|
|
this->id = id;
|
|
this->counter = counter;
|
|
this->date = date;
|
|
}
|
|
uint32 id;
|
|
uint32 counter;
|
|
time_t date;
|
|
};
|
|
|
|
struct CriteriaCastSpellRequirement
|
|
{
|
|
uint32 achievementCriteriaId;
|
|
uint32 creatureEntry;
|
|
uint8 playerClass;
|
|
uint8 playerRace;
|
|
};
|
|
|
|
typedef UNORDERED_MAP<uint32, CriteriaProgress*> CriteriaProgressMap;
|
|
typedef UNORDERED_MAP<uint32, time_t> CompletedAchievementMap;
|
|
|
|
class Unit;
|
|
class Player;
|
|
class WorldPacket;
|
|
|
|
enum AchievementCompletionState
|
|
{
|
|
ACHIEVEMENT_COMPLETED_NONE,
|
|
ACHIEVEMENT_COMPLETED_COMPLETED_NOT_STORED,
|
|
ACHIEVEMENT_COMPLETED_COMPLETED_STORED,
|
|
};
|
|
|
|
class AchievementMgr
|
|
{
|
|
public:
|
|
AchievementMgr(Player* pl);
|
|
~AchievementMgr();
|
|
|
|
void LoadFromDB(QueryResult *achievementResult, QueryResult *criteriaResult);
|
|
void SaveToDB();
|
|
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit *unit=NULL, uint32 time=0);
|
|
void CheckAllAchievementCriteria();
|
|
void SendAllAchievementData();
|
|
void SendRespondInspectAchievements(Player* player);
|
|
Player* GetPlayer() { return m_player;}
|
|
|
|
private:
|
|
void SendAchievementEarned(AchievementEntry const* achievement);
|
|
void SendCriteriaUpdate(CriteriaProgress *progress);
|
|
void SetCriteriaProgress(AchievementCriteriaEntry const* entry, uint32 newValue, bool relative=false);
|
|
void CompletedCriteria(AchievementCriteriaEntry const* entry);
|
|
void CompletedAchievement(AchievementEntry const* entry);
|
|
bool IsCompletedCriteria(AchievementCriteriaEntry const* entry);
|
|
AchievementCompletionState GetAchievementCompletionState(AchievementEntry const* entry);
|
|
void BuildAllDataPacket(WorldPacket *data);
|
|
|
|
Player* m_player;
|
|
CriteriaProgressMap m_criteriaProgress;
|
|
CompletedAchievementMap m_completedAchievements;
|
|
static const CriteriaCastSpellRequirement criteriaCastSpellRequirements[];
|
|
};
|
|
#endif
|