From 7f23c93ce5df5c8523ff1d50e10d370970e89257 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Fri, 24 Dec 2021 13:46:17 -0500 Subject: [PATCH] [Commands] Cleanup #setadventurepoints Command. (#1901) - Cleanup message and logic. --- zone/command.cpp | 2 +- zone/gm_commands/set_adventure_points.cpp | 82 ++++++++++++++++++++--- 2 files changed, 72 insertions(+), 12 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 166f2cc81..be3547754 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -324,7 +324,7 @@ int command_init(void) command_add("serverrules", "- Read this server's rules", AccountStatus::Player, command_serverrules) || command_add("setaapts", "[AA|Group|Raid] [AA Amount] - Set your or your player target's Available AA Points by Type", AccountStatus::GMAdmin, command_setaapts) || command_add("setaaxp", "[AA|Group|Raid] [AA Experience] - Set your or your player target's AA Experience by Type", AccountStatus::GMAdmin, command_setaaxp) || - command_add("setadventurepoints", "- Set your or your player target's available adventure points", AccountStatus::GMLeadAdmin, command_set_adventure_points) || + command_add("setadventurepoints", "[Theme] [Points] - Set your or your player target's available Adventure Points by Theme", AccountStatus::GMLeadAdmin, command_set_adventure_points) || command_add("setaltcurrency", "[Currency ID] [Amount] - Set your or your target's available Alternate Currency by Currency ID", AccountStatus::GMAdmin, command_setaltcurrency) || command_add("setanim", "[Animation ID (IDs are 0 to 4)] - Set target's appearance to Animation ID", AccountStatus::GMMgmt, command_setanim) || command_add("setcrystals", "[value] - Set your or your player target's available radiant or ebon crystals", AccountStatus::GMAdmin, command_setcrystals) || diff --git a/zone/gm_commands/set_adventure_points.cpp b/zone/gm_commands/set_adventure_points.cpp index a9b1f47e3..fff6eec9a 100755 --- a/zone/gm_commands/set_adventure_points.cpp +++ b/zone/gm_commands/set_adventure_points.cpp @@ -1,24 +1,84 @@ #include "../client.h" +#include "../../common/data_verification.h" void command_set_adventure_points(Client *c, const Seperator *sep) { - Client *t = c; + 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()) { - t = c->GetTarget()->CastToClient(); + target = c->GetTarget()->CastToClient(); } - if (!sep->arg[1][0]) { - c->Message(Chat::White, "Usage: #setadventurepoints [theme] [points]"); + auto theme_id = std::stoul(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; } - if (!sep->IsNumber(1) || !sep->IsNumber(2)) { - c->Message(Chat::White, "Usage: #setadventurepoints [theme] [points]"); - return; - } + auto points = std::stoi(sep->arg[2]); - c->Message(Chat::White, "Updating adventure points for %s", t->GetName()); - t->UpdateLDoNPoints(atoi(sep->arg[1]), atoi(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 == target ? + "Yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ) + ).c_str() + ); + + target->UpdateLDoNPoints(theme_id, points); } -