You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
981 B

#pragma once
#include "engine/random.hpp"
namespace devilution {
struct Damage {
int minValue;
int maxValue;
Damage() = default;
constexpr Damage(int fixedValue)
: Damage(fixedValue, fixedValue)
{
}
constexpr Damage(int minValue, int maxValue)
: minValue(minValue)
, maxValue(maxValue)
{
}
int GetValue() const
{
return minValue == maxValue
? minValue
: minValue + GenerateRnd(maxValue - minValue + 1);
}
constexpr bool operator==(const Damage &other) const
{
return minValue == other.minValue && maxValue == other.maxValue;
}
constexpr bool operator!=(const Damage &other) const
{
return !(*this == other);
}
constexpr Damage operator/=(const int factor)
{
minValue /= factor;
maxValue /= factor;
return *this;
}
constexpr friend Damage operator/(Damage damage, const int factor)
{
damage /= factor;
return damage;
}
};
} // namespace devilution