CreatureLib/src/Library/TypeLibrary.hpp

30 lines
1.1 KiB
C++
Raw Normal View History

2019-11-04 16:58:26 +00:00
#ifndef CREATURELIB_TYPELIBRARY_HPP
#define CREATURELIB_TYPELIBRARY_HPP
#include <Arbutils/Collections/Dictionary.hpp>
#include <Arbutils/Collections/List.hpp>
2020-02-29 14:41:43 +00:00
#include <Arbutils/ConstString.hpp>
#include <unordered_set>
2019-11-04 16:58:26 +00:00
#include <vector>
namespace CreatureLib::Library {
2019-11-04 16:58:26 +00:00
class TypeLibrary {
2020-05-26 16:31:06 +00:00
ArbUt::Dictionary<uint32_t, uint8_t> _types;
ArbUt::List<ArbUt::List<float>> _effectiveness;
2019-11-04 16:58:26 +00:00
public:
2020-05-26 16:31:06 +00:00
TypeLibrary(size_t initialCapacity = 20) : _types(ArbUt::Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
2020-05-26 16:31:06 +00:00
uint8_t GetTypeId(const ArbUt::CaseInsensitiveConstString& s) const;
uint8_t GetTypeId(uint32_t s) const;
2020-02-29 15:06:36 +00:00
[[nodiscard]] float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const;
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const std::unordered_set<uint8_t>& defensive) const;
2019-11-04 16:58:26 +00:00
2020-05-26 16:31:06 +00:00
uint8_t RegisterType(const ArbUt::CaseInsensitiveConstString& typeName);
2020-02-29 15:06:36 +00:00
uint8_t RegisterType(uint32_t typeHash);
2019-11-04 16:58:26 +00:00
void SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness);
};
}
#endif // CREATURELIB_TYPELIBRARY_HPP