From c24972af6162d7547a4c80eff6a08da53fbdbf0b Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 20 Sep 2021 01:11:34 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Allow=20adding=20or=20s?= =?UTF-8?q?ubtracting=20'Damage'=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/damage.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Source/damage.hpp b/Source/damage.hpp index 705584fb8..4006bdc89 100644 --- a/Source/damage.hpp +++ b/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;