From d6199a58c2bf9982a839746f5aee82485a8e7728 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Thu, 16 Jul 2015 23:59:37 -0400 Subject: [PATCH] Separate projected fits from list of affectors. Also, show when affected module is projected. Still need to clean up affector tree stuff --- eos/modifiedAttributeDict.py | 9 ++++--- eos/saveddata/character.py | 5 ++++ eos/saveddata/fit.py | 8 ++++-- eos/saveddata/module.py | 8 ++++++ gui/itemStats.py | 47 ++++++++++++++++++++++++------------ 5 files changed, 57 insertions(+), 20 deletions(-) diff --git a/eos/modifiedAttributeDict.py b/eos/modifiedAttributeDict.py index 79d871ce5..09497be2a 100644 --- a/eos/modifiedAttributeDict.py +++ b/eos/modifiedAttributeDict.py @@ -217,13 +217,16 @@ class ModifiedAttributeDict(collections.MutableMapping): if attributeName not in self.__affectedBy: self.__affectedBy[attributeName] = {} affs = self.__affectedBy[attributeName] + origin = self.fit.getOrigin() + fit = origin if origin and origin != self.fit else self.fit # If there's no set for current fit in dictionary, create it - if self.fit not in affs: - affs[self.fit] = [] + if fit not in affs: + affs[fit] = [] # Reassign alias to list - affs = affs[self.fit] + affs = affs[fit] # Get modifier which helps to compose 'Affected by' map modifier = self.fit.getModifier() + # Add current affliction to list affs.append((modifier, operation, bonus, used)) diff --git a/eos/saveddata/character.py b/eos/saveddata/character.py index f0b4d9a56..c3e476526 100644 --- a/eos/saveddata/character.py +++ b/eos/saveddata/character.py @@ -285,5 +285,10 @@ class Skill(HandledItem): copy = Skill(self.item, self.level, self.__ro) return copy + def __repr__(self): + return "Skill(ID={}, name={}) at {}".format( + self.item.ID, self.item.name, hex(id(self)) + ) + class ReadOnlyException(Exception): pass diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index b8a530752..6e1515c44 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -381,8 +381,9 @@ class Fit(object): #Methods to register and get the thing currently affecting the fit, #so we can correctly map "Affected By" - def register(self, currModifier): + def register(self, currModifier, origin=None): self.__modifier = currModifier + self.__origin = origin if hasattr(currModifier, "itemModifiedAttributes"): currModifier.itemModifiedAttributes.fit = self if hasattr(currModifier, "chargeModifiedAttributes"): @@ -391,6 +392,9 @@ class Fit(object): def getModifier(self): return self.__modifier + def getOrigin(self): + return self.__origin + def __calculateGangBoosts(self, runTime): logger.debug("Applying gang boosts in `%s` runtime for %s", runTime, self) for name, info in self.gangBoosts.iteritems(): @@ -506,7 +510,7 @@ class Fit(object): item.calculateModifiedAttributes(self, runTime, False) if projected is True: for _ in xrange(projectionInfo.amount): - targetFit.register(item) + targetFit.register(item, origin=self) item.calculateModifiedAttributes(targetFit, runTime, True) timer.checkpoint('Done with runtime: %s'%runTime) diff --git a/eos/saveddata/module.py b/eos/saveddata/module.py index a4fdbec07..32a28c28e 100644 --- a/eos/saveddata/module.py +++ b/eos/saveddata/module.py @@ -639,6 +639,14 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): copy.state = self.state return copy + def __repr__(self): + if self.item: + return "Module(ID={}, name={}) at {}".format( + self.item.ID, self.item.name, hex(id(self)) + ) + else: + return "EmptyModule() at {}".format(hex(id(self))) + class Rack(Module): ''' This is simply the Module class named something else to differentiate diff --git a/gui/itemStats.py b/gui/itemStats.py index a26406af5..b12eddf4e 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -24,7 +24,7 @@ import bitmapLoader import sys import wx.lib.mixins.listctrl as listmix import wx.html -from eos.types import Ship, Module, Skill, Booster, Implant, Drone, Mode +from eos.types import Fit, Ship, Module, Skill, Booster, Implant, Drone, Mode from gui.utils.numberFormatter import formatAmount import service import config @@ -549,9 +549,9 @@ class ItemEffects (wx.Panel): class ItemAffectedBy (wx.Panel): - ORDER = [Ship, Mode, Module, Drone, Implant, Booster, Skill] + ORDER = [Fit, Ship, Mode, Module, Drone, Implant, Booster, Skill] def __init__(self, parent, stuff, item): - wx.Panel.__init__ (self, parent) + wx.Panel.__init__(self, parent) self.stuff = stuff self.item = item @@ -640,26 +640,37 @@ class ItemAffectedBy (wx.Panel): def PopulateTree(self): root = self.affectedBy.AddRoot("WINPWNZ0R") self.affectedBy.SetPyData(root, None) - + activeFit = gui.mainFrame.MainFrame.getInstance().getActiveFit() + print activeFit self.imageList = wx.ImageList(16, 16) self.affectedBy.SetImageList(self.imageList) cont = self.stuff.itemModifiedAttributes if self.item == self.stuff.item else self.stuff.chargeModifiedAttributes things = {} + holding = {} for attrName in cont.iterAfflictions(): # if value is 0 or there has been no change from original to modified, return if cont[attrName] == (cont.getOriginal(attrName) or 0): continue + for fit, afflictors in cont.getAfflictions(attrName).iteritems(): for afflictor, modifier, amount, used in afflictors: + container = things + #print "\t", afflictor, modifier, amount, used, + if not used or afflictor.item is None: continue - if afflictor.item.name not in things: - things[afflictor.item.name] = [type(afflictor), set(), []] + if fit.ID != activeFit: + if fit not in holding: + holding[fit] = {} + container = holding[fit] - info = things[afflictor.item.name] + if afflictor.item.name not in container: + container[afflictor.item.name] = [type(afflictor), set(), [], getattr(afflictor, "projected", False)] + + info = container[afflictor.item.name] info[1].add(afflictor) # If info[1] > 1, there are two separate modules working. # Check to make sure we only include the modifier once @@ -668,15 +679,20 @@ class ItemAffectedBy (wx.Panel): continue info[2].append((attrName, modifier, amount)) + for fit, items in holding.iteritems(): + child = self.affectedBy.AppendItem(root, fit.name, self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons"))) + self.test(child, holding[fit]) + self.test(root, things) + self.ExpandCollapseTree() + + def test(self, parent, things): order = things.keys() order.sort(key=lambda x: (self.ORDER.index(things[x][0]), x)) - for itemName in order: info = things[itemName] - afflictorType, afflictors, attrData = info + afflictorType, afflictors, attrData, projected = info counter = len(afflictors) - baseAfflictor = afflictors.pop() if afflictorType == Ship: itemIcon = self.imageList.Add(bitmapLoader.getBitmap("ship_small", "icons")) @@ -686,7 +702,12 @@ class ItemAffectedBy (wx.Panel): else: itemIcon = -1 - child = self.affectedBy.AppendItem(root, "%s" % itemName if counter == 1 else "%s x %d" % (itemName,counter), itemIcon) + displayStr = "%s" % itemName if counter == 1 else "%s x %d" % (itemName,counter) + + if projected: + displayStr += " (projected)" + + child = self.affectedBy.AppendItem(parent, displayStr, itemIcon) if counter > 0: attributes = [] @@ -716,7 +737,6 @@ class ItemAffectedBy (wx.Panel): attributes.append((attrName, (displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized, attrIcon)) attrSorted = sorted(attributes, key = lambda attribName: attribName[0]) - for attr in attrSorted: attrName, displayName, attrModifier, attrAmount, penalized, attrIcon = attr if self.toggleView == 1: @@ -725,6 +745,3 @@ class ItemAffectedBy (wx.Panel): else: treeitem = self.affectedBy.AppendItem(child, "%s %s %.2f %s" % (attrName, attrModifier, attrAmount, penalized), attrIcon) self.affectedBy.SetPyData(treeitem,"%s %s %.2f %s" % ((displayName if displayName != "" else attrName), attrModifier, attrAmount, penalized)) - - self.ExpandCollapseTree() -