Allow AsInt from Float EffectParameter, and AsFloat from Int EffectParameter.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-05-03 21:08:27 +02:00
parent f65b2f74bd
commit 119e71e86a
2 changed files with 8 additions and 0 deletions

View File

@@ -34,6 +34,9 @@ namespace CreatureLib::Library {
}
int64_t AsInt() const {
if (_type != EffectParameterType::Int) {
if (_type == EffectParameterType::Float) {
return static_cast<int64_t>(std::get<float>(_value));
}
std::stringstream ss;
ss << "Cast effect parameter to int, but was " << EffectParameterTypeHelper::ToString(_type);
throw CreatureException(ss.str());
@@ -42,6 +45,9 @@ namespace CreatureLib::Library {
}
float AsFloat() const {
if (_type != EffectParameterType::Float) {
if (_type == EffectParameterType::Int) {
return static_cast<float>(std::get<int64_t>(_value));
}
std::stringstream ss;
ss << "Cast effect parameter to float, but was " << EffectParameterTypeHelper::ToString(_type);
throw CreatureException(ss.str());