eqemu-server/zone/gm_commands/set_adventure_points.cpp
Alex King 2a6cf8c8e7
[Strings] Add more number formatters (#2873)
* [Strings] Add more number formatters

# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* [Strings] Add more number formatters

- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* Rebase cleanup

* Changes/benchmarks/tests

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-03-04 17:01:19 -06:00

77 lines
1.7 KiB
C++
Executable File

#include "../client.h"
#include "../../common/data_verification.h"
void command_set_adventure_points(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (
!arguments ||
!sep->IsNumber(1) ||
!sep->IsNumber(2)
) {
c->Message(Chat::White, "Usage: #setadventurepoints [Theme] [Points]");
c->Message(Chat::White, "Valid themes are as follows.");
auto theme_map = EQ::constants::GetLDoNThemeMap();
for (const auto& theme : theme_map) {
c->Message(
Chat::White,
fmt::format(
"Theme {} | {}",
theme.first,
theme.second
).c_str()
);
}
c->Message(Chat::White, "Note: Theme 0 splits the points evenly across all Themes.");
return;
}
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
auto theme_id = Strings::ToUnsignedInt(sep->arg[1]);
if (!EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) {
c->Message(Chat::White, "Valid themes are as follows.");
auto theme_map = EQ::constants::GetLDoNThemeMap();
for (const auto& theme : theme_map) {
c->Message(
Chat::White,
fmt::format(
"Theme {} | {}",
theme.first,
theme.second
).c_str()
);
}
c->Message(Chat::White, "Note: Theme 0 splits the points evenly across all Themes.");
return;
}
auto points = Strings::ToInt(sep->arg[2]);
c->Message(
Chat::White,
fmt::format(
"{} for {}.",
(
theme_id == LDoNThemes::Unused ?
fmt::format(
"Splitting {} Points Evenly",
points
) :
fmt::format(
"Adding {} {} Points",
points,
EQ::constants::GetLDoNThemeName(theme_id)
)
),
c->GetTargetDescription(target)
).c_str()
);
target->UpdateLDoNPoints(theme_id, points);
}