(self)
| 21 | self.savedPosition = None |
| 22 | |
| 23 | def Do(self): |
| 24 | pyfalog.debug('Doing addition of local drone {} to fit {}'.format(self.droneInfo, self.fitID)) |
| 25 | fit = Fit.getInstance().getFit(self.fitID) |
| 26 | item = Market.getInstance().getItem(self.droneInfo.itemID, eager=("attributes", "group.category")) |
| 27 | # If we're not adding any active drones, check if there's an inactive stack |
| 28 | # with enough space for new drones and use it |
| 29 | if not self.forceNewStack and self.droneInfo.amountActive == 0: |
| 30 | maxStack = droneStackLimit(fit, item) |
| 31 | for drone in fit.drones.find(item): |
| 32 | if ( |
| 33 | drone is not None and drone.amountActive == 0 and |
| 34 | drone.amount + self.droneInfo.amount <= maxStack |
| 35 | ): |
| 36 | self.savedDroneInfo = DroneInfo.fromDrone(drone) |
| 37 | self.savedPosition = fit.drones.index(drone) |
| 38 | drone.amount += self.droneInfo.amount |
| 39 | return True |
| 40 | # Do new stack otherwise |
| 41 | drone = self.droneInfo.toDrone() |
| 42 | if drone is None: |
| 43 | return False |
| 44 | if not self.ignoreRestrictions and not drone.fits(fit): |
| 45 | pyfalog.warning('Drone does not fit') |
| 46 | return False |
| 47 | fit.drones.append(drone) |
| 48 | if drone not in fit.drones: |
| 49 | pyfalog.warning('Failed to append to list') |
| 50 | return False |
| 51 | self.savedPosition = fit.drones.index(drone) |
| 52 | return True |
| 53 | |
| 54 | def Undo(self): |
| 55 | pyfalog.debug('Undoing addition of local drone {} to fit {}'.format(self.droneInfo, self.fitID)) |
nothing calls this directly
no test coverage detected