refactor(Scripts/Commands): Update cs_quest to the new model (#9267)
This commit is contained in:
parent
91552e240e
commit
2187470df7
12 changed files with 716 additions and 204 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue