2019-11-04 16:58:26 +00:00
|
|
|
#ifndef CREATURELIB_TYPELIBRARY_HPP
|
|
|
|
#define CREATURELIB_TYPELIBRARY_HPP
|
|
|
|
|
2020-03-22 18:21:40 +00:00
|
|
|
#include <Arbutils/Collections/Dictionary.hpp>
|
|
|
|
#include <Arbutils/Collections/List.hpp>
|
2020-02-29 14:41:43 +00:00
|
|
|
#include <Arbutils/ConstString.hpp>
|
2019-11-04 16:58:26 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
2020-02-29 14:41:43 +00:00
|
|
|
using ConstString = Arbutils::CaseInsensitiveConstString;
|
2020-03-22 18:21:40 +00:00
|
|
|
using namespace Arbutils::Collections;
|
2019-11-04 16:58:26 +00:00
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
namespace CreatureLib::Library {
|
2019-11-04 16:58:26 +00:00
|
|
|
class TypeLibrary {
|
2020-03-22 18:21:40 +00:00
|
|
|
Dictionary<uint32_t, uint8_t> _types;
|
|
|
|
List<List<float>> _effectiveness;
|
2019-11-28 11:55:22 +00:00
|
|
|
|
2019-11-04 16:58:26 +00:00
|
|
|
public:
|
2020-03-22 18:21:40 +00:00
|
|
|
TypeLibrary(size_t initialCapacity = 20) : _types(Dictionary<uint32_t, uint8_t>(initialCapacity)) {}
|
2019-12-31 09:48:52 +00:00
|
|
|
|
2020-02-29 14:41:43 +00:00
|
|
|
uint8_t GetTypeId(const ConstString& s) const;
|
2020-02-29 14:54:02 +00:00
|
|
|
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;
|
2020-03-22 18:21:40 +00:00
|
|
|
[[nodiscard]] float GetEffectiveness(uint8_t attacking, const List<uint8_t>& defensive) const;
|
2019-11-04 16:58:26 +00:00
|
|
|
|
2020-02-29 14:41:43 +00:00
|
|
|
uint8_t RegisterType(const ConstString& 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);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-28 11:55:22 +00:00
|
|
|
#endif // CREATURELIB_TYPELIBRARY_HPP
|