Get list of damage dealer mods with ammo data

This commit is contained in:
DarkPhoenix
2019-10-10 15:40:39 +03:00
parent e883035120
commit 9fddb64ef9
4 changed files with 69 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ import wx
import gui.mainFrame
from gui.contextMenu import ContextMenuSingle
from service.market import Market
class GraphFitAmmoPicker(ContextMenuSingle):
@@ -23,7 +24,7 @@ class GraphFitAmmoPicker(ContextMenuSingle):
return 'Plot with Different Ammo...'
def activate(self, callingWindow, fullContext, mainItem, i):
with AmmoPicker(self.mainFrame) as dlg:
with AmmoPicker(self.mainFrame, mainItem.item) as dlg:
if dlg.ShowModal() == wx.ID_OK:
pass
else:
@@ -35,6 +36,32 @@ GraphFitAmmoPicker.register()
class AmmoPicker(wx.Dialog):
def __init__(self, parent):
def __init__(self, parent, fit):
super().__init__(parent, title='Choose Different Ammo', style=wx.DEFAULT_DIALOG_STYLE)
mods = self.getMods(fit)
self.SetMinSize((346, 156))
def getMods(self, fit):
sMkt = Market.getInstance()
loadableCharges = {}
# Modules, Format: {frozenset(ammo): [module list]}
mods = {}
if fit is not None:
for mod in fit.modules:
if not mod.canDealDamage():
continue
typeID = mod.item.ID
if typeID in loadableCharges:
charges = loadableCharges[typeID]
else:
charges = loadableCharges.setdefault(typeID, set())
for charge in mod.getValidCharges():
if sMkt.getPublicityByItem(charge):
charges.add(charge)
if charges:
mods.setdefault(frozenset(charges), []).append(mod)
return mods