Browse Source

🏷️ Allow adding or subtracting 'Damage' instances

julealgon/Enhancements/DamageStruct
Juliano Leal Goncalves 5 years ago
parent
commit
c24972af61
  1. 26
      Source/damage.hpp

26
Source/damage.hpp

@ -43,6 +43,20 @@ struct Damage {
return !(*this == other);
}
constexpr Damage operator+=(Damage damage)
{
minValue += damage.minValue;
maxValue += damage.maxValue;
return *this;
}
constexpr Damage operator-=(Damage damage)
{
minValue -= damage.minValue;
maxValue -= damage.maxValue;
return *this;
}
constexpr Damage operator/=(const int factor)
{
minValue /= factor;
@ -50,6 +64,18 @@ struct Damage {
return *this;
}
constexpr friend Damage operator+(Damage damage, Damage anotherDamage)
{
damage += anotherDamage;
return damage;
}
constexpr friend Damage operator-(Damage damage, Damage anotherDamage)
{
damage -= anotherDamage;
return damage;
}
constexpr friend Damage operator/(Damage damage, const int factor)
{
damage /= factor;

Loading…
Cancel
Save