refactor(Scripts/Commands): Update cs_quest to the new model (#9267)

This commit is contained in:
Skjalf 2021-11-24 01:21:16 -03:00 committed by GitHub
parent 91552e240e
commit 2187470df7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 716 additions and 204 deletions

View file

@ -116,3 +116,28 @@ ChatCommandResult Acore::Impl::ChatCommands::ArgInfo<SpellInfo const*>::TryConsu
return std::nullopt;
}
struct QuestVisitor
{
using value_type = Quest const*;
value_type operator()(Hyperlink<quest> quest_template) const { return quest_template->Quest; };
value_type operator()(uint32 questId) const { return sObjectMgr->GetQuestTemplate(questId); };
};
ChatCommandResult Acore::Impl::ChatCommands::ArgInfo<Quest const*>::TryConsume(Quest const*& data, ChatHandler const* handler, std::string_view args)
{
Variant<Hyperlink<quest>, uint32> val;
ChatCommandResult result = ArgInfo<decltype(val)>::TryConsume(val, handler, args);
if (!result || (data = val.visit(QuestVisitor())))
{
return result;
}
if (uint32* id = std::get_if<uint32>(&val))
{
return FormatAcoreString(handler, LANG_CMDPARSER_QUEST_NO_EXIST, *id);
}
return std::nullopt;
}