More work on exceptions.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-31 14:17:38 +02:00
parent 9c93ca6995
commit bd7ecb6b33
3 changed files with 18 additions and 4 deletions

View File

@@ -7,6 +7,7 @@
#include <numeric>
#include <unordered_set>
#include <vector>
#include "Exceptions/CreatureException.hpp"
namespace CreatureLib::Library {
class TypeLibrary {
@@ -19,7 +20,12 @@ namespace CreatureLib::Library {
inline uint8_t GetTypeId(const ArbUt::BasicStringView& key) const { return _types.Get(key); }
inline uint8_t GetTypeId(uint32_t s) const { return _types.Get(s); }
[[nodiscard]] inline float GetSingleEffectiveness(uint8_t attacking, uint8_t defensive) const {
return _effectiveness[attacking][defensive];
try {
return _effectiveness[attacking][defensive];
} catch (const std::exception& e) {
THROW_CREATURE("Unknown type indices were requested for effectiveness: "
<< (uint32_t)attacking << " and " << (uint32_t)defensive);
}
}
[[nodiscard]] inline float GetEffectiveness(uint8_t attacking,
const std::unordered_set<uint8_t>& defensive) const {