From 88125634d23de0ea08b77e0ea53a994aa5a83e5f Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sat, 28 Jan 2017 21:47:58 -0800 Subject: [PATCH 1/9] Add extra info for misc column for fueled boosters --- eos/gamedata.py | 6 +++- gui/builtinViewColumns/misc.py | 53 ++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index e4a4afa1c..a23ed0d8a 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -243,9 +243,13 @@ class Item(EqBase): return self.__attributes - def getAttribute(self, key): + def getAttribute(self, key, default=None): if key in self.attributes: return self.attributes[key].value + elif default: + return default + else: + return None def isType(self, type): for effect in self.effects.itervalues(): diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 080614a3b..4ffa64405 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -450,30 +450,71 @@ class Miscellanea(ViewColumn): return text, item.name else: return "", None - elif itemGroup in ("Ancillary Armor Repairer", "Ancillary Shield Booster"): + elif itemGroup in ( + "Ancillary Armor Repairer", + "Ancillary Shield Booster", + "Capacitor Booster", + "Ancillary Remote Armor Repairer", + "Ancillary Remote Shield Booster", + ): + if "Armor" in itemGroup or "Shield" in itemGroup: + boosted_attribute = "HP" + elif "Capacitor" in itemGroup: + boosted_attribute = "Cap" + else: + boosted_attribute = None + hp = stuff.hpBeforeReload cycles = stuff.numShots cycleTime = stuff.rawCycleTime + + if boosted_attribute == "Cap": + if hp is None: + local_booster = stuff.charge.getAttribute("capacitorBonus",0) + hp = max(local_booster, 0) * cycles + reload_time = 10 + elif boosted_attribute == "HP": + if hp is None: + armor_repairer = item.getAttribute("armorDamageAmount", None) + shield_booster = item.getAttribute("shieldBonus", None) + hp = max(armor_repairer, shield_booster, 0) + reload_time = item.getAttribute("reloadTime", 0) / 1000 + else: + reload_time = 0 + if not hp or not cycleTime or not cycles: return "", None + fit = Fit.getInstance().getFit(self.mainFrame.getActiveFit()) ehpTotal = fit.ehp hpTotal = fit.hp useEhp = self.mainFrame.statsPane.nameViewMap["resistancesViewFull"].showEffective - tooltip = "HP restored over duration using charges" - if useEhp: - if itemGroup == "Ancillary Armor Repairer": + tooltip = "{0} restored over duration using charges (plus reload)".format(boosted_attribute) + + if useEhp and boosted_attribute == "HP" and "Remote" not in itemGroup: + if "Ancillary Armor Repairer" in itemGroup: hpRatio = ehpTotal["armor"] / hpTotal["armor"] else: hpRatio = ehpTotal["shield"] / hpTotal["shield"] tooltip = "E{0}".format(tooltip) else: hpRatio = 1 - if itemGroup == "Ancillary Armor Repairer": + + if ("Ancillary" and "Armor") in itemGroup: hpRatio *= 3 + + ehp = hp * hpRatio + duration = cycles * cycleTime / 1000 - text = "{0} / {1}s".format(formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3)) + for number_of_cycles in {5, 10, 25}: + tooltip = "{0}\n{1} charges lasts {2} seconds ({3} cycles)".format( + tooltip, + formatAmount(number_of_cycles*cycles, 3, 0, 3), + formatAmount((duration+reload_time)*number_of_cycles, 3, 0, 3), + formatAmount(number_of_cycles, 3, 0, 3) + ) + text = "{0} / {1}s (+{2}s)".format(formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3), formatAmount(reload_time, 3, 0, 3)) return text, tooltip elif itemGroup == "Armor Resistance Shift Hardener": From 34c69cf10f883775579b5ced583ea9331d806498 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sat, 28 Jan 2017 21:56:03 -0800 Subject: [PATCH 2/9] Some pep8 stuff --- gui/builtinViewColumns/misc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 4ffa64405..5a27bab55 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -470,7 +470,7 @@ class Miscellanea(ViewColumn): if boosted_attribute == "Cap": if hp is None: - local_booster = stuff.charge.getAttribute("capacitorBonus",0) + local_booster = stuff.charge.getAttribute("capacitorBonus", 0) hp = max(local_booster, 0) * cycles reload_time = 10 elif boosted_attribute == "HP": @@ -503,7 +503,6 @@ class Miscellanea(ViewColumn): if ("Ancillary" and "Armor") in itemGroup: hpRatio *= 3 - ehp = hp * hpRatio duration = cycles * cycleTime / 1000 @@ -514,7 +513,11 @@ class Miscellanea(ViewColumn): formatAmount((duration+reload_time)*number_of_cycles, 3, 0, 3), formatAmount(number_of_cycles, 3, 0, 3) ) - text = "{0} / {1}s (+{2}s)".format(formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3), formatAmount(reload_time, 3, 0, 3)) + text = "{0} / {1}s (+{2}s)".format( + formatAmount(ehp, 3, 0, 9), + formatAmount(duration, 3, 0, 3), + formatAmount(reload_time, 3, 0, 3) + ) return text, tooltip elif itemGroup == "Armor Resistance Shift Hardener": From 1a0ac7bb352475b840e6194d70fcf06452cb6edd Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:16:15 -0800 Subject: [PATCH 3/9] Allow default values to be passed in for modified attributes --- eos/gamedata.py | 4 +--- eos/modifiedAttributeDict.py | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index a23ed0d8a..10317dab2 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -246,10 +246,8 @@ class Item(EqBase): def getAttribute(self, key, default=None): if key in self.attributes: return self.attributes[key].value - elif default: - return default else: - return None + return default def isType(self, type): for effect in self.effects.itervalues(): diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index d060eb425..e558dc64d 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -25,19 +25,19 @@ cappingAttrKeyCache = {} class ItemAttrShortcut(object): - def getModifiedItemAttr(self, key): + def getModifiedItemAttr(self, key, default=None): if key in self.itemModifiedAttributes: return self.itemModifiedAttributes[key] else: - return None + return default class ChargeAttrShortcut(object): - def getModifiedChargeAttr(self, key): + def getModifiedChargeAttr(self, key, default=None): if key in self.chargeModifiedAttributes: return self.chargeModifiedAttributes[key] else: - return None + return default class ModifiedAttributeDict(collections.MutableMapping): From c567ee2c08ce644dcec5dbd2eefe9483bf837df3 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:16:32 -0800 Subject: [PATCH 4/9] Clean up logic and generally make purdier --- gui/builtinViewColumns/misc.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 5a27bab55..87e4ea9db 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -459,28 +459,23 @@ class Miscellanea(ViewColumn): ): if "Armor" in itemGroup or "Shield" in itemGroup: boosted_attribute = "HP" + reload_time = item.getAttribute("reloadTime", 0) / 1000 elif "Capacitor" in itemGroup: boosted_attribute = "Cap" + reload_time = 10 else: - boosted_attribute = None + boosted_attribute = "" + reload_time = 0 - hp = stuff.hpBeforeReload cycles = stuff.numShots cycleTime = stuff.rawCycleTime - if boosted_attribute == "Cap": - if hp is None: - local_booster = stuff.charge.getAttribute("capacitorBonus", 0) - hp = max(local_booster, 0) * cycles - reload_time = 10 - elif boosted_attribute == "HP": - if hp is None: - armor_repairer = item.getAttribute("armorDamageAmount", None) - shield_booster = item.getAttribute("shieldBonus", None) - hp = max(armor_repairer, shield_booster, 0) - reload_time = item.getAttribute("reloadTime", 0) / 1000 - else: - reload_time = 0 + # Get HP or boosted amount + stuff_hp = stuff.hpBeforeReload + armor_hp = stuff.getModifiedItemAttr("armorDamageAmount", 0) + capacitor_hp = stuff.charge.getModifiedChargeAttr("capacitorBonus", 0) + shield_hp = stuff.getModifiedItemAttr("shieldBonus", 0) + hp = max(stuff_hp, armor_hp * cycles, capacitor_hp * cycles, shield_hp * cycles, 0) if not hp or not cycleTime or not cycles: return "", None From f111c49cc62378576dad7c22d5cd66c52d25219f Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:25:42 -0800 Subject: [PATCH 5/9] wrap getting attribute in at try/except Catches if there's an attribute error. Useful when we try and get an attribute when the object doesn't even have it. --- gui/builtinViewColumns/misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 87e4ea9db..897e6a0ab 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -496,7 +496,7 @@ class Miscellanea(ViewColumn): hpRatio = 1 if ("Ancillary" and "Armor") in itemGroup: - hpRatio *= 3 + hpRatio *= stuff.getModifiedItemAttr("chargedArmorDamageMultiplier", 1) ehp = hp * hpRatio @@ -508,6 +508,7 @@ class Miscellanea(ViewColumn): formatAmount((duration+reload_time)*number_of_cycles, 3, 0, 3), formatAmount(number_of_cycles, 3, 0, 3) ) + text = "{0} / {1}s (+{2}s)".format( formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3), From e524197a4d59bc8575dbdd7405c2f885e87b5f1b Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:25:55 -0800 Subject: [PATCH 6/9] Revert "wrap getting attribute in at try/except" This reverts commit f111c49cc62378576dad7c22d5cd66c52d25219f. --- gui/builtinViewColumns/misc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 897e6a0ab..87e4ea9db 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -496,7 +496,7 @@ class Miscellanea(ViewColumn): hpRatio = 1 if ("Ancillary" and "Armor") in itemGroup: - hpRatio *= stuff.getModifiedItemAttr("chargedArmorDamageMultiplier", 1) + hpRatio *= 3 ehp = hp * hpRatio @@ -508,7 +508,6 @@ class Miscellanea(ViewColumn): formatAmount((duration+reload_time)*number_of_cycles, 3, 0, 3), formatAmount(number_of_cycles, 3, 0, 3) ) - text = "{0} / {1}s (+{2}s)".format( formatAmount(ehp, 3, 0, 9), formatAmount(duration, 3, 0, 3), From 1ebd54b2821ed3d095ddef11c891190c979f1f32 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:27:45 -0800 Subject: [PATCH 7/9] Wrap getting attribute data in a try/except Useful for when we try to get an sub-attribute on an object where the attribute doesn't exist. Now returns the default value. --- eos/gamedata.py | 9 ++++++--- eos/modifiedAttributeDict.py | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/eos/gamedata.py b/eos/gamedata.py index 10317dab2..fca14263a 100644 --- a/eos/gamedata.py +++ b/eos/gamedata.py @@ -244,9 +244,12 @@ class Item(EqBase): return self.__attributes def getAttribute(self, key, default=None): - if key in self.attributes: - return self.attributes[key].value - else: + try: + if key in self.attributes: + return self.attributes[key].value + else: + return default + except AttributeError: return default def isType(self, type): diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index e558dc64d..417a459c2 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -26,17 +26,23 @@ cappingAttrKeyCache = {} class ItemAttrShortcut(object): def getModifiedItemAttr(self, key, default=None): - if key in self.itemModifiedAttributes: - return self.itemModifiedAttributes[key] - else: + try: + if key in self.itemModifiedAttributes: + return self.itemModifiedAttributes[key] + else: + return default + except AttributeError: return default class ChargeAttrShortcut(object): def getModifiedChargeAttr(self, key, default=None): - if key in self.chargeModifiedAttributes: - return self.chargeModifiedAttributes[key] - else: + try: + if key in self.chargeModifiedAttributes: + return self.chargeModifiedAttributes[key] + else: + return default + except AttributeError: return default From dd3316a1c245c00aecd29103e8ee9df7f5297f25 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 00:28:20 -0800 Subject: [PATCH 8/9] Gets the multiplier bonus from the item rather than hard coding it to 3 --- gui/builtinViewColumns/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 87e4ea9db..9535b3656 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -496,7 +496,7 @@ class Miscellanea(ViewColumn): hpRatio = 1 if ("Ancillary" and "Armor") in itemGroup: - hpRatio *= 3 + hpRatio *= stuff.getModifiedItemAttr("chargedArmorDamageMultiplier", 1) ehp = hp * hpRatio From 32611e07c849f6eb05c6234333b30af39543e9e4 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Sun, 29 Jan 2017 10:12:16 -0800 Subject: [PATCH 9/9] Fix syntax. Catch scenarios where none can be passed. --- gui/builtinViewColumns/misc.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gui/builtinViewColumns/misc.py b/gui/builtinViewColumns/misc.py index 9535b3656..a5188253d 100644 --- a/gui/builtinViewColumns/misc.py +++ b/gui/builtinViewColumns/misc.py @@ -467,13 +467,13 @@ class Miscellanea(ViewColumn): boosted_attribute = "" reload_time = 0 - cycles = stuff.numShots - cycleTime = stuff.rawCycleTime + cycles = max(stuff.numShots, 0) + cycleTime = max(stuff.rawCycleTime, 0) # Get HP or boosted amount - stuff_hp = stuff.hpBeforeReload + stuff_hp = max(stuff.hpBeforeReload, 0) armor_hp = stuff.getModifiedItemAttr("armorDamageAmount", 0) - capacitor_hp = stuff.charge.getModifiedChargeAttr("capacitorBonus", 0) + capacitor_hp = stuff.getModifiedChargeAttr("capacitorBonus", 0) shield_hp = stuff.getModifiedItemAttr("shieldBonus", 0) hp = max(stuff_hp, armor_hp * cycles, capacitor_hp * cycles, shield_hp * cycles, 0) @@ -495,7 +495,7 @@ class Miscellanea(ViewColumn): else: hpRatio = 1 - if ("Ancillary" and "Armor") in itemGroup: + if "Ancillary" in itemGroup and "Armor" in itemGroup: hpRatio *= stuff.getModifiedItemAttr("chargedArmorDamageMultiplier", 1) ehp = hp * hpRatio