[Commands] Add #show aas Command (#3710)

# Notes
- Allows operators to view AAs a player has purchased from ingame and their ranks.
This commit is contained in:
Alex King 2023-11-26 00:27:02 -05:00 committed by GitHub
parent 3a49d851ca
commit 692a90f3f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 111 additions and 0 deletions

View File

@ -120,6 +120,7 @@ public:
{.parent_command = "set", .sub_command = "title_suffix", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "titlesuffix"},
{.parent_command = "set", .sub_command = "weather", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "weather"},
{.parent_command = "set", .sub_command = "zone", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "zclip|zcolor|zheader|zonelock|zsafecoords|zsky|zunderworld"},
{.parent_command = "show", .sub_command = "aas", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "showaas"},
{.parent_command = "show", .sub_command = "aa_points", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "showaapoints|showaapts"},
{.parent_command = "show", .sub_command = "aggro", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "aggro"},
{.parent_command = "show", .sub_command = "buffs", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "showbuffs"},

View File

@ -2207,3 +2207,97 @@ bool Client::HasAlreadyPurchasedRank(AA::Rank* rank) {
return false;
}
void Client::ListPurchasedAAs(Client *to, std::string search_criteria)
{
if (!to) {
return;
}
std::map<std::string, uint8> client_aa_ranks;
for (auto &aa : zone->aa_abilities) {
AA::Ability *ability = aa.second.get();
AA::Rank *rank = ability->first;
while (rank) {
if (!CanUseAlternateAdvancementRank(rank)) {
break;
}
if (HasAlreadyPurchasedRank(rank)) {
const std::string aa_name = zone->GetAAName(rank->id);
if (
search_criteria.empty() ||
Strings::Contains(
Strings::ToLower(aa_name),
Strings::ToLower(search_criteria)
)
) {
if (client_aa_ranks.find(aa_name) == client_aa_ranks.end()) {
client_aa_ranks[aa_name] = 1;
} else {
client_aa_ranks[aa_name]++;
}
}
}
rank = rank->next;
}
}
if (client_aa_ranks.empty()) {
to->Message(
Chat::White,
fmt::format(
"{} {} no purchased AAs{}.",
to->GetTargetDescription(this, TargetDescriptionType::UCYou),
this == to ? "have" : "has",
(
!search_criteria.empty() ?
fmt::format(
" matching '{}'",
search_criteria
) :
""
)
).c_str()
);
return;
}
int aa_number = 1;
for (const auto &aa : client_aa_ranks) {
to->Message(
Chat::White,
fmt::format(
"{}. {} (Rank {})",
aa_number,
aa.first,
aa.second
).c_str()
);
aa_number++;
}
to->Message(
Chat::White,
fmt::format(
"{} {} {} purchased AA{}{}.",
to->GetTargetDescription(this, TargetDescriptionType::UCYou),
this == to ? "have" : "has",
client_aa_ranks.size(),
client_aa_ranks.size() > 1 ? "s" : "",
(
!search_criteria.empty() ?
fmt::format(
" matching '{}'",
search_criteria
) :
""
)
).c_str()
);
}

View File

@ -908,6 +908,7 @@ public:
void AutoGrantAAPoints();
void GrantAllAAPoints(uint8 unlock_level = 0);
bool HasAlreadyPurchasedRank(AA::Rank* rank);
void ListPurchasedAAs(Client *to, std::string search_criteria = std::string());
bool SendGMCommand(std::string message, bool ignore_status = false);

View File

@ -1,4 +1,5 @@
#include "../client.h"
#include "show/aas.cpp"
#include "show/aa_points.cpp"
#include "show/aggro.cpp"
#include "show/buffs.cpp"
@ -56,6 +57,7 @@ void command_show(Client *c, const Seperator *sep)
};
std::vector<Cmd> commands = {
Cmd{.cmd = "aas", .u = "aas", .fn = ShowAAs, .a = {"#showaas"}},
Cmd{.cmd = "aa_points", .u = "aa_points", .fn = ShowAAPoints, .a = {"#showaapoints", "#showaapts"}},
Cmd{.cmd = "aggro", .u = "aggro [Distance] [-v] (-v is verbose Faction Information)", .fn = ShowAggro, .a = {"#aggro"}},
Cmd{.cmd = "buffs", .u = "buffs", .fn = ShowBuffs, .a = {"#showbuffs"}},

View File

@ -0,0 +1,13 @@
#include "../../client.h"
void ShowAAs(Client *c, const Seperator *sep)
{
Client *t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const std::string& search_criteria = sep->argnum >= 2 ? sep->argplus[2] : std::string();
t->ListPurchasedAAs(c, search_criteria);
}