[Commands] Cleanup #viewcurrencies Command (#3441)

# Notes
- Utilize Dialogue Window table for cleanliness and readability.
This commit is contained in:
Alex King 2023-06-24 20:26:41 -04:00 committed by GitHub
parent 9154c90418
commit 050aba65b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,34 +2,44 @@
void command_viewcurrencies(Client *c, const Seperator *sep) void command_viewcurrencies(Client *c, const Seperator *sep)
{ {
Client *target = c; auto t = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) { if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient(); t = c->GetTarget()->CastToClient();
} }
auto platinum = ( const auto platinum = (
target->GetMoney(3, 0) + t->GetMoney(3, 0) +
target->GetMoney(3, 1) + t->GetMoney(3, 1) +
target->GetMoney(3, 2) + t->GetMoney(3, 2) +
target->GetMoney(3, 3) t->GetMoney(3, 3)
); );
auto gold = ( const auto gold = (
target->GetMoney(2, 0) + t->GetMoney(2, 0) +
target->GetMoney(2, 1) + t->GetMoney(2, 1) +
target->GetMoney(2, 2) t->GetMoney(2, 2)
); );
auto silver = ( const auto silver = (
target->GetMoney(1, 0) + t->GetMoney(1, 0) +
target->GetMoney(1, 1) + t->GetMoney(1, 1) +
target->GetMoney(1, 2) t->GetMoney(1, 2)
); );
auto copper = ( const auto copper = (
target->GetMoney(0, 0) + t->GetMoney(0, 0) +
target->GetMoney(0, 1) + t->GetMoney(0, 1) +
target->GetMoney(0, 2) t->GetMoney(0, 2)
);
std::string currency_table;
currency_table += DialogueWindow::TableRow(
fmt::format(
"{}{}",
DialogueWindow::TableCell("Currency"),
DialogueWindow::TableCell("Amount")
)
); );
if ( if (
@ -38,90 +48,82 @@ void command_viewcurrencies(Client *c, const Seperator *sep)
silver || silver ||
copper copper
) { ) {
c->Message( currency_table += DialogueWindow::TableRow(
Chat::White,
fmt::format( fmt::format(
"Money for {} | {}", "{}{}",
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell("Money"),
Strings::Money( DialogueWindow::TableCell(Strings::Money(platinum, gold, silver, copper))
platinum, )
gold,
silver,
copper
)
).c_str()
); );
} }
auto ebon_crystals = target->GetEbonCrystals(); const auto ebon_crystals = t->GetEbonCrystals();
if (ebon_crystals) { if (ebon_crystals) {
c->Message( currency_table += DialogueWindow::TableRow(
Chat::White,
fmt::format( fmt::format(
"{} for {} | {}", "{}{}",
database.CreateItemLink(RuleI(Zone, EbonCrystalItemID)), DialogueWindow::TableCell("Ebon Crystals"),
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell(Strings::Commify(ebon_crystals))
ebon_crystals )
).c_str()
); );
} }
auto radiant_crystals = target->GetRadiantCrystals(); const auto radiant_crystals = t->GetRadiantCrystals();
if (radiant_crystals) { if (radiant_crystals) {
c->Message( currency_table += DialogueWindow::TableRow(
Chat::White,
fmt::format( fmt::format(
"{} for {} | {}", "{}{}",
database.CreateItemLink(RuleI(Zone, RadiantCrystalItemID)), DialogueWindow::TableCell("Radiant Crystals"),
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell(Strings::Commify(radiant_crystals))
radiant_crystals )
).c_str()
); );
} }
for (const auto& ac : zone->AlternateCurrencies) { for (const auto& a : zone->AlternateCurrencies) {
auto currency_value = target->GetAlternateCurrencyValue(ac.id); const auto currency_value = t->GetAlternateCurrencyValue(a.id);
if (currency_value) { if (currency_value) {
c->Message( const auto* d = database.GetItem(a.item_id);
Chat::White, currency_table += DialogueWindow::TableRow(
fmt::format( fmt::format(
"{} for {} | {}", "{}{}",
database.CreateItemLink(ac.item_id), DialogueWindow::TableCell(d->Name),
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell(Strings::Commify(currency_value))
currency_value )
).c_str()
); );
} }
} }
for ( for (const auto& l : EQ::constants::GetLDoNThemeMap()) {
uint32 ldon_currency_id = LDoNThemes::GUK; const auto ldon_currency_value = t->GetLDoNPointsTheme(l.first);
ldon_currency_id <= LDoNThemes::TAK;
ldon_currency_id++
) {
auto ldon_currency_value = target->GetLDoNPointsTheme(ldon_currency_id);
if (ldon_currency_value) { if (ldon_currency_value) {
c->Message( currency_table += DialogueWindow::TableRow(
Chat::White,
fmt::format( fmt::format(
"{} for {} | {}", "{}{}",
EQ::constants::GetLDoNThemeName(ldon_currency_id), DialogueWindow::TableCell(l.second),
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell(Strings::Commify(ldon_currency_value))
ldon_currency_value )
).c_str()
); );
} }
} }
auto pvp_points = target->GetPVPPoints(); auto pvp_points = t->GetPVPPoints();
if (pvp_points) { if (pvp_points) {
c->Message( currency_table += DialogueWindow::TableRow(
Chat::White,
fmt::format( fmt::format(
"PVP Points for {} | {}", "{}{}",
c->GetTargetDescription(target, TargetDescriptionType::UCSelf), DialogueWindow::TableCell("PVP Points"),
pvp_points DialogueWindow::TableCell(Strings::Commify(pvp_points))
).c_str() )
); );
} }
currency_table = DialogueWindow::Table(currency_table);
c->SendPopupToClient(
fmt::format(
"Currency for {}",
c->GetTargetDescription(t, TargetDescriptionType::UCSelf)
).c_str(),
currency_table.c_str()
);
} }