mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 10:00:44 +08:00
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#pragma once
|
||
|
||
#include "AbstractConfigerWithTempl.h"
|
||
|
||
#include <unordered_map>
|
||
#include <unordered_set>
|
||
#include <vector>
|
||
|
||
namespace asst
|
||
{
|
||
class ItemConfiger final : public SingletonHolder<ItemConfiger>, public AbstractConfigerWithTempl
|
||
{
|
||
public:
|
||
virtual ~ItemConfiger() override = default;
|
||
|
||
const std::string& get_item_name(const std::string& id) const noexcept
|
||
{
|
||
if (id.empty()) {
|
||
static const std::string unknown = "Unknown";
|
||
return unknown;
|
||
}
|
||
if (auto iter = m_item_name.find(id); iter != m_item_name.cend()) {
|
||
return iter->second;
|
||
}
|
||
else {
|
||
static const std::string empty;
|
||
return empty;
|
||
}
|
||
}
|
||
const auto& get_all_item_id() const noexcept { return m_all_item_id; }
|
||
virtual const std::unordered_set<std::string>& get_templ_required() const noexcept override
|
||
{
|
||
return get_all_item_id();
|
||
}
|
||
const auto& get_ordered_material_item_id() const noexcept { return m_ordered_material_item_id; }
|
||
|
||
protected:
|
||
virtual bool parse(const json::value& json) override;
|
||
|
||
// key:材料编号Id,value:材料名(zh,utf8)
|
||
std::unordered_map<std::string, std::string> m_item_name;
|
||
std::unordered_set<std::string> m_all_item_id;
|
||
std::vector<std::string> m_ordered_material_item_id;
|
||
};
|
||
|
||
inline static auto& ItemData = ItemConfiger::get_instance();
|
||
}
|