Beispiel #1
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     results = []
     for position in sorted(self.positions, reverse=True):
         drone = fit.drones[position]
         if drone.itemID == self.newItemID:
             continue
         info = DroneInfo.fromDrone(drone)
         info.itemID = self.newItemID
         cmdRemove = CalcRemoveLocalDroneCommand(
             fitID=self.fitID,
             position=position,
             amount=math.inf,
             commit=False)
         cmdAdd = CalcAddLocalDroneCommand(
             fitID=self.fitID,
             droneInfo=info,
             forceNewStack=True,
             ignoreRestrictions=True,
             commit=False)
         results.append(self.internalHistory.submitBatch(cmdRemove, cmdAdd))
     success = any(results)
     eos.db.commit()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
Beispiel #2
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     drone = fit.drones[self.position]
     if self.amount >= drone.amount:
         return False
     info = DroneInfo.fromDrone(drone)
     info.amount = self.amount
     info.amountActive = min(self.amount, info.amountActive)
     commands = []
     commands.append(
         CalcRemoveLocalDroneCommand(fitID=self.fitID,
                                     position=self.position,
                                     amount=self.amount,
                                     commit=False))
     commands.append(
         CalcAddLocalDroneCommand(fitID=self.fitID,
                                  droneInfo=info,
                                  forceNewStack=True,
                                  commit=False))
     success = self.internalHistory.submitBatch(*commands)
     eos.db.commit()
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success
Beispiel #3
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     try:
         drone = fit.drones[self.position]
     except IndexError:
         return False
     if drone.isMutated:
         return False
     info = DroneInfo(
         amount=drone.amount,
         amountActive=drone.amountActive,
         itemID=self.itemID,
         baseItemID=drone.item.ID,
         mutaplasmidID=self.mutaplasmidID,
         mutations={})
     cmdRemove = CalcRemoveLocalDroneCommand(
         fitID=self.fitID,
         position=self.position,
         amount=math.inf)
     cmdAdd = CalcAddLocalDroneCommand(
         fitID=self.fitID,
         droneInfo=info,
         forceNewStack=True,
         ignoreRestrictions=True)
     success = self.internalHistory.submitBatch(cmdRemove, cmdAdd)
     eos.db.flush()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     eos.db.commit()
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitIDs=(self.fitID,)))
     return success
Beispiel #4
0
 def Do(self):
     cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=DroneInfo(itemID=self.itemID, amount=self.amount, amountActive=0))
     success = self.internalHistory.submit(cmd)
     sFit = Fit.getInstance()
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
Beispiel #5
0
 def Do(self):
     cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=self.newDroneInfo, forceNewStack=True)
     success = self.internalHistory.submit(cmd)
     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
Beispiel #6
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     try:
         drone = fit.drones[self.position]
     except IndexError:
         return False
     info = DroneInfo.fromDrone(drone)
     cmd = CalcAddLocalDroneCommand(fitID=self.fitID, droneInfo=info, forceNewStack=True)
     success = self.internalHistory.submit(cmd)
     sFit.recalc(self.fitID)
     sFit.fill(self.fitID)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(), GE.FitChanged(fitID=self.fitID))
     return success
Beispiel #7
0
 def Do(self):
     results = []
     for itemID, amount in self.drones:
         cmd = CalcAddLocalDroneCommand(fitID=self.fitID,
                                        droneInfo=DroneInfo(itemID=itemID,
                                                            amount=amount,
                                                            amountActive=0),
                                        forceNewStack=True)
         results.append(self.internalHistory.submit(cmd))
     success = any(results)
     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
Beispiel #8
0
 def Do(self):
     sFit = Fit.getInstance()
     fit = sFit.getFit(self.fitID)
     drone = fit.drones[self.position]
     if drone.itemID == self.newItemID:
         return False
     info = DroneInfo.fromDrone(drone)
     info.itemID = self.newItemID
     cmdRemove = CalcRemoveLocalDroneCommand(fitID=self.fitID,
                                             position=self.position,
                                             amount=math.inf)
     cmdAdd = CalcAddLocalDroneCommand(fitID=self.fitID,
                                       droneInfo=info,
                                       forceNewStack=True)
     success = self.internalHistory.submitBatch(cmdRemove, cmdAdd)
     sFit.recalc(fit)
     wx.PostEvent(gui.mainFrame.MainFrame.getInstance(),
                  GE.FitChanged(fitID=self.fitID))
     return success