当前位置: 首页>>代码示例>>Python>>正文


Python Cart.fini方法代码示例

本文整理汇总了Python中cart.Cart.fini方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.fini方法的具体用法?Python Cart.fini怎么用?Python Cart.fini使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cart.Cart的用法示例。


在下文中一共展示了Cart.fini方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Slots

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import fini [as 别名]
class Slots(object):

    def __init__(self, aggregatedData):
        self.cart = Cart(aggregatedData)
        self.bonusPanel = BonusPanel(aggregatedData)
        self.updated = Event()
        self.selected = Event()
        self.__aData = aggregatedData
        self.__currentType = CUSTOMIZATION_TYPE.CAMOUFLAGE
        self.__currentIdx = 0
        self.__data = None
        self.__initialData = None
        self.__updateSlotsData(False)
        self.__aData.updated += self.__updateSlotsData
        return

    def fini(self):
        self.__aData.updated -= self.__updateSlotsData
        self.__aData = None
        self.__data = None
        self.__initialData = None
        self.cart.fini()
        self.bonusPanel.fini()
        self.cart = None
        self.bonusPanel = None
        return

    def getSelectedSlotItemID(self):
        return self.__data['data'][self.__currentType]['data'][self.__currentIdx]['itemID']

    def getInstalledItem(self, idx = None, type_ = None):
        idx = self.__currentIdx if idx is None else idx
        type_ = self.__currentType if type_ is None else type_
        return self.__aData.installed[type_][idx]

    def getSlotItem(self, slotIdx = None, cType = None):
        slotIdx = self.__currentIdx if slotIdx is None else slotIdx
        cType = self.__currentType if cType is None else cType
        itemID = self.__data['data'][cType]['data'][slotIdx]['itemID']
        if itemID < 0:
            return
        else:
            return self.__aData.available[cType][itemID]
            return

    def getItemById(self, cType, itemId):
        return self.__aData.available[cType][itemId]

    def getSummaryString(self):
        totalSlotsNum = 0
        occupiedSlotsNum = 0
        for slotGroupData in self.__data['data']:
            totalSlotsNum += len(slotGroupData['data'])
            for slotData in slotGroupData['data']:
                if slotData['itemID'] >= 0:
                    occupiedSlotsNum += 1

        return text_styles.highTitle(_ms('#customization:typeSwitchScreen/slotSummary', occupiedSlotsNum=occupiedSlotsNum, totalSlotsNum=totalSlotsNum))

    def getCurrentTypeLabel(self):
        return text_styles.middleTitle(_ms('#customization:typeSwitchScreen/typeName/plural/{0}'.format(self.__currentType)))

    def getData(self):
        return self.__data

    def select(self, cType, slotIdx):
        self.__currentType = cType
        self.__currentIdx = slotIdx
        self.selected(cType, slotIdx)
        g_hangarSpace.space.updateVehicleSticker(self.__aData.viewModel[1:3])
        if cType != CUSTOMIZATION_TYPE.CAMOUFLAGE:
            slotItem = self.__data['data'][cType]['data'][slotIdx]
            g_hangarSpace.space.locateCameraOnEmblem(slotItem['spot'] == 0, SLOT_TYPE[cType], self.calculateVehicleIndex(slotIdx, cType), 0.2)
        else:
            g_hangarSpace.space.locateCameraToPreview()

    def updateSlot(self, item, cType = None, slotIdx = None, duration = 0):
        slotIdx = self.__currentIdx if slotIdx is None else slotIdx
        cType = self.__currentType if cType is None else cType
        if item['id'] < 0:
            if cType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
                img = _EMPTY_SLOTS_MAP[cType][slotIdx]
            else:
                img = _EMPTY_SLOTS_MAP[cType]
            price = 0
            bonus = ''
            isInDossier = False
        else:
            img = item['object'].getTexturePath()
            price = item['object'].getPrice(duration)
            isInDossier = item['object'].isInDossier
            bonus = self.__getSlotBonusString(item['object'].qualifier, isInDossier)
        typedData = self.__data['data'][cType]['data']
        if len(typedData) == 2:
            thisItemSlotIdx = slotIdx
            anotherSlotIdx = 1 - slotIdx
            if item['id'] < 0:
                if typedData[thisItemSlotIdx]['itemID'] == typedData[anotherSlotIdx]['itemID']:
                    typedData[anotherSlotIdx]['price'] = self.getSlotItem(cType=cType, slotIdx=anotherSlotIdx).getPrice(typedData[anotherSlotIdx]['duration'])
            elif item['id'] == typedData[anotherSlotIdx]['itemID']:
#.........这里部分代码省略.........
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:103,代码来源:slots.py


注:本文中的cart.Cart.fini方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。