diff --git a/common/repositories/command_subsettings_repository.h b/common/repositories/command_subsettings_repository.h index 963bcee91..aa99d164a 100644 --- a/common/repositories/command_subsettings_repository.h +++ b/common/repositories/command_subsettings_repository.h @@ -49,6 +49,7 @@ public: // these are the base definitions for command_subsettings and can be over-ridden by the database std::vector static_records = { {.parent_command = "find", .sub_command = "aa", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findaa"}, + {.parent_command = "find", .sub_command = "account", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findaccount"}, {.parent_command = "find", .sub_command = "body_type", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findbodytype"}, {.parent_command = "find", .sub_command = "bug_category", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findbugcategory"}, {.parent_command = "find", .sub_command = "character", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findcharacter"}, diff --git a/zone/gm_commands/find.cpp b/zone/gm_commands/find.cpp index 0bdbcbe70..6ee5815cb 100644 --- a/zone/gm_commands/find.cpp +++ b/zone/gm_commands/find.cpp @@ -1,5 +1,6 @@ #include "../client.h" #include "find/aa.cpp" +#include "find/account.cpp" #include "find/body_type.cpp" #include "find/bot.cpp" #include "find/bug_category.cpp" @@ -38,6 +39,7 @@ void command_find(Client *c, const Seperator *sep) std::vector commands = { Cmd{.cmd = "aa", .u = "aa [Search Criteria]", .fn = FindAA, .a = {"#findaa"}}, + Cmd{.cmd = "account", .u = "account [Search Criteria]", .fn = FindAccount, .a = {"#findaccount"}}, Cmd{.cmd = "body_type", .u = "body_type [Search Criteria]", .fn = FindBodyType, .a = {"#findbodytype"}}, Cmd{.cmd = "bug_category", .u = "bug_category [Search Criteria]", .fn = FindBugCategory, .a = {"#findbugcategory"}}, Cmd{.cmd = "character", .u = "character [Search Criteria]", .fn = FindCharacter, .a = {"#findcharacter"}}, @@ -72,7 +74,7 @@ void command_find(Client *c, const Seperator *sep) commands.emplace_back( Cmd{.cmd = "bot", .u = "bot [Search Criteria]", .fn = FindBot, .a = {"#findbot"}} ); - + std::sort(commands.begin(), commands.end(), [](const Cmd& a, const Cmd& b) { return a.cmd < b.cmd; }); diff --git a/zone/gm_commands/find/account.cpp b/zone/gm_commands/find/account.cpp new file mode 100644 index 000000000..1265c8431 --- /dev/null +++ b/zone/gm_commands/find/account.cpp @@ -0,0 +1,50 @@ +#include "../../client.h" +#include "../../common/repositories/account_repository.h" + +void FindAccount(Client *c, const Seperator *sep) +{ + const uint16 arguments = sep->argnum; + if (arguments < 2) { + c->Message(Chat::White, "Usage: #find account [Character Name]"); + c->Message(Chat::White, "Note: Used to print the account ID and name of the account a character belongs to."); + return; + } + + const std::string& character_name = sep->arg[2]; + + const auto& e = CharacterDataRepository::FindByName(database, character_name); + + if (!e.id) { + c->Message( + Chat::White, + fmt::format( + "Character '{}' does not exist.", + character_name + ).c_str() + ); + return; + } + + auto a = AccountRepository::FindOne(database, e.account_id); + + if (!a.id) { + c->Message( + Chat::White, + fmt::format( + "Character '{}' is not attached to an account.", + character_name + ).c_str() + ); + return; + } + + c->Message( + Chat::White, + fmt::format( + "Account {} ({}) owns the character {}.", + a.name, + a.id, + character_name + ).c_str() + ); +}