Alex King f25e37d0c5
[Commands] Consolidate #set-like commands into a singular #set command (#3486)
* First push

* Final push.

* Consolidate zone commands in to one.

* Update command.cpp

* Remove debug messages.

* Test

* Add support for sub command status levels.

* Update command.cpp

* Update client.cpp

* Update database_update_manifest.cpp

* Update version.h

* Update item.cpp

* Update version.h

* Update database_update_manifest.cpp

* Fix command arguments.

* Help message.

* Update command.cpp

* Do DB injection/deletion

* Indent

* Update server_locked.cpp

* Update set.cpp

* Lock aliases

* Update command_subsettings_repository.h

* Update set.cpp

* Fix

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-07-15 00:37:51 -05:00

50 lines
1.0 KiB
C++
Executable File

#include "../../client.h"
void SetEXP(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
if (arguments < 3 || !sep->IsNumber(3)) {
c->Message(Chat::White, "Usage: #set exp [aa|exp] [Amount]");
return;
}
auto t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const std::string& type = Strings::ToLower(sep->arg[2]);
const bool is_aa = Strings::EqualFold(type, "aa");
const bool is_exp = Strings::EqualFold(type, "exp");
if (!is_aa && !is_exp) {
c->Message(Chat::White, "Usage: #set exp [aa|exp] [Amount]");
return;
}
const uint32 amount = Strings::ToUnsignedInt(sep->arg[3]);
if (is_aa) {
t->SetEXP(
t->GetEXP(),
amount
);
} else if (is_exp) {
t->SetEXP(
amount,
t->GetAAXP()
);
}
c->Message(
Chat::White,
fmt::format(
"{} now {} {} {}experience.",
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
c == t ? "have" : "has",
Strings::Commify(amount),
is_aa ? "AA " : ""
).c_str()
);
}