Files
MaaAssistantArknights/src/MeoAssistant/ItemConfiger.h
2021-12-15 00:29:17 +08:00

65 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "AbstractConfiger.h"
#include <unordered_map>
namespace asst
{
class ItemConfiger : public AbstractConfiger
{
public:
virtual ~ItemConfiger() = default;
const std::string& get_item_name(const std::string& id) const noexcept
{
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 std::unordered_map<std::string, int>& get_drop_count() const noexcept
{
return m_drop_count;
}
std::unordered_map<std::string, int>& get_drop_count() noexcept
{
return m_drop_count;
}
int get_drop_count(const std::string& id) const noexcept
{
if (auto iter = m_drop_count.find(id);
iter != m_drop_count.cend()) {
return iter->second;
}
else {
return 0;
}
}
void set_drop_count(std::string id, int count)
{
m_drop_count.emplace(std::move(id), count);
}
void increase_drop_count(std::string id, int count)
{
m_drop_count[std::move(id)] += count;
}
void clear_drop_count() noexcept
{
m_drop_count.clear();
}
protected:
virtual bool parse(const json::value& json) override;
// key材料编号Idvalue材料名zhutf8
std::unordered_map<std::string, std::string> m_item_name;
// key材料编号Idvalue数量
std::unordered_map<std::string, int> m_drop_count;
};
}