[Commands] Cleanup #permaclass Command. (#1777)

- Cleanup message and logic.
This commit is contained in:
Kinglykrab
2021-11-21 09:56:10 -05:00
committed by GitHub
parent 7559732408
commit 7c12c5d5ef
2 changed files with 31 additions and 19 deletions
+30 -18
View File
@@ -2,27 +2,39 @@
void command_permaclass(Client *c, const Seperator *sep)
{
Client *t = c;
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #permaclass [Class ID]");
return;
}
Client *target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
target = c->GetTarget()->CastToClient();
}
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #permaclass <classnum>");
}
else if (!t->IsClient()) {
c->Message(Chat::White, "Target is not a client.");
}
else {
c->Message(Chat::White, "Setting %s's class...Sending to char select.", t->GetName());
LogInfo("Class change request from [{}] for [{}], requested class:[{}]",
c->GetName(),
t->GetName(),
atoi(sep->arg[1]));
t->SetBaseClass(atoi(sep->arg[1]));
t->Save();
t->Kick("Class was changed.");
auto class_id = std::stoi(sep->arg[1]);
LogInfo("Class changed by {} for {} to {} ({})",
c->GetCleanName(),
target->GetCleanName(),
GetClassIDName(class_id),
class_id
);
target->SetBaseClass(class_id);
target->Save();
target->Kick("Class was changed.");
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Class changed for {} to {} ({}).",
target->GetCleanName(),
GetClassIDName(class_id),
class_id
).c_str()
);
}
}