Reworked slot-copying logic so that we can call it explicitly outside the append. Needed for the fitting commands to know what the previous item ID was that it's replacing.

This commit is contained in:
Ryan Holmes
2018-08-05 08:14:12 -04:00
parent 7a1b4b4a1e
commit 326e1e04c2
6 changed files with 31 additions and 5 deletions

View File

@@ -197,14 +197,20 @@ class HandledImplantBoosterList(HandledList):
self.remove(thing)
return
self.makeRoom(thing)
HandledList.append(self, thing)
def makeRoom(self, thing):
# if needed, remove booster that was occupying slot
oldObj = next((m for m in self if m.slot == thing.slot), None)
if oldObj:
pyfalog.info("Slot {0} occupied with {1}, replacing with {2}", thing.slot, oldObj.item.name, thing.item.name)
pyfalog.info("Slot {0} occupied with {1}, replacing with {2}", thing.slot, oldObj.item.name,
thing.item.name)
itemID = oldObj.itemID
oldObj.itemID = 0 # hack to remove from DB. See GH issue #324
self.remove(oldObj)
HandledList.append(self, thing)
return itemID
return None
class HandledSsoCharacterList(list):