25 lines
738 B
C++
25 lines
738 B
C++
#include "TypeLibrary.hpp"
|
|
|
|
using namespace CreatureLib::Library;
|
|
|
|
uint8_t TypeLibrary::RegisterType(const ArbUt::StringView& key) {
|
|
_types.Insert(key, _types.Count());
|
|
_effectiveness.Resize(_types.Count());
|
|
for (auto& eff : _effectiveness) {
|
|
eff.Resize(_types.Count(), 1);
|
|
}
|
|
return _types.Count() - 1;
|
|
}
|
|
|
|
void TypeLibrary::SetEffectiveness(uint8_t attacking, uint8_t defensive, float effectiveness) {
|
|
_effectiveness[attacking][defensive] = effectiveness;
|
|
}
|
|
const ArbUt::StringView& TypeLibrary::GetTypeName(uint8_t type) const {
|
|
for (auto& kv : _types) {
|
|
if (kv.second == type) {
|
|
return kv.first;
|
|
}
|
|
}
|
|
THROW("Name requested for unknown type: " << (uint32_t)type);
|
|
}
|