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
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ achievement_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable achievement_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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

◆ HandleAchievementAddCommand()

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

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
65 {
66 if (!player)
67 {
68 player = PlayerIdentifier::FromTarget(handler);
69 }
70
71 if (!player)
72 {
74 return false;
75 }
76
77 if (player->IsConnected())
78 {
79 if (Player* target = player->GetConnectedPlayer())
80 target->CheckAllAchievementCriteria();
81 }
82 else
83 {
84 auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
85 stmt->SetData(0, uint16(AT_LOGIN_CHECK_ACHIEVS));
86 stmt->SetData(1, player->GetGUID().GetCounter());
87 CharacterDatabase.Execute(stmt);
88 }
89
90 return true;
91 }
std::uint16_t uint16
Definition: Define.h:109
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_UPD_ADD_AT_LOGIN_FLAG
Definition: CharacterDatabase.h:274
@ AT_LOGIN_CHECK_ACHIEVS
Definition: Player.h:611
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
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().