mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
* Initial commit checkpoint * More functions converted * Commify * More functions * Fin * Sort declarations * Split functions between files * Bots * Update strings.h * Split * Revert find replaces * Repository template * Money * Misc function * Update CMakeLists.txt * Saylink * Update strings.cpp * Swap Strings::Saylink for Saylink::Create since saylink is coupled to zone database * API casings
53 lines
1.3 KiB
C++
Executable File
53 lines
1.3 KiB
C++
Executable File
#include "../client.h"
|
|
|
|
void command_setcrystals(Client *c, const Seperator *sep)
|
|
{
|
|
int arguments = sep->argnum;
|
|
if (arguments <= 1 || !sep->IsNumber(2)) {
|
|
c->Message(Chat::White, "Usage: #setcrystals [Ebon|Radiant] [Crystal Amount]");
|
|
return;
|
|
}
|
|
|
|
Client *target = c;
|
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
|
target = c->GetTarget()->CastToClient();
|
|
}
|
|
|
|
std::string crystal_type = Strings::ToLower(sep->arg[1]);
|
|
uint32 crystal_amount = static_cast<uint32>(std::min(
|
|
std::stoull(sep->arg[2]),
|
|
(unsigned long long) 2000000000
|
|
));
|
|
bool is_ebon = crystal_type.find("ebon") != std::string::npos;
|
|
bool is_radiant = crystal_type.find("radiant") != std::string::npos;
|
|
if (!is_ebon && !is_radiant) {
|
|
c->Message(Chat::White, "Usage: #setcrystals [Ebon|Radiant] [Crystal Amount]");
|
|
return;
|
|
}
|
|
|
|
uint32 crystal_item_id = (
|
|
is_ebon ?
|
|
RuleI(Zone, EbonCrystalItemID) :
|
|
RuleI(Zone, RadiantCrystalItemID)
|
|
);
|
|
|
|
auto crystal_link = database.CreateItemLink(crystal_item_id);
|
|
if (is_radiant) {
|
|
target->SetRadiantCrystals(crystal_amount);
|
|
} else {
|
|
target->SetEbonCrystals(crystal_amount);
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} now {} {} {}.",
|
|
c->GetTargetDescription(target, TargetDescriptionType::UCYou),
|
|
c == target ? "have" : "has",
|
|
crystal_amount,
|
|
crystal_link
|
|
).c_str()
|
|
);
|
|
}
|
|
|