| 804 | |
| 805 | |
| 806 | class AbstractFit: |
| 807 | |
| 808 | def __init__(self): |
| 809 | # Modules |
| 810 | self.modulesHigh = [] |
| 811 | self.modulesMed = [] |
| 812 | self.modulesLow = [] |
| 813 | self.rigs = [] |
| 814 | self.subsystems = [] |
| 815 | self.services = [] |
| 816 | # Non-modules |
| 817 | self.implants = [] |
| 818 | self.boosters = [] |
| 819 | self.drones = [] |
| 820 | self.fighters = [] |
| 821 | self.cargo = {} # Format: {item: Cargo} |
| 822 | # Other stuff |
| 823 | self.mutations = {} # Format: {reference: (mutaplamid item, {attr ID: attr value})} |
| 824 | |
| 825 | @property |
| 826 | def __slotContainerMap(self): |
| 827 | return { |
| 828 | FittingSlot.HIGH: self.modulesHigh, |
| 829 | FittingSlot.MED: self.modulesMed, |
| 830 | FittingSlot.LOW: self.modulesLow, |
| 831 | FittingSlot.RIG: self.rigs, |
| 832 | FittingSlot.SUBSYSTEM: self.subsystems, |
| 833 | FittingSlot.SERVICE: self.services} |
| 834 | |
| 835 | def getContainerBySlot(self, slotType): |
| 836 | return self.__slotContainerMap.get(slotType) |
| 837 | |
| 838 | def getSlotByContainer(self, container): |
| 839 | slotType = None |
| 840 | for k, v in self.__slotContainerMap.items(): |
| 841 | if v is container: |
| 842 | slotType = k |
| 843 | break |
| 844 | return slotType |
| 845 | |
| 846 | def addModules(self, itemSpecs): |
| 847 | modules = [] |
| 848 | slotTypes = set() |
| 849 | for itemSpec in itemSpecs: |
| 850 | if itemSpec is None: |
| 851 | modules.append(None) |
| 852 | continue |
| 853 | m = self.__makeModule(itemSpec) |
| 854 | if m is None: |
| 855 | modules.append(None) |
| 856 | continue |
| 857 | modules.append(m) |
| 858 | slotTypes.add(m.slot) |
| 859 | _clearTail(modules) |
| 860 | # If all the modules have same slot type, put them to appropriate |
| 861 | # container with stubs |
| 862 | if len(slotTypes) == 1: |
| 863 | slotType = tuple(slotTypes)[0] |