Restore booster state even when it was replaced by another booster
This commit is contained in:
@@ -23,7 +23,7 @@ import datetime
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.db.saveddata.implant import charImplants_table
|
||||
from eos.effectHandlerHelpers import HandledImplantBoosterList, HandledSsoCharacterList
|
||||
from eos.effectHandlerHelpers import HandledImplantList, HandledSsoCharacterList
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.user import User
|
||||
from eos.saveddata.character import Character, Skill
|
||||
@@ -75,7 +75,7 @@ mapper(Character, characters_table,
|
||||
cascade="all,delete-orphan"),
|
||||
"_Character__implants" : relation(
|
||||
Implant,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
collection_class=HandledImplantList,
|
||||
cascade='all,delete-orphan',
|
||||
backref='character',
|
||||
single_parent=True,
|
||||
|
||||
@@ -31,7 +31,7 @@ from eos.db.saveddata.drone import drones_table
|
||||
from eos.db.saveddata.fighter import fighters_table
|
||||
from eos.db.saveddata.implant import fitImplants_table
|
||||
from eos.db.saveddata.module import modules_table
|
||||
from eos.effectHandlerHelpers import HandledDroneCargoList, HandledImplantBoosterList, HandledModuleList, HandledProjectedDroneList, HandledProjectedModList
|
||||
from eos.effectHandlerHelpers import HandledDroneCargoList, HandledImplantList, HandledBoosterList, HandledModuleList, HandledProjectedDroneList, HandledProjectedModList
|
||||
from eos.saveddata.booster import Booster
|
||||
from eos.saveddata.cargo import Cargo
|
||||
from eos.saveddata.character import Character
|
||||
@@ -183,7 +183,7 @@ mapper(es_Fit, fits_table,
|
||||
"shipID": fits_table.c.shipID,
|
||||
"_Fit__boosters": relation(
|
||||
Booster,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
collection_class=HandledBoosterList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
backref='owner',
|
||||
single_parent=True),
|
||||
@@ -219,7 +219,7 @@ mapper(es_Fit, fits_table,
|
||||
primaryjoin=and_(fighters_table.c.fitID == fits_table.c.ID, fighters_table.c.projected == True)), # noqa
|
||||
"_Fit__implants": relation(
|
||||
Implant,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
collection_class=HandledImplantList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
backref='owner',
|
||||
single_parent=True,
|
||||
|
||||
@@ -23,7 +23,7 @@ import datetime
|
||||
|
||||
from eos.db import saveddata_meta
|
||||
from eos.db.saveddata.implant import implantsSetMap_table
|
||||
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
||||
from eos.effectHandlerHelpers import HandledImplantList
|
||||
from eos.saveddata.implant import Implant
|
||||
from eos.saveddata.implantSet import ImplantSet
|
||||
|
||||
@@ -38,7 +38,7 @@ mapper(ImplantSet, implant_set_table,
|
||||
properties={
|
||||
"_ImplantSet__implants": relation(
|
||||
Implant,
|
||||
collection_class=HandledImplantBoosterList,
|
||||
collection_class=HandledImplantList,
|
||||
cascade='all, delete, delete-orphan',
|
||||
backref='set',
|
||||
single_parent=True,
|
||||
|
||||
@@ -211,7 +211,8 @@ class HandledDroneCargoList(HandledList):
|
||||
self.remove(thing)
|
||||
|
||||
|
||||
class HandledImplantBoosterList(HandledList):
|
||||
class HandledImplantList(HandledList):
|
||||
|
||||
def append(self, thing):
|
||||
if thing.isInvalid:
|
||||
HandledList.append(self, thing)
|
||||
@@ -234,6 +235,32 @@ class HandledImplantBoosterList(HandledList):
|
||||
return None
|
||||
|
||||
|
||||
class HandledBoosterList(HandledList):
|
||||
|
||||
def append(self, thing):
|
||||
if thing.isInvalid:
|
||||
HandledList.append(self, thing)
|
||||
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)
|
||||
itemID = oldObj.itemID
|
||||
state = oldObj.active
|
||||
sideEffects = {se.effectID: se.active for se in oldObj.sideEffects}
|
||||
oldObj.itemID = 0 # hack to remove from DB. See GH issue #324
|
||||
self.remove(oldObj)
|
||||
return itemID, state, sideEffects
|
||||
return None, None, None
|
||||
|
||||
|
||||
class HandledSsoCharacterList(list):
|
||||
def append(self, character):
|
||||
old = next((x for x in self if x.client == character.client), None)
|
||||
|
||||
@@ -27,7 +27,7 @@ from sqlalchemy.orm import validates, reconstructor
|
||||
import eos
|
||||
import eos.db
|
||||
import eos.config
|
||||
from eos.effectHandlerHelpers import HandledItem, HandledImplantBoosterList
|
||||
from eos.effectHandlerHelpers import HandledItem, HandledImplantList
|
||||
|
||||
pyfalog = Logger(__name__)
|
||||
|
||||
@@ -51,7 +51,7 @@ class Character(object):
|
||||
for item in self.getSkillList():
|
||||
self.addSkill(Skill(self, item.ID, self.defaultLevel))
|
||||
|
||||
self.__implants = HandledImplantBoosterList()
|
||||
self.__implants = HandledImplantList()
|
||||
|
||||
@reconstructor
|
||||
def init(self):
|
||||
|
||||
@@ -27,7 +27,7 @@ from sqlalchemy.orm import validates, reconstructor
|
||||
|
||||
import eos.db
|
||||
from eos import capSim
|
||||
from eos.effectHandlerHelpers import HandledModuleList, HandledDroneCargoList, HandledImplantBoosterList, HandledProjectedDroneList, HandledProjectedModList
|
||||
from eos.effectHandlerHelpers import HandledModuleList, HandledDroneCargoList, HandledImplantList, HandledBoosterList, HandledProjectedDroneList, HandledProjectedModList
|
||||
from eos.const import ImplantLocation, CalcType, FittingSlot
|
||||
from eos.saveddata.ship import Ship
|
||||
from eos.saveddata.drone import Drone
|
||||
@@ -57,8 +57,8 @@ class Fit(object):
|
||||
self.__drones = HandledDroneCargoList()
|
||||
self.__fighters = HandledDroneCargoList()
|
||||
self.__cargo = HandledDroneCargoList()
|
||||
self.__implants = HandledImplantBoosterList()
|
||||
self.__boosters = HandledImplantBoosterList()
|
||||
self.__implants = HandledImplantList()
|
||||
self.__boosters = HandledBoosterList()
|
||||
# self.__projectedFits = {}
|
||||
self.__projectedModules = HandledProjectedModList()
|
||||
self.__projectedDrones = HandledProjectedDroneList()
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from eos.effectHandlerHelpers import HandledImplantBoosterList
|
||||
from eos.effectHandlerHelpers import HandledImplantList
|
||||
|
||||
|
||||
class ImplantSet(object):
|
||||
def __init__(self, name=None):
|
||||
self.name = name
|
||||
self.__implants = HandledImplantBoosterList()
|
||||
self.__implants = HandledImplantList()
|
||||
|
||||
@property
|
||||
def implants(self):
|
||||
|
||||
Reference in New Issue
Block a user