More work on exceptions.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user