Exemplo n.º 1
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     if fit.implantSource != ImplantLocation.FIT:
         cmd = CalcChangeImplantLocationCommand(fitID=self.fitID,
                                                source=ImplantLocation.FIT,
                                                commit=False)
         successSource = self.internalHistory.submit(cmd)
     else:
         successSource = False
     cmd = CalcAddImplantCommand(
         fitID=self.fitID,
         implantInfo=ImplantInfo(itemID=self.itemID),
         commit=False)
     successImplant = self.internalHistory.submit(cmd)
     # Acceptable behavior when we already have passed implant and just switch source, or
     # when we have source and add implant, but not if we do not change anything
     success = successSource or successImplant
     eos.db.commit()
     sFit = Fit.getInstance()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
Exemplo n.º 2
0
 def Do(self):
     if not self.implants:
         return False
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     if fit.implantSource != ImplantLocation.FIT:
         cmd = CalcChangeImplantLocationCommand(fitID=self.fitID, source=ImplantLocation.FIT)
         successSource = self.internalHistory.submit(cmd)
     else:
         successSource = False
     resultsImplants = []
     for itemID in self.implants:
         cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=ImplantInfo(itemID=itemID))
         resultsImplants.append(self.internalHistory.submit(cmd))
     successImplants = any(resultsImplants)
     # Acceptable behavior when we already have passed implant and just switch source, or
     # when we have source and add implant, but not if we do not change anything
     success = successSource or successImplants
     eos.db.flush()
     sFit = Fit.getInstance()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
     return success
Exemplo n.º 3
0
 def Do(self):
     pyfalog.debug(
         'Doing removal of implant from position {} on fit {}'.format(
             self.position, self.fitID))
     fit = Fit.getInstance().getFit(self.fitID)
     implant = fit.implants[self.position]
     self.savedImplantInfo = ImplantInfo.fromImplant(implant)
     fit.implants.remove(implant)
     return True
Exemplo n.º 4
0
 def makeRoom(self, implant):
     # if needed, remove booster that was occupying slot
     oldObj = next((i for i in self if i.slot == implant.slot), None)
     if oldObj is not None:
         pyfalog.info("Slot {0} occupied with {1}, replacing with {2}", implant.slot, oldObj.item.name, implant.item.name)
         position = self.index(oldObj)
         from gui.fitCommands.helpers import ImplantInfo
         implantInfo = ImplantInfo.fromImplant(oldObj)
         oldObj.itemID = 0  # hack to remove from DB. See GH issue #324
         self.remove(oldObj)
         return position, implantInfo
     return None, None
Exemplo n.º 5
0
 def makeRoom(self, implant):
     # if needed, remove booster that was occupying slot
     oldObj = next((i for i in self if i.slot == implant.slot), None)
     if oldObj is not None:
         pyfalog.info("Slot {0} occupied with {1}, replacing with {2}", implant.slot, oldObj.item.name, implant.item.name)
         position = self.index(oldObj)
         from gui.fitCommands.helpers import ImplantInfo
         implantInfo = ImplantInfo.fromImplant(oldObj)
         oldObj.itemID = 0  # hack to remove from DB. See GH issue #324
         self.remove(oldObj)
         return position, implantInfo
     return None, None
Exemplo n.º 6
0
 def Do(self):
     results = []
     for itemID in self.itemIDs:
         cmd = CalcAddImplantCommand(fitID=self.fitID,
                                     implantInfo=ImplantInfo(itemID=itemID),
                                     commit=False)
         results.append(self.internalHistory.submit(cmd))
     eos.db.commit()
     Fit.getInstance().recalc(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     # Some might fail, as we already might have these implants
     return any(results)
Exemplo n.º 7
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     implant = fit.implants[self.position]
     if implant.itemID == self.newItemID:
         return False
     info = ImplantInfo.fromImplant(implant)
     info.itemID = self.newItemID
     cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=info)
     success = self.internalHistory.submit(cmd)
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
Exemplo n.º 8
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     implant = fit.implants[self.position]
     if implant.itemID == self.newItemID:
         return False
     info = ImplantInfo.fromImplant(implant)
     info.itemID = self.newItemID
     cmd = CalcAddImplantCommand(fitID=self.fitID, implantInfo=info)
     success = self.internalHistory.submit(cmd)
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     self.newPosition = cmd.newPosition
     newImplant = fit.implants[self.newPosition]
     mainFrame = gui.mainFrame.MainFrame.getInstance()
     wx.PostEvent(mainFrame, GE.FitChanged(fitIDs=(self.fitID, )))
     wx.PostEvent(mainFrame,
                  GE.ItemChangedInplace(old=implant, new=newImplant))
     return success