Expose damage output composition to UI

This commit is contained in:
DarkPhoenix
2018-12-11 19:13:31 +03:00
parent c991562662
commit 5fdae11bb1
4 changed files with 44 additions and 34 deletions

View File

@@ -26,7 +26,7 @@ class DmgTypes:
self.thermal = thermal
self.kinetic = kinetic
self.explosive = explosive
self.total = em + thermal + kinetic + explosive
self._calcTotal()
# Iterator is needed to support tuple-style unpacking
def __iter__(self):
@@ -51,11 +51,20 @@ class DmgTypes:
self.em, self.thermal, self.kinetic,
self.explosive, self.total))
def __hash__(self):
return hash((
DmgTypes.__qualname__,
self.em,
self.thermal,
self.kinetic,
self.explosive,
self.total))
def _calcTotal(self):
self.total = self.em + self.thermal + self.kinetic + self.explosive
def __add__(self, other):
return type(self)(
em=self.em + other.em,
thermal=self.thermal + other.thermal,
kinetic=self.kinetic + other.kinetic,
explosive=self.explosive + other.explosive)
def __iadd__(self, other):
self.em += other.em
self.thermal += other.thermal
self.kinetic += other.kinetic
self.explosive += other.explosive
self._calcTotal()
return self