From 29b5a7433d2044bc2adf719de6b8853b8e3f07cb Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Wed, 16 Nov 2016 09:54:02 -0500 Subject: [PATCH] Trying to flesh out how command boosts are gonna work. --- eos/effects/chargebonuswarfarecharge.py | 33 ++++++++++++++++++++++--- eos/saveddata/fit.py | 12 +++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/eos/effects/chargebonuswarfarecharge.py b/eos/effects/chargebonuswarfarecharge.py index 8bc9db28b..d4b2769c3 100644 --- a/eos/effects/chargebonuswarfarecharge.py +++ b/eos/effects/chargebonuswarfarecharge.py @@ -1,16 +1,43 @@ # We should probably have something a little less hacky in place, but time is money! + + +''' +Some documentation: +When the fit is calculated, we gather up all the gang effects and stick them onto the fit. We don't run the actual +effect yet, only give the fit details so that it can run the effect at a later time. We need to do this so that we can +only run the strongest effect. When we are done, one of the last things that we do with the fit is to loop through those +bonuses and actually run the effect. To do this, we have a special argument passed into the effect handler that tells it +which warfareBuffID to run (shouldn't need this right now, but better safe than sorry) +''' + + type = "passive" -def handler(fit, module, context): +def handler(fit, module, context, warfareBuffID = None): + print "In chargeBonusWarfareEffect, context: ", context def runEffect(id, value): + print "RUN EFFECT: ", if id == 21: # Skirmish Burst: Interdiction Maneuvers: Tackle Range + print "Tackle Range" + return groups = ("Stasis Web", "Warp Scrambler") fit.modules.filteredItemBoost(lambda mod: mod.item.group.name in groups, - "maxRange", value, + "maxRange", value, stackingPenalties=True) + if id == 10: + print "Shield Resists" print "Inside the CHARGE" + for x in xrange(1, 4): if module.getModifiedChargeAttr("warfareBuff{}ID".format(x)): - runEffect(module.getModifiedChargeAttr("warfareBuff{}ID".format(x)), module.getModifiedChargeAttr("warfareBuff{}Value".format(x))) + value = module.getModifiedChargeAttr("warfareBuff{}Value".format(x)) + id = module.getModifiedChargeAttr("warfareBuff{}ID".format(x)) + + if 'commandRun' not in context: + print "Add buffID", warfareBuffID, " to ", fit + fit.addCommandBonus(id, value, module) + elif warfareBuffID is not None and warfareBuffID == id: + print "Running buffID ", warfareBuffID, " on ", fit + runEffect(warfareBuffID, value) diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index b6209b5bf..9087a8f63 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -79,6 +79,14 @@ class Fit(object): self.build() + def addCommandBonus(self, warfareBuffID, value, module): + # oh fuck this is so janky + # @todo should we pass in min/max to this function, or is abs okay? (abs is old method, ccp now provides the aggregate function in their data) + print "Add command bonus: ", warfareBuffID, " - value: ", value + + if warfareBuffID not in self.commandBonuses or abs(self.commandBonuses[warfareBuffID][0]) > abs(value): + self.commandBonuses[warfareBuffID] = (value, module) + @reconstructor def init(self): """Initialize a fit from the database and validate""" @@ -136,6 +144,7 @@ class Fit(object): self.boostsFits = set() self.gangBoosts = None self.ecmProjectedStr = 1 + self.commandBonuses = {} @property def targetResists(self): @@ -559,6 +568,9 @@ class Fit(object): timer.checkpoint('Done with runtime: %s'%runTime) + print "Command: " + print self.commandBonuses + # Mark fit as calculated self.__calculated = True