AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
achievement_commandscript Class Reference
Inheritance diagram for achievement_commandscript:
CommandScript ScriptObject

Public Member Functions

 achievement_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleAchievementAddCommand (ChatHandler *handler, AchievementEntry const *achievementEntry)
 
static bool HandleAchievementCheckAllCommand (ChatHandler *handler, Optional< PlayerIdentifier > player)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ achievement_commandscript()

achievement_commandscript::achievement_commandscript ( )
inline
34: CommandScript("achievement_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable achievement_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37 {
38 static ChatCommandTable achievementCommandTable =
39 {
40 { "add", HandleAchievementAddCommand, SEC_GAMEMASTER, Console::No },
41 { "checkall", HandleAchievementCheckAllCommand, SEC_ADMINISTRATOR, Console::Yes }
42 };
43 static ChatCommandTable commandTable =
44 {
45 { "achievement", achievementCommandTable }
46 };
47 return commandTable;
48 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleAchievementCheckAllCommand(ChatHandler *handler, Optional< PlayerIdentifier > player)
Definition: cs_achievement.cpp:63
static bool HandleAchievementAddCommand(ChatHandler *handler, AchievementEntry const *achievementEntry)
Definition: cs_achievement.cpp:50

References HandleAchievementAddCommand(), HandleAchievementCheckAllCommand(), SEC_ADMINISTRATOR, and SEC_GAMEMASTER.

◆ HandleAchievementAddCommand()

static bool achievement_commandscript::HandleAchievementAddCommand ( ChatHandler handler,
AchievementEntry const *  achievementEntry 
)
inlinestatic
51 {
52 Player* target = handler->getSelectedPlayer();
53 if (!target)
54 {
56 return false;
57 }
58 target->CompletedAchievement(achievementEntry);
59
60 return true;
61 }
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
Player * getSelectedPlayer() const
Definition: Chat.cpp:373
Definition: Player.h:1064
void CompletedAchievement(AchievementEntry const *entry)
Definition: Player.cpp:13946

References Player::CompletedAchievement(), ChatHandler::getSelectedPlayer(), LANG_NO_CHAR_SELECTED, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleAchievementCheckAllCommand()

static bool achievement_commandscript::HandleAchievementCheckAllCommand ( ChatHandler handler,
Optional< PlayerIdentifier player 
)
inlinestatic
64 {
65 if (!player)
66 {
67 player = PlayerIdentifier::FromTarget(handler);
68 }
69
70 if (!player)
71 {
73 return false;
74 }
75
76 if (player->IsConnected())
77 {
78 if (Player* target = player->GetConnectedPlayer())
79 target->CheckAllAchievementCriteria();
80 }
81 else
82 {
83 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
84 stmt->SetData(0, uint16(AT_LOGIN_CHECK_ACHIEVS));
85 stmt->SetData(1, player->GetGUID().GetCounter());
86 CharacterDatabase.Execute(stmt);
87 }
88
89 return true;
90 }
std::uint16_t uint16
Definition: Define.h:108
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
@ AT_LOGIN_CHECK_ACHIEVS
Definition: Player.h:610
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
Definition: CharacterDatabase.h:274
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
static Optional< PlayerIdentifier > FromTarget(ChatHandler *handler)
Definition: ChatCommandTags.cpp:138

References AT_LOGIN_CHECK_ACHIEVS, CHAR_UPD_ADD_AT_LOGIN_FLAG, CharacterDatabase, Acore::ChatCommands::PlayerIdentifier::FromTarget(), LANG_PLAYER_NOT_FOUND, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().