From 2c8e306dc2246a29d2c3b276e0c83c1becbab585 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 11 Nov 2024 14:34:38 +0100 Subject: [PATCH] Add HP field to target profile --- eos/db/migrations/upgrade49.py | 15 +++++++++++++++ eos/db/saveddata/targetProfile.py | 4 +++- eos/saveddata/module.py | 4 ++-- eos/saveddata/targetProfile.py | 15 ++++++++++++++- 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 eos/db/migrations/upgrade49.py diff --git a/eos/db/migrations/upgrade49.py b/eos/db/migrations/upgrade49.py new file mode 100644 index 000000000..60a1e4221 --- /dev/null +++ b/eos/db/migrations/upgrade49.py @@ -0,0 +1,15 @@ +""" +Migration 49 + +- added hp column to targetResists table +""" + + +import sqlalchemy + + +def upgrade(saveddata_engine): + try: + saveddata_engine.execute("SELECT hp FROM targetResists LIMIT 1;") + except sqlalchemy.exc.DatabaseError: + saveddata_engine.execute("ALTER TABLE targetResists ADD COLUMN hp FLOAT;") diff --git a/eos/db/saveddata/targetProfile.py b/eos/db/saveddata/targetProfile.py index be6c72625..75dfa36ae 100644 --- a/eos/db/saveddata/targetProfile.py +++ b/eos/db/saveddata/targetProfile.py @@ -37,6 +37,7 @@ targetProfiles_table = Table( Column('maxVelocity', Float, nullable=True), Column('signatureRadius', Float, nullable=True), Column('radius', Float, nullable=True), + Column('hp', Float, nullable=True), Column('ownerID', ForeignKey('users.ID'), nullable=True), Column('created', DateTime, nullable=True, default=datetime.datetime.now), Column('modified', DateTime, nullable=True, onupdate=datetime.datetime.now)) @@ -48,4 +49,5 @@ mapper( 'rawName': targetProfiles_table.c.name, '_maxVelocity': targetProfiles_table.c.maxVelocity, '_signatureRadius': targetProfiles_table.c.signatureRadius, - '_radius': targetProfiles_table.c.radius}) + '_radius': targetProfiles_table.c.radius, + '_hp': targetProfiles_table.c.hp}) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index 429d75535..250993960 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -472,9 +472,9 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut, M return {0: DmgTypes(0, 0, 0, 0)} if self.__baseVolley is None: self.__baseVolley = {} - if self.charge and 'dotMissileLaunching' in self.charge.item.effects: + if self.charge and 'dotMissileLaunching' in self.charge.effects: dmgDelay = 1 - subcycles = math.floor(self.getModifiedChargeAttr("dotDuration", 0)) + subcycles = math.floor(self.getModifiedChargeAttr("dotDuration", 0) / 1000) breacher_info = BreacherInfo( absolute=self.getModifiedChargeAttr("dotMaxDamagePerTick", 0), relative=self.getModifiedChargeAttr("dotMaxHPPercentagePerTick", 0)) diff --git a/eos/saveddata/targetProfile.py b/eos/saveddata/targetProfile.py index c18dd1e00..ac7fce3f2 100644 --- a/eos/saveddata/targetProfile.py +++ b/eos/saveddata/targetProfile.py @@ -254,7 +254,7 @@ class TargetProfile: def init(self): self.builtin = False - def update(self, emAmount=0, thermalAmount=0, kineticAmount=0, explosiveAmount=0, maxVelocity=None, signatureRadius=None, radius=None): + def update(self, emAmount=0, thermalAmount=0, kineticAmount=0, explosiveAmount=0, maxVelocity=None, signatureRadius=None, radius=None, hp=None): self.emAmount = emAmount self.thermalAmount = thermalAmount self.kineticAmount = kineticAmount @@ -262,6 +262,7 @@ class TargetProfile: self._maxVelocity = maxVelocity self._signatureRadius = signatureRadius self._radius = radius + self._hp = hp @classmethod def getBuiltinList(cls): @@ -331,6 +332,18 @@ class TargetProfile: def radius(self, val): self._radius = val + @property + def hp(self): + if self._hp is None or self._hp == -1: + return math.inf + return self._hp + + @hp.setter + def hp(self, val): + if val is not None and math.isinf(val): + val = None + self._hp = val + @classmethod def importPatterns(cls, text): lines = re.split('[\n\r]+', text)