From cfd82a6ad4c81baf470b94b739f32f513f379fc9 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Fri, 29 Apr 2016 18:47:53 -0400 Subject: [PATCH] Add titan gang bonuses, along with other things --- .../modulebonusnetworkedsensorarray.py | 2 +- eos/effects/shipbonustitana4fleetbonus.py | 9 +++++++ eos/effects/shipbonustitanc4fleetbonus.py | 9 +++++++ eos/effects/shipbonustitang4fleetbonus.py | 9 +++++++ eos/effects/shipbonustitanm4fleetbonus.py | 9 +++++++ eos/saveddata/fit.py | 4 ++- eos/saveddata/ship.py | 5 +++- gui/fighterView.py | 25 ++++++++++--------- 8 files changed, 57 insertions(+), 15 deletions(-) create mode 100644 eos/effects/shipbonustitana4fleetbonus.py create mode 100644 eos/effects/shipbonustitanc4fleetbonus.py create mode 100644 eos/effects/shipbonustitang4fleetbonus.py create mode 100644 eos/effects/shipbonustitanm4fleetbonus.py diff --git a/eos/effects/modulebonusnetworkedsensorarray.py b/eos/effects/modulebonusnetworkedsensorarray.py index 2005861d2..688f51b0f 100644 --- a/eos/effects/modulebonusnetworkedsensorarray.py +++ b/eos/effects/modulebonusnetworkedsensorarray.py @@ -1,4 +1,4 @@ -type = "passive" +type = "active" def handler(fit, src, context): fit.ship.increaseItemAttr("maxLockedTargets", src.getModifiedItemAttr("maxLockedTargetsBonus")) fit.ship.multiplyItemAttr("maxTargetRange", src.getModifiedItemAttr("maxTargetRangeMultiplier"), stackingPenalties=True, penaltyGroup="postMul") diff --git a/eos/effects/shipbonustitana4fleetbonus.py b/eos/effects/shipbonustitana4fleetbonus.py new file mode 100644 index 000000000..5ca86aaa1 --- /dev/null +++ b/eos/effects/shipbonustitana4fleetbonus.py @@ -0,0 +1,9 @@ +type = "gang" +gangBoost = "rechargeRate" +gangBonus = "shipBonusTitanA4" +runTime = "late" + +def handler(fit, src, context): + if "gang" not in context: return + fit.ship.boostItemAttr(gangBoost, src.getModifiedItemAttr(gangBonus) * src.parent.character.getSkill("Amarr Titan").level) + diff --git a/eos/effects/shipbonustitanc4fleetbonus.py b/eos/effects/shipbonustitanc4fleetbonus.py new file mode 100644 index 000000000..a20422f2a --- /dev/null +++ b/eos/effects/shipbonustitanc4fleetbonus.py @@ -0,0 +1,9 @@ +type = "gang" +gangBoost = "shieldCapacity" +gangBonus = "shipBonusTitanC4" +runTime = "late" + +def handler(fit, src, context): + if "gang" not in context: return + fit.ship.boostItemAttr(gangBoost, src.getModifiedItemAttr(gangBonus) * src.parent.character.getSkill("Caldari Titan").level) + diff --git a/eos/effects/shipbonustitang4fleetbonus.py b/eos/effects/shipbonustitang4fleetbonus.py new file mode 100644 index 000000000..289366f61 --- /dev/null +++ b/eos/effects/shipbonustitang4fleetbonus.py @@ -0,0 +1,9 @@ +type = "gang" +gangBoost = "armorHP" +gangBonus = "shipBonusTitanG4" +runTime = "late" + +def handler(fit, src, context): + if "gang" not in context: return + fit.ship.boostItemAttr(gangBoost, src.getModifiedItemAttr(gangBonus) * src.parent.character.getSkill("Gallente Titan").level) + diff --git a/eos/effects/shipbonustitanm4fleetbonus.py b/eos/effects/shipbonustitanm4fleetbonus.py new file mode 100644 index 000000000..293ad00f1 --- /dev/null +++ b/eos/effects/shipbonustitanm4fleetbonus.py @@ -0,0 +1,9 @@ +type = "gang" +gangBoost = "signatureRadius" +gangBonus = "shipBonusTitanM4" +runTime = "late" + +def handler(fit, src, context): + if "gang" not in context: return + fit.ship.boostItemAttr(gangBoost, src.getModifiedItemAttr(gangBonus) * src.parent.character.getSkill("Minmatar Titan").level) + diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index aa7997737..7db7c7216 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -56,6 +56,7 @@ class Fit(object): """Initialize a fit from the program""" # use @mode.setter's to set __attr and IDs. This will set mode as well self.ship = ship + self.ship.parent = self self.__modules = HandledModuleList() self.__drones = HandledDroneCargoList() @@ -89,7 +90,7 @@ class Fit(object): return try: - self.__ship = Ship(item) + self.__ship = Ship(item, self) # @todo extra attributes is now useless, however it set to be # the same as ship attributes for ease (so we don't have to # change all instances in source). Remove this at some point @@ -462,6 +463,7 @@ class Fit(object): if self.fleet is not None and withBoosters is True: logger.debug("Fleet is set, gathering gang boosts") self.gangBoosts = self.fleet.recalculateLinear(withBoosters=withBoosters) + timer.checkpoint("Done calculating gang boosts for %r"%self) elif self.fleet is None: self.gangBoosts = None diff --git a/eos/saveddata/ship.py b/eos/saveddata/ship.py index 0a0e13c45..0d9def9ee 100644 --- a/eos/saveddata/ship.py +++ b/eos/saveddata/ship.py @@ -41,7 +41,7 @@ class Ship(ItemAttrShortcut, HandledItem): # as None unless the Entosis effect sets it. } - def __init__(self, item): + def __init__(self, item, parent=None): if item.category.name != "Ship": raise ValueError('Passed item "%s" (category: (%s)) is not under Ship category'%(item.name, item.category.name)) @@ -53,6 +53,9 @@ class Ship(ItemAttrShortcut, HandledItem): self.__itemModifiedAttributes.original.update(self.EXTRA_ATTRIBUTES) self.__itemModifiedAttributes.overrides = self.item.overrides + # there are occasions when we need to get to the parent fit of the ship, such as when we need the character + # skills for ship-role gang boosts (Titans) + self.parent = parent self.commandBonus = 0 @property diff --git a/gui/fighterView.py b/gui/fighterView.py index 7ae5160eb..b011f89d0 100644 --- a/gui/fighterView.py +++ b/gui/fighterView.py @@ -85,21 +85,22 @@ class FighterView(wx.Panel): activeFitID = self.mainFrame.getActiveFit() fit = sFit.getFit(activeFitID) - for x in self.labels: - slot = getattr(Slot, "F_{}".format(x.upper())) - used = fit.getSlotsUsed(slot) - total = fit.getNumSlots(slot) - color = wx.Colour(204, 51, 51) if used > total else wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT) + if fit: + for x in self.labels: + slot = getattr(Slot, "F_{}".format(x.upper())) + used = fit.getSlotsUsed(slot) + total = fit.getNumSlots(slot) + color = wx.Colour(204, 51, 51) if used > total else wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT) - lbl = getattr(self, "label%sUsed" % x.capitalize()) - lbl.SetLabel(str(int(used))) - lbl.SetForegroundColour(color) + lbl = getattr(self, "label%sUsed" % x.capitalize()) + lbl.SetLabel(str(int(used))) + lbl.SetForegroundColour(color) - lbl = getattr(self, "label%sTotal" % x.capitalize()) - lbl.SetLabel(str(int(total))) - lbl.SetForegroundColour(color) + lbl = getattr(self, "label%sTotal" % x.capitalize()) + lbl.SetLabel(str(int(total))) + lbl.SetForegroundColour(color) - self.Refresh() + self.Refresh() class FighterDisplay(d.Display):