[Commands] Cleanup #scribespell and #scribespells Commands. (#2534)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab
2022-11-14 14:05:34 -05:00
committed by GitHub
parent 9c967c24b8
commit 8d184fc6c0
3 changed files with 96 additions and 65 deletions
+63 -36
View File
@@ -2,65 +2,92 @@
void command_scribespell(Client *c, const Seperator *sep)
{
uint16 spell_id = 0;
uint16 book_slot = -1;
Client *t = c;
auto arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #scribespell [Spell ID]");
return;
}
auto t = c;
if (c->GetTarget() && c->GetTarget()->IsClient() && c->GetGM()) {
t = c->GetTarget()->CastToClient();
}
if (!sep->arg[1][0]) {
c->Message(Chat::White, "FORMAT: #scribespell <spellid>");
return;
}
spell_id = atoi(sep->arg[1]);
const auto spell_id = std::stoul(sep->arg[1]);
if (IsValidSpell(spell_id)) {
t->Message(Chat::White, "Scribing spell: %s (%i) to spellbook.", spells[spell_id].name, spell_id);
t->Message(
Chat::White,
fmt::format(
"Scribing {} ({}) to spellbook.",
spells[spell_id].name,
spell_id
).c_str()
);
if (t != c) {
c->Message(Chat::White, "Scribing spell: %s (%i) for %s.", spells[spell_id].name, spell_id, t->GetName());
c->Message(
Chat::White,
fmt::format(
"Scribing {} ({}) for {}.",
spells[spell_id].name,
spell_id,
t->GetName()
).c_str()
);
}
LogInfo("Scribe spell: [{}] ([{}]) request for [{}] from [{}]",
spells[spell_id].name,
spell_id,
t->GetName(),
c->GetName());
LogInfo(
"Scribe spell: [{}] ([{}]) request for [{}] from [{}]",
spells[spell_id].name,
spell_id,
t->GetName(),
c->GetName()
);
if (spells[spell_id].classes[WARRIOR] != 0 && spells[spell_id].skill != 52 &&
spells[spell_id].classes[t->GetPP().class_ - 1] > 0 && !IsDiscipline(spell_id)) {
book_slot = t->GetNextAvailableSpellBookSlot();
if (
spells[spell_id].classes[WARRIOR] != 0 &&
spells[spell_id].skill != EQ::skills::SkillTigerClaw &&
spells[spell_id].classes[t->GetPP().class_ - 1] > 0 &&
!IsDiscipline(spell_id)
) {
auto book_slot = t->GetNextAvailableSpellBookSlot();
if (book_slot >= 0 && t->FindSpellBookSlotBySpellID(spell_id) < 0) {
t->ScribeSpell(spell_id, book_slot);
}
else {
} else {
t->Message(
Chat::Red,
"Unable to scribe spell: %s (%i) to your spellbook.",
spells[spell_id].name,
spell_id
Chat::White,
fmt::format(
"Unable to scribe {} ({}) to your spellbook.",
spells[spell_id].name,
spell_id
).c_str()
);
if (t != c) {
c->Message(
Chat::Red,
"Unable to scribe spell: %s (%i) for %s.",
spells[spell_id].name,
spell_id,
t->GetName());
Chat::White,
fmt::format(
"Unable to scribe {} ({}) for {}.",
spells[spell_id].name,
spell_id,
t->GetName()
).c_str()
);
}
}
} else {
c->Message(Chat::White, "Your target cannot scribe this spell.");
}
else {
c->Message(Chat::Red, "Your target can not scribe this spell.");
}
}
else {
c->Message(Chat::Red, "Spell ID: %i is an unknown spell and cannot be scribed.", spell_id);
} else {
c->Message(
Chat::White,
fmt::format(
"Spell ID {} is an unknown spell and cannot be scribed.",
spell_id
).c_str()
);
}
}