def getDisplayableData(self, intCD):
     if intCD is not None:
         vehicle = self.itemsCache.items.getItemByCD(int(intCD))
         return vo_converters.makeVehicleVO(vehicle)
     else:
         super(CybersportSelectedVehicleToolTipData, self).getDisplayableData(intCD)
         return
    def updateData(self):
        if not self.getFilters().get('compatibleOnly',
                                     True) or self.__vehicles is None:
            vehicleVOs = self._updateData(
                g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY))
        else:
            vehicleVOs = self._updateData(self.__vehicles)
        if self.__selectedVehicles is not None:
            vehicleGetter = g_itemsCache.items.getItemByCD
            selected = [
                makeVehicleVO(vehicleGetter(int(item)))
                for item in self.__selectedVehicles
            ]
        else:
            selected = None
        for vehicleVO in vehicleVOs:
            if self.__vehicles is not None and vehicleVO[
                    'intCD'] not in self.__vehicles.keys(
                    ) and vehicleVO['enabled']:
                vehicleVO[
                    'tooltip'] = TOOLTIPS.CYBERSPORT_VEHICLESELECTOR_BADVEHICLE
                vehicleVO['enabled'] = False
                vehicleVO['showAlert'] = True
                vehicleVO['alertSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_GEAR
                vehicleVO['isReadyToFight'] = True

        self.as_setListDataS(vehicleVOs, selected)
        return
Beispiel #3
0
 def getDisplayableData(self, intCD):
     if intCD is not None:
         vehicle = g_itemsCache.items.getItemByCD(int(intCD))
         return vo_converters.makeVehicleVO(vehicle)
     else:
         super(CybersportSelectedVehicleToolTipData, self).getDisplayableData(intCD)
         return
 def onUnitVehiclesChanged(self, dbID, vInfos):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     needToUpdateSlots = g_eventsCache.isSquadXpFactorsEnabled()
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if vInfos and not vInfos[0].isEmpty():
             vInfo = vInfos[0]
             vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange(), isCurrentPlayer=pInfo.isCurrentPlayer())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         if pInfo.isCurrentPlayer():
             if len(vInfos) < slotIdx + 1:
                 needToUpdateSlots = True
         elif vehicleVO is None:
             needToUpdateSlots = True
     if g_eventsCache.isSquadXpFactorsEnabled() or g_eventsCache.isBalancedSquadEnabled():
         self.as_setActionButtonStateS(self.__getActionButtonStateVO())
     if needToUpdateSlots:
         self._updateMembersData()
     return
Beispiel #5
0
 def _makeVehicleVOAction(self, vehicle):
     vehicleVO = makeVehicleVO(vehicle, self._levelsRange,
                               self.__vehicleTypes)
     if vehicle.isOnlyForEpicBattles:
         vehicleVO['enabled'], vehicleVO[
             'tooltip'] = False, TOOLTIPS.CYBERSPORT_UNIT_FIGHTBTN_EVENTVEHICLEWRONGMODE
     return vehicleVO
Beispiel #6
0
    def _updateData(self, allVehicles, levelsRange, vehicleTypes):
        criteria = REQ_CRITERIA.EMPTY
        criteria |= ~REQ_CRITERIA.VEHICLE.EXPIRED_IGR_RENT
        criteria |= ~REQ_CRITERIA.VEHICLE.DISABLED_IN_PREM_IGR
        if not self.showNotReadyVehicles:
            criteria |= REQ_CRITERIA.VEHICLE.READY
        if self.__filters:
            if self.__filters["nation"] != -1:
                criteria |= REQ_CRITERIA.NATIONS([self.__filters["nation"]])
            if self.__filters["vehicleType"] != "none":
                criteria |= REQ_CRITERIA.VEHICLE.CLASSES([self.__filters["vehicleType"]])
            if self.__filters["isMain"]:
                criteria |= REQ_CRITERIA.VEHICLE.FAVORITE
            if self.__filters["level"] != -1:
                criteria |= REQ_CRITERIA.VEHICLE.LEVELS([self.__filters["level"]])
        filteredVehicles = allVehicles.filter(criteria)
        if self.__filters.get("compatibleOnly", True):
            predicate = lambda vo: vo.get("enabled")
        else:
            predicate = lambda vo: True
        result = []
        for v in filteredVehicles.itervalues():
            vo = makeVehicleVO(v, levelsRange, vehicleTypes)
            if predicate(vo):
                result.append(vo)

        return result
    def getDisplayableData(self, index, unitMgrID=None):
        if unitMgrID is not None:
            unitMgrID = int(unitMgrID)
        dispatcher = g_prbLoader.getDispatcher()
        if dispatcher is not None:
            entity = dispatcher.getEntity()
            vehicleGetter = self.itemsCache.items.getItemByCD
            slotFilters = entity.getSlotFilters()
            vehicleCDs = slotFilters.get(index, {}).get('vehicle_cds', [])
            conditions = []
            leftCount = len(vehicleCDs) - _MAX_VEHICLES_COUNT
            for vehicleCD in vehicleCDs[:_MAX_VEHICLES_COUNT]:
                conditions.append({
                    'vehicle':
                    vo_converters.makeVehicleVO(vehicleGetter(vehicleCD))
                })

            return {
                'conditions': conditions,
                'isCreator': True,
                'toolTipType': TOOLTIPS_CONSTANTS.FORT_SORTIE_SLOT,
                'leftCount': leftCount if leftCount > 0 else 0
            }
        else:
            super(FortificationsSlotToolTipData,
                  self).getDisplayableData(index, unitMgrID)
            return
 def onUnitVehicleChanged(self, dbID, vInfo):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if not vInfo.isEmpty():
             vehicleVO = makeVehicleVO(
                 g_itemsCache.items.getItemByCD(vInfo.vehTypeCD),
                 functional.getRosterSettings().getLevelsRange())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         unitStats = functional.getStats()
         canDoAction, restriction = functional.validateLevels(
             stats=unitStats)
         self.as_setTotalLabelS(
             canDoAction,
             vo_converters.makeTotalLevelLabel(unitStats, restriction),
             unitStats.curTotalLevel)
     if pInfo.isCurrentPlayer() or functional.getPlayerInfo().isCreator():
         self._setActionButtonState()
Beispiel #9
0
 def onUnitVehiclesChanged(self, dbID, vInfos):
     entity = self.prbEntity
     pInfo = entity.getPlayerInfo(dbID=dbID)
     needToUpdateSlots = self.eventsCache.isSquadXpFactorsEnabled()
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if vInfos and not vInfos[0].isEmpty():
             vInfo = vInfos[0]
             vehicleVO = makeVehicleVO(
                 g_itemsCache.items.getItemByCD(vInfo.vehTypeCD),
                 entity.getRosterSettings().getLevelsRange(),
                 isCurrentPlayer=pInfo.isCurrentPlayer())
             slotCost = vInfo.vehLevel
         else:
             slotState = entity.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         if pInfo.isCurrentPlayer():
             if len(vInfos) < slotIdx + 1:
                 needToUpdateSlots = True
         elif vehicleVO is None:
             needToUpdateSlots = True
     if self.eventsCache.isSquadXpFactorsEnabled(
     ) or self.eventsCache.isBalancedSquadEnabled():
         self.as_setActionButtonStateS(self.__getActionButtonStateVO())
     if needToUpdateSlots:
         self._updateMembersData()
     return
 def onUnitVehiclesChanged(self, dbID, vInfos):
     entity = self.prbEntity
     pInfo = entity.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if vInfos and not vInfos[0].isEmpty():
             vInfo = vInfos[0]
             vehicleVO = makeVehicleVO(
                 self.itemsCache.items.getItemByCD(vInfo.vehTypeCD),
                 entity.getRosterSettings().getLevelsRange())
             slotCost = vInfo.vehLevel
         else:
             slotState = entity.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         unitStats = entity.getStats()
         result = entity.validateLevels()
         self.as_setTotalLabelS(
             result.isValid,
             vo_converters.makeTotalLevelLabel(unitStats,
                                               result.restriction),
             unitStats.curTotalLevel)
     self._setActionButtonState()
     return
    def _updateData(self, allVehicles, levelsRange, vehicleTypes):
        criteria = REQ_CRITERIA.EMPTY
        criteria |= ~REQ_CRITERIA.VEHICLE.EXPIRED_IGR_RENT
        criteria |= ~REQ_CRITERIA.VEHICLE.DISABLED_IN_PREM_IGR
        if not self.showNotReadyVehicles:
            criteria |= REQ_CRITERIA.VEHICLE.READY
        if self.__filters:
            if self.__filters['nation'] != -1:
                criteria |= REQ_CRITERIA.NATIONS([self.__filters['nation']])
            if self.__filters['vehicleType'] != 'none':
                criteria |= REQ_CRITERIA.VEHICLE.CLASSES(
                    [self.__filters['vehicleType']])
            if self.__filters['isMain']:
                criteria |= REQ_CRITERIA.VEHICLE.FAVORITE
            if self.__filters['level'] != -1:
                criteria |= REQ_CRITERIA.VEHICLE.LEVELS(
                    [self.__filters['level']])
        filteredVehicles = allVehicles.filter(criteria)
        if self.__filters.get('compatibleOnly', True):
            predicate = lambda vo: vo.get('enabled')
        else:
            predicate = lambda vo: True
        result = []
        for v in filteredVehicles.itervalues():
            vo = makeVehicleVO(v, levelsRange, vehicleTypes)
            if predicate(vo):
                result.append(vo)

        return result
Beispiel #12
0
 def onUnitVehicleChanged(self, dbID, vInfo):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if g_eventsCache.isEventEnabled() and pInfo.isCreator():
         self.__isFallout = None
         if not vInfo.isEmpty():
             vehicle = g_itemsCache.items.getItemByCD(vInfo.vehTypeCD)
             self.__isFallout = vehicle.isEvent
         self._updateRallyData()
         self._setActionButtonState()
         return
     else:
         if pInfo.isInSlot:
             slotIdx = pInfo.slotIdx
             if not vInfo.isEmpty():
                 vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange(), isFallout=self.__isFallout, isCreator=pInfo.isCreator())
                 slotCost = vInfo.vehLevel
             else:
                 slotState = functional.getSlotState(slotIdx)
                 vehicleVO = None
                 if slotState.isClosed:
                     slotCost = settings.UNIT_CLOSED_SLOT_COST
                 else:
                     slotCost = 0
             self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         return
Beispiel #13
0
 def getDisplayableData(self, descr = None):
     if descr is not None:
         selected = [ vo_converters.makeVehicleVO(g_itemsCache.items.getItemByCD(int(item))) for item in descr ]
     else:
         selected = None
     data = vo_converters.getUnitRosterModel(selected, tuple(), False)
     data.update({'toolTipType': 'cyberSportAutoSearchVehicles'})
     return data
Beispiel #14
0
 def getDisplayableData(self, playerID):
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         functional = dispatcher.getPrbFunctional()
         playerInfo = functional.getPlayerInfo(pID=playerID)
         if playerInfo.isVehicleSpecified():
             return vo_converters.makeVehicleVO(playerInfo.getVehicle())
     super(SquadSlotSelectedToolTipData, self).getDisplayableData()
Beispiel #15
0
 def getDisplayableData(self, playerID):
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         functional = dispatcher.getPrbFunctional()
         playerInfo = functional.getPlayerInfo(pID=playerID)
         if playerInfo.isVehicleSpecified():
             return vo_converters.makeVehicleVO(playerInfo.getVehicle())
     super(SquadSlotSelectedToolTipData, self).getDisplayableData()
 def __makeVehicleVO(vehicle):
     if vehicle is None:
         return
     else:
         vo = makeVehicleVO(vehicle)
         vo.update({
             'type':
             '{}_elite'.format(vehicle.type)
             if vehicle.isPremium else vehicle.type
         })
         return vo
 def __makeInitialSlotData(self, currentSlotSetting):
     if currentSlotSetting is None:
         return (makeFiltersVO([], [], self.__convertLevelsRange(self.__levelsRange)), RANGE_SELECTOR_TAB_ID)
     elif currentSlotSetting.selectedVehicle > 0:
         vehicle = g_itemsCache.items.getItemByCD(int(currentSlotSetting.selectedVehicle))
         return (makeVehicleVO(vehicle, self.__convertLevelsRange(self.__levelsRange), self.__vehicleTypes), VEHICLE_SELECTOR_TAB_ID)
     elif currentSlotSetting.nationIDRange or currentSlotSetting.vTypeRange or currentSlotSetting.vLevelRange:
         return (makeFiltersVO(currentSlotSetting.nationIDRange, currentSlotSetting.vTypeRange, self.__convertLevelsRange(currentSlotSetting.vLevelRange)), RANGE_SELECTOR_TAB_ID)
     else:
         return (None, None)
         return
Beispiel #18
0
 def __makeInitialSlotData(self, currentSlotSetting):
     if currentSlotSetting is None:
         return (None, None)
     elif currentSlotSetting.selectedVehicle > 0:
         vehicle = self.itemsCache.items.getItemByCD(int(currentSlotSetting.selectedVehicle))
         return (makeVehicleVO(vehicle, self.__convertLevelsRange(self._levelsRange), self.__vehicleTypes), VEHICLE_SELECTOR_TAB_ID)
     elif currentSlotSetting.nationIDRange or currentSlotSetting.vTypeRange or currentSlotSetting.vLevelRange:
         levelsRange = self.__convertLevelsRange(currentSlotSetting.vLevelRange or self._levelsRange)
         return (makeFiltersVO(currentSlotSetting.nationIDRange, currentSlotSetting.vTypeRange, levelsRange), RANGE_SELECTOR_TAB_ID)
     else:
         return (None, None)
 def updateData(self):
     if not self.getFilters().get('compatibleOnly', True) or self.__vehicles is None:
         vehicles = self._updateData(g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY), self.__levelsRange)
     else:
         vehicles = self._updateData(self.__vehicles, self.__levelsRange)
     if self.__selectedVehicles is not None:
         vehicleGetter = g_itemsCache.items.getItemByCD
         selected = [ makeVehicleVO(vehicleGetter(int(item))) for item in self.__selectedVehicles ]
     else:
         selected = None
     self.as_setListDataS(vehicles, selected)
 def __setTradeOffVehicle(self, _=None):
     self.tradeInVehicleToSell = self.tradeIn.getSelectedVehicleToSell()
     tradeOffVehicleHtml = moneyWithIcon(self.tradeInVehicleToSell.tradeOffPrice, currType=Currency.GOLD)
     tradeOffVehicleStatus = i18n.makeString(DIALOGS.BUYVEHICLEWINDOW_TRADEIN_INFO_SAVING, cost=tradeOffVehicleHtml)
     tradeOffVehicleVo = makeVehicleVO(self.tradeInVehicleToSell)
     tradeOffVehicleVo['actionPrice'] = self._getItemPriceActionData(self.tradeInVehicleToSell)
     tradeOffData = {'vehicleVo': tradeOffVehicleVo,
      'price': self.tradeInVehicleToSell.tradeOffPrice.getSignValue(Currency.GOLD),
      'status': tradeOffVehicleStatus}
     self.as_updateTradeOffVehicleS(tradeOffData)
     self.as_setTradeInWarningMessagegeS(i18n.makeString(DIALOGS.TRADEINCONFIRMATION_MESSAGE, vehName=self.tradeInVehicleToSell.userName, addition=''))
Beispiel #21
0
 def _updateData(self, allVehicles, levelsRange):
     criteria = REQ_CRITERIA.EMPTY
     criteria |= ~REQ_CRITERIA.VEHICLE.EXPIRED_IGR_RENT
     criteria |= ~REQ_CRITERIA.VEHICLE.DISABLED_IN_PREM_IGR
     if not self.showNotReadyVehicles:
         criteria |= REQ_CRITERIA.VEHICLE.READY
     if self.__filters:
         if self.__filters['nation'] != -1:
             criteria |= REQ_CRITERIA.NATIONS([self.__filters['nation']])
         if self.__filters['vehicleType'] != 'none':
             criteria |= REQ_CRITERIA.VEHICLE.CLASSES([self.__filters['vehicleType']])
         if self.__filters['isMain']:
             criteria |= REQ_CRITERIA.VEHICLE.FAVORITE
         if self.__filters['level'] != -1:
             criteria |= REQ_CRITERIA.VEHICLE.LEVELS([self.__filters['level']])
     filteredVehicles = allVehicles.filter(criteria)
     if self.__filters.get('compatibleOnly', True):
         return [ vo for vo in [ makeVehicleVO(v, levelsRange) for v in filteredVehicles.values() ] if vo.get('enabled', True) ]
     else:
         return [ makeVehicleVO(v, levelsRange) for v in filteredVehicles.values() ]
Beispiel #22
0
 def getDisplayableData(self, index, unitIdx=None):
     if unitIdx is not None:
         unitIdx = int(unitIdx)
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         functional = dispatcher.getUnitFunctional()
         _, unit = functional.getUnit(unitIdx)
         accountDBID = unit.getMembers()[index]["accountDBID"]
         vehicles = unit.getVehicles()[accountDBID]
         if vehicles:
             vehicle = g_itemsCache.items.getItemByCD(vehicles[0].vehTypeCompDescr)
             return vo_converters.makeVehicleVO(vehicle, functional.getRosterSettings().getLevelsRange())
     return super(CybersportSlotSelectedToolTipData, self).getDisplayableData(index, unitIdx)
 def getDisplayableData(self, index, unitMgrID=None):
     if unitMgrID is not None:
         unitMgrID = int(unitMgrID)
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         entity = dispatcher.getEntity()
         _, unit = entity.getUnit(unitMgrID)
         accountDBID = unit.getMembers()[index]['accountDBID']
         vehicles = unit.getVehicles()[accountDBID]
         if vehicles:
             vehicle = self.itemsCache.items.getItemByCD(vehicles[0].vehTypeCompDescr)
             return vo_converters.makeVehicleVO(vehicle, entity.getRosterSettings().getLevelsRange())
     return super(CybersportSlotSelectedToolTipData, self).getDisplayableData(index, unitMgrID)
Beispiel #24
0
 def getDisplayableData(self, index, unitIdx = None):
     if unitIdx is not None:
         unitIdx = int(unitIdx)
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         functional = dispatcher.getUnitFunctional()
         _, unit = functional.getUnit(unitIdx)
         accountDBID = unit.getMembers()[index]['accountDBID']
         vehicles = unit.getVehicles()[accountDBID]
         if vehicles:
             vehicle = g_itemsCache.items.getItemByCD(vehicles[0].vehTypeCompDescr)
             return vo_converters.makeVehicleVO(vehicle)
     super(SquadSlotSelectedToolTipData, self).getDisplayableData()
     return
Beispiel #25
0
 def getDisplayableData(self, index, unitIdx=None):
     if unitIdx is not None:
         unitIdx = int(unitIdx)
     dispatcher = g_prbLoader.getDispatcher()
     if dispatcher is not None:
         entity = dispatcher.getEntity()
         _, unit = entity.getUnit(unitIdx)
         accountDBID = unit.getMembers()[index]['accountDBID']
         vehicles = unit.getVehicles()[accountDBID]
         if vehicles:
             vehicle = g_itemsCache.items.getItemByCD(
                 vehicles[0].vehTypeCompDescr)
             return vo_converters.makeVehicleVO(vehicle)
     super(SquadSlotSelectedToolTipData, self).getDisplayableData()
     return
 def __makeCurrentSlotData(self, value):
     currentSlot = [value[0], value[1]]
     data = value[2]
     if isinstance(data, long):
         currentSlot.append(makeVehicleVO(g_itemsCache.items.getItemByCD(int(data)), self.__levelsRange))
     elif data is not None:
         if len(data.nationIDRange) == 0 and len(data.vTypeRange) == 0 and len(data.vLevelRange) == 0:
             currentSlot.append(None)
         else:
             currentSlot.append({'nationIDRange': data.nationIDRange,
              'vTypeRange': data.vTypeRange,
              'vLevelRange': data.vLevelRange})
     else:
         currentSlot.append(None)
     return currentSlot
 def __addAditionalSlot(self, slotSettins):
     row = slotSettins[0]
     column = slotSettins[1]
     vehicleCD = self.__currentSlot['intCD']
     vehicle = self.itemsCache.items.getItemByCD(int(vehicleCD))
     if vehicle.hasNationGroup and vehicle.activeInNationGroup:
         addVehCD = iterVehTypeCDsInNationGroup(vehicleCD).next()
         vehicle = self.itemsCache.items.getItemByCD(addVehCD)
         addSlot = makeVehicleVO(
             vehicle, self.__convertLevelsRange(self._levelsRange),
             self.__vehicleTypes)
         slotSettings = [row, 1 - column, addSlot]
         self.fireEvent(
             CSRosterSlotSettingsWindow(
                 CSRosterSlotSettingsWindow.APPLY_SLOT_SETTINGS,
                 slotSettings))
Beispiel #28
0
 def __updateAutoSearchVehicle(self, vehsIntCD):
     if len(vehsIntCD):
         vehIntCD = vehsIntCD[0]
         vehicle = g_itemsCache.items.getItemByCD(vehIntCD)
         levelsRange = self.unitFunctional.getRosterSettings().getLevelsRange()
         if vehicle.level not in levelsRange:
             isReadyVehicle = False
             warnTooltip = TOOLTIPS.CYBERSPORT_INTRO_SELECTEDVEHICLEWARN_INCOMPATIBLELEVEL
         elif vehicle.type not in _ACCEPTED_VEH_TYPES:
             isReadyVehicle = False
             warnTooltip = TOOLTIPS.CYBERSPORT_INTRO_SELECTEDVEHICLEWARN_INCOMPATIBLETYPE
         else:
             warnTooltip, isReadyVehicle = '', vehicle.isReadyToPrebattle()
         self.as_setSelectedVehicleS(makeVehicleVO(vehicle), isReadyVehicle, warnTooltip)
     else:
         self.as_setNoVehiclesS(TOOLTIPS.CYBERSPORT_NOVEHICLESINHANGAR)
Beispiel #29
0
 def onUnitVehicleChanged(self, dbID, vInfo):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if not vInfo.isEmpty():
             vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange(), isCurrentPlayer=pInfo.isCurrentPlayer())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
Beispiel #30
0
    def getDisplayableData(self, index, unitIdx=None):
        if unitIdx is not None:
            unitIdx = int(unitIdx)
        dispatcher = g_prbLoader.getDispatcher()
        if dispatcher is not None:
            functional = dispatcher.getUnitFunctional()
            try:
                _, unit = functional.getUnit(unitIdx)
            except ValueError:
                LOG_ERROR("Unit is not exists")
                return {}

            accountDBID = unit._members[index]["accountDBID"]
            vehicle = g_itemsCache.items.getItemByCD(unit._vehicles[accountDBID]["vehTypeCompDescr"])
            return vo_converters.makeVehicleVO(vehicle, functional.getRosterSettings().getLevelsRange())
        super(CybersportSlotSelectedToolTipData, self).getDisplayableData(index, unitIdx)
 def __updateAutoSearchVehicle(self, vehsIntCD):
     if len(vehsIntCD):
         vehIntCD = vehsIntCD[0]
         vehicle = g_itemsCache.items.getItemByCD(vehIntCD)
         levelsRange = self.unitFunctional.getRosterSettings(
         ).getLevelsRange()
         if vehicle.level not in levelsRange:
             isReadyVehicle = False
             warnTooltip = TOOLTIPS.CYBERSPORT_INTRO_SELECTEDVEHICLEWARN_INCOMPATIBLELEVEL
         elif vehicle.type not in _ACCEPTED_VEH_TYPES:
             isReadyVehicle = False
             warnTooltip = TOOLTIPS.CYBERSPORT_INTRO_SELECTEDVEHICLEWARN_INCOMPATIBLETYPE
         else:
             warnTooltip, isReadyVehicle = '', vehicle.isReadyToPrebattle()
         self.as_setSelectedVehicleS(makeVehicleVO(vehicle), isReadyVehicle,
                                     warnTooltip)
     else:
         self.as_setNoVehiclesS(TOOLTIPS.CYBERSPORT_NOVEHICLESINHANGAR)
 def onUnitVehicleChanged(self, dbID, vInfo):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if not vInfo.isEmpty():
             vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange(), isCreator=pInfo.isCreator(), isCurrentPlayer=pInfo.isCurrentPlayer())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
     if pInfo.isCreator() or pInfo.isCurrentPlayer():
         self._setActionButtonState()
 def onUnitVehiclesChanged(self, dbID, vInfos):
     pInfo = self.prbEntity.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if vInfos and not vInfos[0].isEmpty():
             vInfo = vInfos[0]
             vehicleVO = makeVehicleVO(self.itemsCache.items.getItemByCD(vInfo.vehTypeCD), self.prbEntity.getRosterSettings().getLevelsRange(), isCurrentPlayer=pInfo.isCurrentPlayer())
             slotCost = vInfo.vehLevel
         else:
             slotState = self.prbEntity.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
     if pInfo.isCurrentPlayer() or pInfo.isCommander():
         self._setActionButtonState()
     return
    def updateData(self):
        if not self.getFilters().get('compatibleOnly', True) or self.__vehicles is None:
            vehicleVOs = self._updateData(g_itemsCache.items.getVehicles(REQ_CRITERIA.INVENTORY), self.__levelsRange, self.__vehicleTypes)
        else:
            vehicleVOs = self._updateData(self.__vehicles, self.__levelsRange, self.__vehicleTypes)
        if self.__selectedVehicles is not None:
            vehicleGetter = g_itemsCache.items.getItemByCD
            selected = [ makeVehicleVO(vehicleGetter(int(item))) for item in self.__selectedVehicles ]
        else:
            selected = None
        for vehicleVO in vehicleVOs:
            if self.__vehicles is not None and vehicleVO['intCD'] not in self.__vehicles.keys() and vehicleVO['enabled']:
                vehicleVO['tooltip'] = TOOLTIPS.CYBERSPORT_VEHICLESELECTOR_BADVEHICLE
                vehicleVO['enabled'] = False
                vehicleVO['showAlert'] = True
                vehicleVO['alertSource'] = RES_ICONS.MAPS_ICONS_LIBRARY_GEAR

        self.as_setListDataS(vehicleVOs, selected)
        return
Beispiel #35
0
    def getDisplayableData(self, index, unitIdx=None):
        if unitIdx is not None:
            unitIdx = int(unitIdx)
        dispatcher = g_prbLoader.getDispatcher()
        if dispatcher is not None:
            functional = dispatcher.getUnitFunctional()
            try:
                _, unit = functional.getUnit(unitIdx)
            except ValueError:
                LOG_ERROR('Unit is not exists')
                return {}

            accountDBID = unit._members[index]['accountDBID']
            vehicle = g_itemsCache.items.getItemByCD(
                unit._vehicles[accountDBID]['vehTypeCompDescr'])
            return vo_converters.makeVehicleVO(
                vehicle,
                functional.getRosterSettings().getLevelsRange())
        super(CybersportSlotSelectedToolTipData,
              self).getDisplayableData(index, unitIdx)
Beispiel #36
0
 def __makeCurrentSlotData(self, value):
     currentSlot = [value[0], value[1]]
     data = value[2]
     if isinstance(data, long):
         currentSlot.append(
             makeVehicleVO(g_itemsCache.items.getItemByCD(int(data)),
                           self.__levelsRange, self.__vehicleTypes))
     elif data is not None:
         if len(data.nationIDRange) == 0 and len(
                 data.vTypeRange) == 0 and len(data.vLevelRange) == 0:
             currentSlot.append(None)
         else:
             currentSlot.append({
                 'nationIDRange': data.nationIDRange,
                 'vTypeRange': data.vTypeRange,
                 'vLevelRange': data.vLevelRange
             })
     else:
         currentSlot.append(None)
     return currentSlot
Beispiel #37
0
 def onUnitVehicleChanged(self, dbID, vInfo):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if not vInfo.isEmpty():
             vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         unitStats = functional.getStats()
         canDoAction, restriction = functional.validateLevels(stats=unitStats)
         self.as_setTotalLabelS(canDoAction, vo_converters.makeTotalLevelLabel(unitStats, restriction), unitStats.curTotalLevel)
     if pInfo.isCurrentPlayer() or functional.getPlayerInfo().isCreator():
         self._setActionButtonState()
 def onUnitVehiclesChanged(self, dbID, vInfos):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo(dbID=dbID)
     if pInfo.isInSlot:
         slotIdx = pInfo.slotIdx
         if vInfos and not vInfos[0].isEmpty():
             vInfo = vInfos[0]
             vehicleVO = makeVehicleVO(g_itemsCache.items.getItemByCD(vInfo.vehTypeCD), functional.getRosterSettings().getLevelsRange())
             slotCost = vInfo.vehLevel
         else:
             slotState = functional.getSlotState(slotIdx)
             vehicleVO = None
             if slotState.isClosed:
                 slotCost = settings.UNIT_CLOSED_SLOT_COST
             else:
                 slotCost = 0
         self.as_setMemberVehicleS(slotIdx, slotCost, vehicleVO)
         self.__updateTotal()
     if pInfo.isCurrentPlayer() or functional.getPlayerInfo().isCreator():
         self._setActionButtonState()
     return
 def _makeVehicleVOAction(self, vehicle):
     return makeVehicleVO(vehicle, self._levelsRange, self.__vehicleTypes)
Beispiel #40
0
 def _populate(self):
     super(EliteWindow, self)._populate()
     self.as_setVehicleS(makeVehicleVO(g_itemsCache.items.getItemByCD(self.vehInvID)))
Beispiel #41
0
 def _populate(self):
     super(EliteWindow, self)._populate()
     self.as_setVehicleS(makeVehicleVO(g_itemsCache.items.getItemByCD(self.vehInvID)))
 def _makeVehicleVOAction(self, vehicle):
     return makeVehicleVO(vehicle, self._levelsRange, self.__vehicleTypes)