[Commands] Cleanup #resetaa Command (#4310)

* [Commands] Cleanup #resetaa Command

* Update resetaa.cpp
This commit is contained in:
Alex King
2024-05-22 17:06:51 -04:00
committed by GitHub
parent ca69cc67e8
commit 7e40c5bac2
7 changed files with 49 additions and 19 deletions
+19 -5
View File
@@ -2,18 +2,32 @@
void command_resetaa(Client *c, const Seperator *sep)
{
if (!c->GetTarget() || !c->GetTarget()->IsClient()) {
c->Message(Chat::White, "You must target a player to use this command.");
Client* t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const uint16 arguments = sep->argnum;
const bool is_aa = !strcasecmp(sep->arg[1], "aa");
const bool is_leadership = !strcasecmp(sep->arg[1], "leadership");
if (!arguments || (!is_aa && !is_leadership)) {
c->Message(Chat::White, "Usage: #resetaa aa - Resets and refunds a player's AAs");
c->Message(Chat::White, "Usage: #resetaa leadership - Resets a player's Leadership AAs");
return;
}
auto t = c->GetTarget()->CastToClient();
t->ResetAA();
if (is_aa) {
t->ResetAA();
} else if (is_leadership) {
t->ResetLeadershipAA();
}
c->Message(
Chat::White,
fmt::format(
"Successfully reset all Alternate Advancements for {}.",
"Successfully reset all{} AAs for {}.",
is_aa ? "" : " Leadership",
c->GetTargetDescription(t)
).c_str()
);