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

Public Member Functions

 bf_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 HandleBattlefieldStart (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldEnd (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldEnable (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldSwitch (ChatHandler *handler, uint32 battleId)
 
static bool HandleBattlefieldTimer (ChatHandler *handler, uint32 battleId, std::string timeStr)
 

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

◆ bf_commandscript()

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

Member Function Documentation

◆ GetCommands()

ChatCommandTable bf_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37 {
38 static ChatCommandTable battlefieldcommandTable =
39 {
40 { "start", HandleBattlefieldStart, SEC_ADMINISTRATOR, Console::No },
41 { "stop", HandleBattlefieldEnd, SEC_ADMINISTRATOR, Console::No },
42 { "switch", HandleBattlefieldSwitch, SEC_ADMINISTRATOR, Console::No },
43 { "timer", HandleBattlefieldTimer, SEC_ADMINISTRATOR, Console::No },
44 { "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::No }
45 };
46 static ChatCommandTable commandTable =
47 {
48 { "bf", battlefieldcommandTable }
49 };
50 return commandTable;
51 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleBattlefieldEnable(ChatHandler *handler, uint32 battleId)
Definition: cs_bf.cpp:83
static bool HandleBattlefieldStart(ChatHandler *handler, uint32 battleId)
Definition: cs_bf.cpp:53
static bool HandleBattlefieldTimer(ChatHandler *handler, uint32 battleId, std::string timeStr)
Definition: cs_bf.cpp:120
static bool HandleBattlefieldSwitch(ChatHandler *handler, uint32 battleId)
Definition: cs_bf.cpp:106
static bool HandleBattlefieldEnd(ChatHandler *handler, uint32 battleId)
Definition: cs_bf.cpp:68

References HandleBattlefieldEnable(), HandleBattlefieldEnd(), HandleBattlefieldStart(), HandleBattlefieldSwitch(), HandleBattlefieldTimer(), and SEC_ADMINISTRATOR.

◆ HandleBattlefieldEnable()

static bool bf_commandscript::HandleBattlefieldEnable ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
84 {
85 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
86
87 if (!bf)
88 return false;
89
90 if (bf->IsEnabled())
91 {
92 bf->ToggleBattlefield(false);
93 if (battleId == 1)
94 handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
95 }
96 else
97 {
98 bf->ToggleBattlefield(true);
99 if (battleId == 1)
100 handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
101 }
102
103 return true;
104 }
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:77
Definition: Battlefield.h:206
void ToggleBattlefield(bool enable)
Enable or Disable battlefield.
Definition: Battlefield.h:252
bool IsEnabled()
Return if battlefield is enable.
Definition: Battlefield.h:254
void SendGlobalGMSysMessage(const char *str)
Definition: Chat.cpp:198

References Battlefield::IsEnabled(), sBattlefieldMgr, ChatHandler::SendGlobalGMSysMessage(), and Battlefield::ToggleBattlefield().

Referenced by GetCommands().

◆ HandleBattlefieldEnd()

static bool bf_commandscript::HandleBattlefieldEnd ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
69 {
70 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
71
72 if (!bf)
73 return false;
74
75 bf->EndBattle(true);
76
77 if (battleId == 1)
78 handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
79
80 return true;
81 }
void EndBattle(bool endByTimer)
Definition: Battlefield.cpp:357

References Battlefield::EndBattle(), sBattlefieldMgr, and ChatHandler::SendGlobalGMSysMessage().

Referenced by GetCommands().

◆ HandleBattlefieldStart()

static bool bf_commandscript::HandleBattlefieldStart ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
54 {
55 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
56
57 if (!bf)
58 return false;
59
60 bf->StartBattle();
61
62 if (battleId == 1)
63 handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
64
65 return true;
66 }
void StartBattle()
Definition: Battlefield.cpp:335

References sBattlefieldMgr, ChatHandler::SendGlobalGMSysMessage(), and Battlefield::StartBattle().

Referenced by GetCommands().

◆ HandleBattlefieldSwitch()

static bool bf_commandscript::HandleBattlefieldSwitch ( ChatHandler handler,
uint32  battleId 
)
inlinestatic
107 {
108 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
109
110 if (!bf)
111 return false;
112
113 bf->EndBattle(false);
114 if (battleId == 1)
115 handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
116
117 return true;
118 }

References Battlefield::EndBattle(), sBattlefieldMgr, and ChatHandler::SendGlobalGMSysMessage().

Referenced by GetCommands().

◆ HandleBattlefieldTimer()

static bool bf_commandscript::HandleBattlefieldTimer ( ChatHandler handler,
uint32  battleId,
std::string  timeStr 
)
inlinestatic
121 {
122 if (timeStr.empty())
123 {
124 return false;
125 }
126
127 if (Acore::StringTo<int32>(timeStr).value_or(0) < 0)
128 {
130 return false;
131 }
132
133 int32 time = TimeStringToSecs(timeStr);
134 if (time <= 0)
135 {
136 time = Acore::StringTo<int32>(timeStr).value_or(0);
137 }
138
139 if (time <= 0)
140 {
142 return false;
143 }
144
145 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
146
147 if (!bf)
148 return false;
149
150 bf->SetTimer(time * IN_MILLISECONDS);
152 if (battleId == 1)
153 handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
154
155 return true;
156 }
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
uint32 TimeStringToSecs(const std::string &timestring)
Definition: Util.cpp:163
std::int32_t int32
Definition: Define.h:103
@ LANG_BAD_VALUE
Definition: Language.h:147
void SetTimer(uint32 timer)
Definition: Battlefield.h:355
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218

References IN_MILLISECONDS, LANG_BAD_VALUE, sBattlefieldMgr, ChatHandler::SendErrorMessage(), ChatHandler::SendGlobalGMSysMessage(), Battlefield::SendInitWorldStatesToAll(), Battlefield::SetTimer(), and TimeStringToSecs().

Referenced by GetCommands().