25 lines
711 B
C++
25 lines
711 B
C++
#include "TypeLibrary.hpp"
|
|
|
|
using namespace CreatureLib::Library;
|
|
|
|
u8 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(u8 attacking, u8 defensive, float effectiveness) {
|
|
_effectiveness[attacking][defensive] = effectiveness;
|
|
}
|
|
const ArbUt::StringView& TypeLibrary::GetTypeName(u8 type) const {
|
|
for (auto& kv : _types) {
|
|
if (kv.second == type) {
|
|
return kv.first;
|
|
}
|
|
}
|
|
THROW("Name requested for unknown type: ", (u32)type);
|
|
}
|