TrinityCore
Loading...
Searching...
No Matches
PetitionMgr.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef _PETITIONMGR_H
19#define _PETITIONMGR_H
20
21#include "Define.h"
22#include "ObjectGuid.h"
23#include <string>
24#include <utility>
25#include <vector>
26
36
49
50typedef std::pair<uint32, ObjectGuid> Signature;
51typedef std::vector<Signature> SignaturesVector;
52
54{
57 std::string PetitionName;
59
60 bool IsPetitionSignedByAccount(uint32 accountId) const;
61 void AddSignature(uint32 accountId, ObjectGuid playerGuid, bool isLoading);
62 void UpdateName(std::string const& newName);
63 void RemoveSignatureBySigner(ObjectGuid playerGuid);
64};
65
67{
68 public:
69 PetitionMgr() = default;
70 PetitionMgr(PetitionMgr const&) = delete;
74 ~PetitionMgr() = default;
75
76 static PetitionMgr* instance();
77
78 // Load from DB
79 void LoadPetitions();
80 void LoadSignatures();
81
82 // Petitions
83 void AddPetition(ObjectGuid petitionGuid, ObjectGuid ownerGuid, std::string const& name, bool isLoading);
84 void RemovePetition(ObjectGuid petitionGuid);
85 Petition* GetPetition(ObjectGuid petitionGuid);
86 Petition* GetPetitionByOwner(ObjectGuid ownerGuid);
87 void RemovePetitionsByOwner(ObjectGuid ownerGuid);
88 void RemoveSignaturesBySigner(ObjectGuid signerGuid);
89};
90
91#define sPetitionMgr PetitionMgr::instance()
92
93#endif
#define TC_GAME_API
Definition Define.h:129
uint32_t uint32
Definition Define.h:154
PetitionSigns
Definition PetitionMgr.h:38
@ PETITION_SIGN_ALREADY_SIGNED
Definition PetitionMgr.h:40
@ PETITION_SIGN_ALREADY_IN_GUILD
Definition PetitionMgr.h:41
@ PETITION_SIGN_CANT_SIGN_OWN
Definition PetitionMgr.h:42
@ PETITION_SIGN_OK
Definition PetitionMgr.h:39
@ PETITION_SIGN_FULL
Definition PetitionMgr.h:44
@ PETITION_SIGN_RESTRICTED_ACCOUNT_TRIAL
Definition PetitionMgr.h:46
@ PETITION_SIGN_ALREADY_SIGNED_OTHER
Definition PetitionMgr.h:45
@ PETITION_SIGN_NOT_SERVER
Definition PetitionMgr.h:43
@ PETITION_SIGN_HAS_RESTRICTION
Definition PetitionMgr.h:47
PetitionTurns
Definition PetitionMgr.h:28
@ PETITION_TURN_NEED_MORE_SIGNATURES
Definition PetitionMgr.h:31
@ PETITION_TURN_ALREADY_IN_GUILD
Definition PetitionMgr.h:30
@ PETITION_TURN_GUILD_NAME_INVALID
Definition PetitionMgr.h:33
@ PETITION_TURN_HAS_RESTRICTION
Definition PetitionMgr.h:34
@ PETITION_TURN_GUILD_PERMISSIONS
Definition PetitionMgr.h:32
@ PETITION_TURN_OK
Definition PetitionMgr.h:29
std::pair< uint32, ObjectGuid > Signature
Definition PetitionMgr.h:50
std::vector< Signature > SignaturesVector
Definition PetitionMgr.h:51
PetitionMgr(PetitionMgr &&)=delete
PetitionMgr(PetitionMgr const &)=delete
PetitionMgr & operator=(PetitionMgr &&)=delete
PetitionMgr()=default
PetitionMgr & operator=(PetitionMgr const &)=delete
~PetitionMgr()=default
void UpdateName(std::string const &newName)
void RemoveSignatureBySigner(ObjectGuid playerGuid)
ObjectGuid OwnerGuid
Definition PetitionMgr.h:56
SignaturesVector Signatures
Definition PetitionMgr.h:58
bool IsPetitionSignedByAccount(uint32 accountId) const
ObjectGuid PetitionGuid
Definition PetitionMgr.h:55
void AddSignature(uint32 accountId, ObjectGuid playerGuid, bool isLoading)
std::string PetitionName
Definition PetitionMgr.h:57