Пример #1
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
Пример #2
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
Пример #3
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)
Пример #4
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
Пример #5
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