Gracefully handle invalid boosters in database (both itemIDs that don't exist as well as non-booster items). Implants need a little more work
This commit is contained in:
@@ -233,10 +233,14 @@ class HandledImplantBoosterList(HandledList):
|
||||
self.__slotCache = {}
|
||||
|
||||
def append(self, implant):
|
||||
if self.__slotCache.has_key(implant.slot):
|
||||
raise ValueError("Implant/Booster slot already in use, remove the old one first or set replace = True")
|
||||
self.__slotCache[implant.slot] = implant
|
||||
HandledList.append(self, implant)
|
||||
try:
|
||||
if self.__slotCache.has_key(implant.slot):
|
||||
raise ValueError("Implant/Booster slot already in use, remove the old one first or set replace = True")
|
||||
self.__slotCache[implant.slot] = implant
|
||||
HandledList.append(self, implant)
|
||||
except:
|
||||
# if anything goes wrong, simply remove the item
|
||||
eos.db.remove(implant)
|
||||
|
||||
def remove(self, implant):
|
||||
HandledList.remove(self, implant)
|
||||
|
||||
@@ -46,9 +46,13 @@ class Booster(HandledItem, ItemAttrShortcut):
|
||||
|
||||
def __fetchItemInfo(self):
|
||||
import eos.db
|
||||
self.__item = eos.db.getItem(self.itemID)
|
||||
self.__slot = self.__calculateSlot(self.__item)
|
||||
self.build()
|
||||
item = eos.db.getItem(self.itemID)
|
||||
if item:
|
||||
self.__item = item
|
||||
self.__slot = self.__calculateSlot(self.__item)
|
||||
self.build()
|
||||
else:
|
||||
raise ValueError("Invalid item as Booster:", self.itemID)
|
||||
|
||||
def iterSideEffects(self):
|
||||
return self.__sideEffects.__iter__()
|
||||
|
||||
Reference in New Issue
Block a user