Ejemplo n.º 1
0
 def getCommonData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     rate = items.shop.freeXPToTManXPRate
     if rate:
         toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate)
         enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0
     else:
         enoughFreeXPForTeaching = False
     nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     bonuses = tankman.realRoleLevel[1]
     modifiers = []
     if bonuses[0]:
         modifiers.append({'id': 'fromCommander',
          'val': bonuses[0]})
     if bonuses[1]:
         modifiers.append({'id': 'fromSkills',
          'val': bonuses[1]})
     if bonuses[2] or bonuses[3]:
         modifiers.append({'id': 'fromEquipment',
          'val': bonuses[2] + bonuses[3]})
     if bonuses[4]:
         modifiers.append({'id': 'penalty',
          'val': bonuses[4]})
     callback({'tankman': packTankman(tankman),
      'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None,
      'nativeVehicle': packVehicle(nativeVehicle),
      'isOpsLocked': isLocked or g_currentVehicle.isLocked(),
      'lockMessage': reason,
      'modifiers': modifiers,
      'enoughFreeXPForTeaching': enoughFreeXPForTeaching})
Ejemplo n.º 2
0
    def __updateAmmo(self, shellsData = None, historicalBattleID = -1):
        ammo = {'gunName': '',
         'maxAmmo': 0,
         'defaultAmmoCount': 0,
         'vehicleLocked': True,
         'shells': [],
         'stateWarning': 0}
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            default_ammo_count = 0
            default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells))
            isAmmoFull = vehicle.isAmmoFull or historicalBattleID != -1
            stateWarning = vehicle.isBroken or not isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull()
            for compactDescr, count in default_ammo.iteritems():
                default_ammo_count += count

            ammo.update({'gunName': vehicle.gun.longUserName,
             'maxAmmo': vehicle.ammoMaxSize,
             'defaultAmmoCount': default_ammo_count,
             'vehicleLocked': g_currentVehicle.isLocked(),
             'stateWarning': int(stateWarning)})
            if shellsData is None:
                shellsData = map(lambda shell: (shell, shell.count), vehicle.shells)
            shells = ammo.get('shells')
            for shell, count in shellsData:
                shells.append({'id': str(shell.intCD),
                 'type': shell.type,
                 'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                 'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                 'count': count,
                 'historicalBattleID': historicalBattleID})

        self.as_setAmmoS(ammo)
Ejemplo n.º 3
0
 def getCommonData(self, callback):
     """
     Returns common personal case data for tankman, tankman's vehicles,
     message, flags and so on.
     """
     tankman = g_itemsCache.items.getTankman(self.tmanInvID)
     nativeVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleDescr.type.compactDescr)
     (isLocked, reason,) = self.__getTankmanLockMessage(currentVehicle)
     bonuses = tankman.realRoleLevel[1]
     modifiers = []
     if bonuses[0]:
         modifiers.append({'id': 'fromCommander',
          'val': bonuses[0]})
     if bonuses[1]:
         modifiers.append({'id': 'fromSkills',
          'val': bonuses[1]})
     if bonuses[2] or bonuses[3]:
         modifiers.append({'id': 'fromEquipment',
          'val': bonuses[2] + bonuses[3]})
     if bonuses[4]:
         modifiers.append({'id': 'penalty',
          'val': bonuses[4]})
     callback({'tankman': packTankman(tankman),
      'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None,
      'nativeVehicle': packVehicle(nativeVehicle),
      'isOpsLocked': isLocked or g_currentVehicle.isLocked(),
      'lockMessage': reason,
      'modifiers': modifiers})
Ejemplo n.º 4
0
 def update(self, fullUpdate=True):
     if fullUpdate:
         clearLastSlotAction(self.viewModel)
     self.viewModel.setIsMaintenanceEnabled(not g_currentVehicle.isLocked())
     self.viewModel.setIsDisabled(self._getIsDisabled())
     self._ammunitionPanel.update(g_currentVehicle.item,
                                  fullUpdate=fullUpdate)
Ejemplo n.º 5
0
 def getCommonData(self, callback):
     """
     Returns common personal case data for tankman, tankman's vehicles,
     message, flags and so on.
     """
     tankman = g_itemsCache.items.getTankman(self.tmanInvID)
     nativeVehicle = g_itemsCache.items.getItemByCD(
         tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = g_itemsCache.items.getItemByCD(
             tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     callback({
         'tankman':
         g_itemSerializer.pack(tankman),
         'currentVehicle':
         g_itemSerializer.pack(currentVehicle)
         if currentVehicle is not None else None,
         'nativeVehicle':
         g_itemSerializer.pack(nativeVehicle),
         'isOpsLocked':
         isLocked or g_currentVehicle.isLocked(),
         'lockMessage':
         reason
     })
     return
Ejemplo n.º 6
0
 def dropCurrentItemInSection(self, section, kind):
     if g_currentVehicle.isLocked():
         SystemMessages.pushI18nMessage(
             SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED,
             type=SystemMessages.SM_TYPE.Error)
         return
     elif g_currentVehicle.isBroken():
         SystemMessages.pushI18nMessage(
             SYSTEM_MESSAGES.customization_vehicle(
                 g_currentVehicle.item.getState()),
             type=SystemMessages.SM_TYPE.Error)
         return
     else:
         dialog = 'customization/{0:>s}Drop'.format(section)
         isConfirmed = yield DialogsInterface.showI18nConfirmDialog(dialog)
         if isConfirmed:
             interface = self.__interfaces.get(section)
             if interface is not None:
                 self.__returnHangar = False
                 self.__lockUpdate = True
                 Waiting.show('customizationDrop')
                 interface.drop(g_currentVehicle.invID, kind)
             else:
                 LOG_ERROR('Drop operation, section not found', section)
         return
Ejemplo n.º 7
0
    def execute(self):
        if self._entity.isCommander():
            func = self._entity
            fullData = func.getUnitFullData(unitMgrID=func.getID())
            notReadyCount = 0
            for slot in fullData.slotsIterator:
                slotPlayer = slot.player
                if slotPlayer:
                    if slotPlayer.isInArena(
                    ) or fullData.playerInfo.isInSearch(
                    ) or fullData.playerInfo.isInQueue():
                        DialogsInterface.showI18nInfoDialog(
                            'squadHavePlayersInBattle', lambda result: None)
                        return True
                    if not slotPlayer.isReady:
                        notReadyCount += 1

            if not fullData.playerInfo.isReady:
                notReadyCount -= 1
            if fullData.stats.occupiedSlotsCount == 1:
                DialogsInterface.showDialog(
                    I18nConfirmDialogMeta('squadHaveNoPlayers'),
                    self._confirmCallback)
                return True
            if notReadyCount > 0:
                if notReadyCount == 1:
                    DialogsInterface.showDialog(
                        I18nConfirmDialogMeta('squadHaveNotReadyPlayer'),
                        self._confirmCallback)
                    return True
                DialogsInterface.showDialog(
                    I18nConfirmDialogMeta('squadHaveNotReadyPlayers'),
                    self._confirmCallback)
                return True
            if not g_currentVehicle.isLocked(
            ) and not fullData.playerInfo.isReady:
                _, unit = self._entity.getUnit()
                playerVehicles = unit.getVehicles()
                if playerVehicles:
                    commanderLevel = g_currentVehicle.item.level
                    lowerBound, upperBound = self._entity.getSquadLevelBounds()
                    minLevel = max(MIN_VEHICLE_LEVEL,
                                   commanderLevel + lowerBound)
                    maxLevel = min(MAX_VEHICLE_LEVEL,
                                   commanderLevel + upperBound)
                    levelRange = range(minLevel, maxLevel + 1)
                    for _, unitVehicles in playerVehicles.iteritems():
                        for vehicle in unitVehicles:
                            if vehicle.vehLevel not in levelRange:
                                DialogsInterface.showDialog(
                                    I18nConfirmDialogMeta(
                                        'squadHaveNoPlayers'),
                                    self._confirmCallback)
                                return True

            self._setCreatorReady()
        else:
            self._entity.togglePlayerReadyAction(True)
        return True
Ejemplo n.º 8
0
 def processReturnCrew(self, print_message=True):
     if not g_currentVehicle.isInHangar() or g_currentVehicle.isInBattle(
     ) or g_currentVehicle.isLocked() or g_currentVehicle.isCrewFull():
         return
     result = yield TankmanReturn(g_currentVehicle.item).request()
     if len(result.userMsg) and print_message:
         SystemMessages.pushI18nMessage(result.userMsg,
                                        type=result.sysMsgType)
Ejemplo n.º 9
0
 def __onCurrentVehicleChanged(self, *args):
     if g_currentVehicle.isLocked() or not g_currentVehicle.isPresent():
         self.destroy()
     else:
         self.populateTechnicalMaintenance()
         if g_currentVehicle.isPresent() and g_currentVehicle.item.intCD != self.__currentVehicleId:
             self.populateTechnicalMaintenanceEquipmentDefaults()
             self.__currentVehicleId = g_currentVehicle.item.intCD
Ejemplo n.º 10
0
 def __cv_onChanged(self):
     if not g_currentVehicle.isReadyToFight():
         if g_currentVehicle.isCrewFull(
         ) and not g_currentVehicle.isBroken():
             self.closeWindow()
     else:
         self.as_setActionsLockedS(g_currentVehicle.isLocked()
                                   or g_currentVehicle.isBroken())
Ejemplo n.º 11
0
 def __onCurrentVehicleChanged(self, *args):
     if g_currentVehicle.isLocked() or not g_currentVehicle.isPresent():
         self.destroy()
     else:
         self.populateTechnicalMaintenance()
         if g_currentVehicle.isPresent() and g_currentVehicle.item.intCD != self.__currentVehicleId:
             self.populateTechnicalMaintenanceEquipmentDefaults()
             self.__currentVehicleId = g_currentVehicle.item.intCD
Ejemplo n.º 12
0
 def __cv_onChanged(self, *args):
     if self.__steps:
         return
     if not g_currentVehicle.isReadyToFight() and not g_currentVehicle.isReadyToPrebattle():
         if g_currentVehicle.isCrewFull() and not g_currentVehicle.isBroken():
             self.closeWindow()
     else:
         self.as_setActionsLockedS(g_currentVehicle.isLocked() or g_currentVehicle.isBroken() or g_currentVehicle.isDisabledInRent())
Ejemplo n.º 13
0
 def __finishInitData(self):
     if not self.__onceDataInited:
         self.__requestMoney()
         self.as_onInitS(self._getSections())
         if g_currentVehicle.isLocked() or g_currentVehicle.isBroken():
             self.as_setActionsLockedS(True)
         self.__setPreviewMode()
         self.__onceDataInited = True
Ejemplo n.º 14
0
 def __finishInitData(self):
     if not self.__onceDataInited:
         self.__requestMoney()
         self.as_onInitS(self._getSections())
         if g_currentVehicle.isLocked() or g_currentVehicle.isBroken():
             self.as_setActionsLockedS(True)
         self.__setPreviewMode()
         self.__onceDataInited = True
 def update(self, fullUpdate=True):
     if fullUpdate:
         clearLastSlotAction(self.viewModel)
     self.viewModel.setIsMaintenanceEnabled(not g_currentVehicle.isLocked())
     if not self.__canChangeVehicle():
         self.viewModel.setIsDisabled(True)
     else:
         self.viewModel.setIsDisabled(self._getIsDisabled())
     self._ammunitionPanel.update(self.vehItem, fullUpdate=fullUpdate)
Ejemplo n.º 16
0
 def __checkCurrent(self):
     isOn = False
     isLocked = False
     isCrewFull = False
     if g_currentVehicle.isPresent():
         isOn = self.isOn()
         isLocked = g_currentVehicle.isLocked()
         isCrewFull = g_currentVehicle.isCrewFull()
     self._setFlagValue(self.__isLockedFlagID, isLocked)
     self._setFlagValue(self.__isCrewFullFlagID, isCrewFull)
     self.toggle(isOn=isOn)
Ejemplo n.º 17
0
 def __checkCurrent(self):
     isOn = False
     isLocked = False
     isCrewFull = False
     if g_currentVehicle.isPresent():
         isOn = self.isOn()
         isLocked = g_currentVehicle.isLocked()
         isCrewFull = g_currentVehicle.isCrewFull()
     self._setFlagValue(self.__isLockedFlagID, isLocked)
     self._setFlagValue(self.__isCrewFullFlagID, isCrewFull)
     self.toggle(isOn=isOn)
Ejemplo n.º 18
0
def onXfwCommand(cmd, *args):
    try:
        if cmd == COMMANDS.PUT_PREVIOUS_CREW:
            if g_currentVehicle.isInHangar() and not (
                    g_currentVehicle.isCrewFull()
                    or g_currentVehicle.isInBattle()
                    or g_currentVehicle.isLocked()):
                PutPreviousCrew(g_currentVehicle, False)
            return (None, True)
    except Exception, ex:
        err(traceback.format_exc())
        return (None, True)
Ejemplo n.º 19
0
 def __cv_onChanged(self, *args):
     if self.__steps:
         return
     if not g_currentVehicle.isReadyToFight(
     ) and not g_currentVehicle.isReadyToPrebattle():
         if g_currentVehicle.isCrewFull(
         ) and not g_currentVehicle.isBroken():
             self.closeWindow()
     else:
         self.as_setActionsLockedS(g_currentVehicle.isLocked()
                                   or g_currentVehicle.isBroken()
                                   or g_currentVehicle.isDisabledInRent())
Ejemplo n.º 20
0
 def doAction(self, action = None, dispatcher = None):
     result = False
     if not g_currentVehicle.isLocked() and not g_currentVehicle.isBroken():
         if action is not None:
             actionName = action.actionName
             if actionName in self.CREATE_PRB_BY_ACTION:
                 from gui.prb_control.functional import createPrbEntry
                 entry = createPrbEntry(self.CREATE_PRB_BY_ACTION[actionName])
                 result = entry.doAction(action, dispatcher)
     else:
         result = True
         SystemMessages.pushI18nMessage(MENU.HANGAR_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error)
     return result
Ejemplo n.º 21
0
 def getCommonData(self, callback):
     items = self.itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     rate = items.shop.freeXPToTManXPRate
     if rate:
         toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate)
         enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0
     else:
         enoughFreeXPForTeaching = False
     nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     td = tankman.descriptor
     changeRoleEnabled = tankmen.tankmenGroupCanChangeRole(td.nationID, td.gid, td.isPremium)
     if changeRoleEnabled:
         tooltipChangeRole = ''
     else:
         tooltipChangeRole = makeTooltip(TOOLTIPS.CREW_ROLECHANGEFORBID_HEADER, TOOLTIPS.CREW_ROLECHANGEFORBID_TEXT)
     showDocumentTab = not td.getRestrictions().isPassportReplacementForbidden()
     bonuses = tankman.realRoleLevel[1]
     modifiers = []
     if bonuses[0]:
         modifiers.append({'id': 'fromCommander',
          'val': bonuses[0]})
     if bonuses[1]:
         modifiers.append({'id': 'fromSkills',
          'val': bonuses[1]})
     if bonuses[2] or bonuses[3]:
         modifiers.append({'id': 'fromEquipment',
          'val': bonuses[2] + bonuses[3]})
     if bonuses[4]:
         modifiers.append({'id': 'penalty',
          'val': bonuses[4]})
     callback({'tankman': packTankman(tankman),
      'currentVehicle': packVehicle(currentVehicle) if currentVehicle is not None else None,
      'nativeVehicle': packVehicle(nativeVehicle),
      'isOpsLocked': isLocked or g_currentVehicle.isLocked(),
      'lockMessage': reason,
      'modifiers': modifiers,
      'enoughFreeXPForTeaching': enoughFreeXPForTeaching,
      'tabsData': self.getTabsButtons(showDocumentTab),
      'tooltipDismiss': TOOLTIPS.BARRACKS_TANKMEN_DISMISS,
      'tooltipUnload': TOOLTIPS.BARRACKS_TANKMEN_UNLOAD,
      'dismissEnabled': True,
      'unloadEnabled': True,
      'changeRoleEnabled': changeRoleEnabled,
      'tooltipChangeRole': tooltipChangeRole})
     return
Ejemplo n.º 22
0
    def execute(self, customData):
        if self._functional.isCreator():
            func = self._functional
            fullData = func.getUnitFullData(unitIdx=self._functional.getUnitIdx())
            if fullData is None:
                return {}
            _, _, unitStats, pInfo, slotsIter = fullData
            notReadyCount = 0
            for slot in slotsIter:
                slotPlayer = slot.player
                if slotPlayer:
                    if slotPlayer.isInArena() or slotPlayer.isInPreArena() or pInfo.isInSearch() or pInfo.isInQueue():
                        DialogsInterface.showI18nInfoDialog("squadHavePlayersInBattle", lambda result: None)
                        return True
                    if not slotPlayer.isReady:
                        notReadyCount += 1

            if not pInfo.isReady:
                notReadyCount -= 1
            if unitStats.occupiedSlotsCount == 1:
                DialogsInterface.showDialog(I18nConfirmDialogMeta("squadHaveNoPlayers"), self._setCreatorReady)
                return True
            if notReadyCount > 0:
                if notReadyCount == 1:
                    DialogsInterface.showDialog(I18nConfirmDialogMeta("squadHaveNotReadyPlayer"), self._setCreatorReady)
                    return True
                DialogsInterface.showDialog(I18nConfirmDialogMeta("squadHaveNotReadyPlayers"), self._setCreatorReady)
                return True
            if not g_currentVehicle.isLocked():
                _, unit = self._functional.getUnit()
                playerVehicles = unit.getVehicles()
                if playerVehicles:
                    commanderLevel = g_currentVehicle.item.level
                    lowerBound, upperBound = self._functional.getSquadLevelBounds()
                    minLevel = max(MIN_VEHICLE_LEVEL, commanderLevel + lowerBound)
                    maxLevel = min(MAX_VEHICLE_LEVEL, commanderLevel + upperBound)
                    levelRange = range(minLevel, maxLevel + 1)
                    for _, unitVehicles in playerVehicles.iteritems():
                        for vehicle in unitVehicles:
                            if vehicle.vehLevel not in levelRange:
                                DialogsInterface.showDialog(
                                    I18nConfirmDialogMeta("squadHaveNoPlayers"), self._setCreatorReady
                                )
                                return True

            self._setCreatorReady(True)
        else:
            self._functional.togglePlayerReadyAction(True)
        return True
Ejemplo n.º 23
0
 def doAction(self, action=None, dispatcher=None):
     result = False
     if not g_currentVehicle.isLocked() and not g_currentVehicle.isBroken():
         if action is not None:
             actionName = action.actionName
             if actionName in self.CREATE_PRB_BY_ACTION:
                 from gui.prb_control.functional import createPrbEntry
                 entry = createPrbEntry(
                     self.CREATE_PRB_BY_ACTION[actionName])
                 result = entry.doAction(action, dispatcher)
     else:
         result = True
         SystemMessages.pushI18nMessage(MENU.HANGAR_VEHICLE_LOCKED,
                                        type=SystemMessages.SM_TYPE.Error)
     return result
Ejemplo n.º 24
0
 def getCommonData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     rate = items.shop.freeXPToTManXPRate
     if rate:
         toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate)
         enoughFreeXPForTeaching = items.stats.freeXP - max(
             1, toNextPrcLeft / rate) >= 0
     else:
         enoughFreeXPForTeaching = False
     nativeVehicle = items.getItemByCD(
         tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = items.getItemByCD(
             tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     bonuses = tankman.realRoleLevel[1]
     modifiers = []
     if bonuses[0]:
         modifiers.append({'id': 'fromCommander', 'val': bonuses[0]})
     if bonuses[1]:
         modifiers.append({'id': 'fromSkills', 'val': bonuses[1]})
     if bonuses[2] or bonuses[3]:
         modifiers.append({
             'id': 'fromEquipment',
             'val': bonuses[2] + bonuses[3]
         })
     if bonuses[4]:
         modifiers.append({'id': 'penalty', 'val': bonuses[4]})
     callback({
         'tankman':
         packTankman(tankman),
         'currentVehicle':
         packVehicle(currentVehicle)
         if currentVehicle is not None else None,
         'nativeVehicle':
         packVehicle(nativeVehicle),
         'isOpsLocked':
         isLocked or g_currentVehicle.isLocked(),
         'lockMessage':
         reason,
         'modifiers':
         modifiers,
         'enoughFreeXPForTeaching':
         enoughFreeXPForTeaching
     })
     return
Ejemplo n.º 25
0
 def getCommonData(self, callback):
     """
     Returns common personal case data for tankman, tankman's vehicles,
     message, flags and so on.
     """
     tankman = g_itemsCache.items.getTankman(self.tmanInvID)
     nativeVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = g_itemsCache.items.getItemByCD(tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     callback({'tankman': g_itemSerializer.pack(tankman),
      'currentVehicle': g_itemSerializer.pack(currentVehicle) if currentVehicle is not None else None,
      'nativeVehicle': g_itemSerializer.pack(nativeVehicle),
      'isOpsLocked': isLocked or g_currentVehicle.isLocked(),
      'lockMessage': reason})
     return
Ejemplo n.º 26
0
 def dropCurrentItemInSection(self, section, kind):
     if g_currentVehicle.isLocked():
         SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error)
         return
     elif g_currentVehicle.isBroken():
         SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error)
         return
     else:
         dialog = 'customization/{0:>s}Drop'.format(section)
         isConfirmed = yield DialogsInterface.showI18nConfirmDialog(dialog)
         if isConfirmed:
             interface = self.__interfaces.get(section)
             if interface is not None:
                 self.__returnHangar = False
                 self.__lockUpdate = True
                 Waiting.show('customizationDrop')
                 interface.drop(g_currentVehicle.invID, kind)
             else:
                 LOG_ERROR('Drop operation, section not found', section)
         return
Ejemplo n.º 27
0
 def getCommonData(self, callback):
     items = g_itemsCache.items
     tankman = items.getTankman(self.tmanInvID)
     rate = items.shop.freeXPToTManXPRate
     if rate:
         toNextPrcLeft = roundByModulo(tankman.getNextLevelXpCost(), rate)
         enoughFreeXPForTeaching = items.stats.freeXP - max(1, toNextPrcLeft / rate) >= 0
     else:
         enoughFreeXPForTeaching = False
     nativeVehicle = items.getItemByCD(tankman.vehicleNativeDescr.type.compactDescr)
     currentVehicle = None
     if tankman.isInTank:
         currentVehicle = items.getItemByCD(tankman.vehicleDescr.type.compactDescr)
     isLocked, reason = self.__getTankmanLockMessage(currentVehicle)
     bonuses = tankman.realRoleLevel[1]
     modifiers = []
     if bonuses[0]:
         modifiers.append({"id": "fromCommander", "val": bonuses[0]})
     if bonuses[1]:
         modifiers.append({"id": "fromSkills", "val": bonuses[1]})
     if bonuses[2] or bonuses[3]:
         modifiers.append({"id": "fromEquipment", "val": bonuses[2] + bonuses[3]})
     if bonuses[4]:
         modifiers.append({"id": "penalty", "val": bonuses[4]})
     callback(
         {
             "tankman": packTankman(tankman),
             "currentVehicle": packVehicle(currentVehicle) if currentVehicle is not None else None,
             "nativeVehicle": packVehicle(nativeVehicle),
             "isOpsLocked": isLocked or g_currentVehicle.isLocked(),
             "lockMessage": reason,
             "modifiers": modifiers,
             "enoughFreeXPForTeaching": enoughFreeXPForTeaching,
         }
     )
     return
Ejemplo n.º 28
0
 def isOn(self):
     isOn = False
     if g_currentVehicle.isPresent():
         isOn = g_currentVehicle.isLocked()
     return isOn
Ejemplo n.º 29
0
 def isOn(self):
     isOn = False
     if g_currentVehicle.isPresent():
         isOn = g_currentVehicle.isLocked()
     return isOn
Ejemplo n.º 30
0
    def applyCustomization(self, sections):
        if g_currentVehicle.isLocked():
            SystemMessages.pushI18nMessage(
                SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED,
                type=SystemMessages.SM_TYPE.Error)
            yield lambda callback=None: callback
        if g_currentVehicle.isBroken():
            SystemMessages.pushI18nMessage(
                SYSTEM_MESSAGES.customization_vehicle(
                    g_currentVehicle.item.getState()),
                type=SystemMessages.SM_TYPE.Error)
            yield lambda callback=None: callback
        notSelected = []
        selected = []
        remove = []
        selectedNames = []
        totalGold = 0
        totalCredits = 0
        newItemsByType = defaultdict(list)
        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                newItems = interface.getNewItems()
                if newItems is not None:
                    self.__updateNewItemsByType(newItemsByType, newItems,
                                                interface._type)

        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                newItems = interface.getNewItems()
                if newItems is not None:
                    removeStr = None
                    hasMatches = self.__hasNewItemsDuplicates(
                        newItemsByType, newItems, interface._type)
                    if not hasMatches:
                        costValue = interface.getSelectedItemCost()
                        if isinstance(costValue, list):
                            for price in costValue:
                                cost = price.get('cost')
                                isGold = price.get('isGold')
                                if cost > 0:
                                    if isGold and section.isGold:
                                        totalGold += cost
                                    elif not isGold and not section.isGold:
                                        totalCredits += cost

                        else:
                            cost, isGold = costValue
                            if cost > 0:
                                if isGold:
                                    totalGold += cost
                                else:
                                    totalCredits += cost
                    if section.sectionName not in selectedNames:
                        selected.append(
                            i18n.makeString(
                                '#menu:customization/change/{0:>s}'.format(
                                    section.sectionName)))
                        selectedNames.append(section.sectionName)
                        removeStr = interface.getCurrentItemRemoveStr()
                    if removeStr is not None:
                        remove.extend(removeStr)
                else:
                    notSelected.append(
                        i18n.makeString(
                            '#menu:customization/items/{0:>s}'.format(
                                section.sectionName)))
            else:
                LOG_ERROR('Section not found', section.sectionName)

        if len(notSelected) > 0:
            DialogsInterface.showI18nInfoDialog(
                'customization/selectNewItems', lambda success: None,
                I18nInfoDialogMeta(
                    'customization/selectNewItems',
                    messageCtx={'items': ', '.join(notSelected)}))
            yield lambda callback=None: callback
        if totalGold or totalCredits:
            titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_BUY
        else:
            titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_CHANGE
        isConfirmed = yield DialogsInterface.showDialog(
            I18nConfirmDialogMeta(
                'customization/changeConfirmation',
                titleCtx={'action': i18n.makeString(titleKey)},
                messageCtx={
                    'selected': ', '.join(selected),
                    'remove': '\n'.join(remove)
                }))
        if isConfirmed:
            creditsNotEnough = totalCredits > self.__credits
            goldNotEnough = totalGold > self.__gold
            if creditsNotEnough or goldNotEnough:
                if creditsNotEnough and goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH
                elif goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH
                else:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH
                SystemMessages.pushI18nMessage(
                    key, type=SystemMessages.SM_TYPE.Error)
                yield lambda callback=None: callback
            self.__returnHangar = True
            vehInvID = g_currentVehicle.invID
            self.__steps = 0
            self.__messages = []
            self.flashObject.applyButton.disabled = True
            if len(sections) > 0:
                Waiting.show('customizationApply')
                self.__lockUpdate = True
            selectedNames = []
            for section in sections:
                interface = self.__interfaces.get(section.sectionName)
                if interface is not None:
                    newItems = interface.getNewItems()
                    if newItems is not None:
                        hasMatches = self.__hasNewItemsDuplicates(
                            newItemsByType, newItems, interface._type)
                        self.__steps += interface.getSelectedItemsCount(
                            section.isGold)
                        if section.sectionName not in selectedNames:
                            interface.change(vehInvID, section, hasMatches)
                            selectedNames.append(section.sectionName)
                else:
                    LOG_ERROR('Change operation, section not found', section)
                    self.__steps -= 1

            if not self.__steps:
                self.__onServerResponsesReceived()
        return
Ejemplo n.º 31
0
    def __updateAmmo(self):
        Waiting.show('updateAmmo')
        credits = g_itemsCache.items.stats.credits
        shopRqs = yield ShopRequester().request()
        ammo = {'gunName': '',
         'maxAmmo': 0,
         'reserved1': False,
         'reserved2': False,
         'defaultAmmoCount': 0,
         'reserved3': 0,
         'vehicleLocked': True,
         'stateMsg': '',
         'stateLevel': 'info',
         'shells': [],
         'stateWarning': 0}
        if g_currentVehicle.isPresent():
            vehicle = g_currentVehicle.item
            default_ammo_count = 0
            default_ammo = dict(((s.intCD, s.defaultCount) for s in vehicle.shells))
            stateWarning = vehicle.isBroken or not vehicle.isCrewFull or not vehicle.isAmmoFull or not g_currentVehicle.isAutoLoadFull() or not g_currentVehicle.isAutoEquipFull()
            for compactDescr, count in default_ammo.iteritems():
                default_ammo_count += count

            msg, msgLvl = g_currentVehicle.getHangarMessage()
            ammo.update({'gunName': vehicle.gun.longUserName,
             'maxAmmo': vehicle.ammoMaxSize,
             'reserved1': not g_currentVehicle.isLocked(),
             'reserved2': not g_currentVehicle.isBroken(),
             'defaultAmmoCount': default_ammo_count,
             'reserved3': 0,
             'vehicleLocked': g_currentVehicle.isLocked(),
             'stateMsg': msg,
             'stateLevel': msgLvl,
             'stateWarning': int(stateWarning)})
            iAmmo = yield Requester('shell').getFromInventory()
            sAmmo = yield Requester('shell').getFromShop()
            iVehicles = yield Requester('vehicle').getFromInventory()
            oldStyleVehicle = None
            for v in iVehicles:
                if v.inventoryId == vehicle.invID:
                    oldStyleVehicle = v
                    break

            shells = ammo.get('shells')
            for shell in oldStyleVehicle.shells:
                shopShell = sAmmo[sAmmo.index(shell)] if shell in sAmmo else None
                goldAmmoForCredits = shopRqs.isEnabledBuyingGoldShellsForCredits
                if shopShell:
                    iCount = iAmmo[iAmmo.index(shell)].count if shell in iAmmo else 0
                    sPrice = (yield shopShell.getPrice()) if shell is not shopShell else (0, 0)
                    if goldAmmoForCredits:
                        shopShell.priceOrder = (sPrice[0] + sPrice[1] * shopRqs.exchangeRateForShellsAndEqs, sPrice[1])
                    shells.append({'id': gui_items.compactItem(shopShell),
                     'type': shell.type,
                     'label': ITEM_TYPES.shell_kindsabbreviation(shell.type),
                     'icon': '../maps/icons/ammopanel/ammo/%s' % shell.descriptor['icon'][0],
                     'count': shell.count,
                     'defaultCount': shell.default,
                     'inventoryCount': iCount,
                     'price': sPrice[0 if not sPrice[1] else 1],
                     'currentcy': 'credits' if not sPrice[1] else 'gold',
                     'ammoName': shell.longName,
                     'tableName': shell.tableName})

        self.as_setAmmoS(ammo)
        Waiting.hide('updateAmmo')
        return
Ejemplo n.º 32
0
    def applyCustomization(self, sections):
        if g_currentVehicle.isLocked():
            SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error)
            yield lambda callback = None: callback
        if g_currentVehicle.isBroken():
            SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error)
            yield lambda callback = None: callback
        notSelected = []
        selected = []
        remove = []
        selectedNames = []
        totalGold = 0
        totalCredits = 0
        newItemsByType = defaultdict(list)
        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                newItems = interface.getNewItems()
                if newItems is not None:
                    self.__updateNewItemsByType(newItemsByType, newItems, interface._type)

        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                newItems = interface.getNewItems()
                if newItems is not None:
                    removeStr = None
                    hasMatches = self.__hasNewItemsDuplicates(newItemsByType, newItems, interface._type)
                    if not hasMatches:
                        costValue = interface.getSelectedItemCost()
                        if isinstance(costValue, list):
                            for price in costValue:
                                cost = price.get('cost')
                                isGold = price.get('isGold')
                                if cost > 0:
                                    if isGold and section.isGold:
                                        totalGold += cost
                                    elif not isGold and not section.isGold:
                                        totalCredits += cost

                        else:
                            cost, isGold = costValue
                            if cost > 0:
                                if isGold:
                                    totalGold += cost
                                else:
                                    totalCredits += cost
                    if section.sectionName not in selectedNames:
                        selected.append(i18n.makeString('#menu:customization/change/{0:>s}'.format(section.sectionName)))
                        selectedNames.append(section.sectionName)
                        removeStr = interface.getCurrentItemRemoveStr()
                    if removeStr is not None:
                        remove.extend(removeStr)
                else:
                    notSelected.append(i18n.makeString('#menu:customization/items/{0:>s}'.format(section.sectionName)))
            else:
                LOG_ERROR('Section not found', section.sectionName)

        if len(notSelected) > 0:
            DialogsInterface.showI18nInfoDialog('customization/selectNewItems', lambda success: None, I18nInfoDialogMeta('customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)}))
            yield lambda callback = None: callback
        if totalGold or totalCredits:
            titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_BUY
        else:
            titleKey = DIALOGS.CUSTOMIZATION_CHANGECONFIRMATION_CHANGE
        isConfirmed = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/changeConfirmation', titleCtx={'action': i18n.makeString(titleKey)}, messageCtx={'selected': ', '.join(selected),
         'remove': '\n'.join(remove)}))
        if isConfirmed:
            creditsNotEnough = totalCredits > self.__credits
            goldNotEnough = totalGold > self.__gold
            if creditsNotEnough or goldNotEnough:
                if creditsNotEnough and goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH
                elif goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH
                else:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH
                SystemMessages.pushI18nMessage(key, type=SystemMessages.SM_TYPE.Error)
                yield lambda callback = None: callback
            self.__returnHangar = True
            vehInvID = g_currentVehicle.invID
            self.__steps = 0
            self.__messages = []
            self.flashObject.applyButton.disabled = True
            if len(sections) > 0:
                Waiting.show('customizationApply')
                self.__lockUpdate = True
            selectedNames = []
            for section in sections:
                interface = self.__interfaces.get(section.sectionName)
                if interface is not None:
                    newItems = interface.getNewItems()
                    if newItems is not None:
                        hasMatches = self.__hasNewItemsDuplicates(newItemsByType, newItems, interface._type)
                        self.__steps += interface.getSelectedItemsCount(section.isGold)
                        if section.sectionName not in selectedNames:
                            interface.change(vehInvID, section, hasMatches)
                            selectedNames.append(section.sectionName)
                else:
                    LOG_ERROR('Change operation, section not found', section)
                    self.__steps -= 1

            if not self.__steps:
                self.__onServerResponsesReceived()
        return
Ejemplo n.º 33
0
    def execute(self, customData):
        if self._functional.isCreator():
            func = self._functional
            fullData = func.getUnitFullData(
                unitIdx=self._functional.getUnitIdx())
            if fullData is None:
                return {}
            _, _, unitStats, pInfo, slotsIter = fullData
            notReadyCount = 0
            for slot in slotsIter:
                slotPlayer = slot.player
                if slotPlayer:
                    if slotPlayer.isInArena() or slotPlayer.isInPreArena(
                    ) or pInfo.isInSearch() or pInfo.isInQueue():
                        DialogsInterface.showI18nInfoDialog(
                            'squadHavePlayersInBattle', lambda result: None)
                        return True
                    if not slotPlayer.isReady:
                        notReadyCount += 1

            if not pInfo.isReady:
                notReadyCount -= 1
            if unitStats.occupiedSlotsCount == 1:
                DialogsInterface.showDialog(
                    I18nConfirmDialogMeta('squadHaveNoPlayers'),
                    self._setCreatorReady)
                return True
            if notReadyCount > 0:
                if notReadyCount == 1:
                    DialogsInterface.showDialog(
                        I18nConfirmDialogMeta('squadHaveNotReadyPlayer'),
                        self._setCreatorReady)
                    return True
                DialogsInterface.showDialog(
                    I18nConfirmDialogMeta('squadHaveNotReadyPlayers'),
                    self._setCreatorReady)
                return True
            if not g_currentVehicle.isLocked():
                _, unit = self._functional.getUnit()
                playerVehicles = unit.getVehicles()
                if playerVehicles:
                    commanderLevel = g_currentVehicle.item.level
                    lowerBound, upperBound = self._functional.getSquadLevelBounds(
                    )
                    minLevel = max(MIN_VEHICLE_LEVEL,
                                   commanderLevel + lowerBound)
                    maxLevel = min(MAX_VEHICLE_LEVEL,
                                   commanderLevel + upperBound)
                    levelRange = range(minLevel, maxLevel + 1)
                    for _, unitVehicles in playerVehicles.iteritems():
                        for vehicle in unitVehicles:
                            if vehicle.vehLevel not in levelRange:
                                DialogsInterface.showDialog(
                                    I18nConfirmDialogMeta(
                                        'squadHaveNoPlayers'),
                                    self._setCreatorReady)
                                return True

            self._setCreatorReady(True)
        else:
            self._functional.togglePlayerReadyAction(True)
        return True
Ejemplo n.º 34
0
 def processReturnCrew(self, print_message = True):
     if not g_currentVehicle.isInHangar() or g_currentVehicle.isInBattle() or g_currentVehicle.isLocked() or g_currentVehicle.isCrewFull():
         return
     result = yield TankmanReturn(g_currentVehicle.item).request()
     if len(result.userMsg) and print_message:
         SystemMessages.pushI18nMessage(result.userMsg, type=result.sysMsgType)
Ejemplo n.º 35
0
 def _getIsDisabled():
     return not g_currentVehicle.isInHangar() or g_currentVehicle.isLocked(
     ) or g_currentVehicle.isBroken()
Ejemplo n.º 36
0
    def applyCustomization(self, sections):
        if g_currentVehicle.isLocked():
            SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED, type=SystemMessages.SM_TYPE.Error)
            yield lambda callback = None: callback
        if g_currentVehicle.isBroken():
            SystemMessages.pushI18nMessage(SYSTEM_MESSAGES.customization_vehicle(g_currentVehicle.item.getState()), type=SystemMessages.SM_TYPE.Error)
            yield lambda callback = None: callback
        notSelected = []
        selected = []
        remove = []
        selectedNames = []
        totalGold = 0
        totalCredits = 0
        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                if interface.isNewItemSelected():
                    costValue = interface.getSelectedItemCost()
                    if type(costValue) is list:
                        for price in costValue:
                            cost = price.get('cost')
                            isGold = price.get('isGold')
                            if cost > 0:
                                if isGold and section.isGold:
                                    totalGold += cost
                                elif not isGold and not section.isGold:
                                    totalCredits += cost

                    else:
                        cost, isGold = costValue
                        if cost > 0:
                            if isGold:
                                totalGold += cost
                            else:
                                totalCredits += cost
                    if section.sectionName not in selectedNames:
                        selected.append(i18n.makeString('#menu:customization/change/{0:>s}'.format(section.sectionName)))
                        selectedNames.append(section.sectionName)
                    if interface.isCurrentItemRemove():
                        remove.append(gui.makeHtmlString('html_templates:lobby/customization', 'remove-{0:>s}'.format(section.sectionName)))
                else:
                    notSelected.append(i18n.makeString('#menu:customization/items/{0:>s}'.format(section.sectionName)))
            else:
                LOG_ERROR('Section not found', section.sectionName)

        if len(notSelected) > 0:
            DialogsInterface.showI18nInfoDialog('customization/selectNewItems', lambda success: None, I18nInfoDialogMeta('customization/selectNewItems', messageCtx={'items': ', '.join(notSelected)}))
            yield lambda callback = None: callback
        isConfirmed = yield DialogsInterface.showDialog(I18nConfirmDialogMeta('customization/changeConfirmation', messageCtx={'selected': ', '.join(selected),
         'remove': '\n'.join(remove)}))
        if isConfirmed:
            creditsNotEnough = totalCredits > self.__credits
            goldNotEnough = totalGold > self.__gold
            if creditsNotEnough or goldNotEnough:
                if creditsNotEnough and goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH
                elif goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH
                else:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH
                SystemMessages.pushI18nMessage(key, type=SystemMessages.SM_TYPE.Error)
                yield lambda callback = None: callback
            self.__returnHangar = True
            vehInvID = g_currentVehicle.invID
            self.__steps = 0
            self.__messages = []
            self.flashObject.applyButton.disabled = True
            if len(sections) > 0:
                Waiting.show('customizationApply')
                self.__lockUpdate = True
            selectedNames = []
            for section in sections:
                interface = self.__interfaces.get(section.sectionName)
                if interface is not None:
                    self.__steps += interface.getSelectedItemsCount(section.isGold)
                    if section.sectionName not in selectedNames:
                        interface.change(vehInvID, section)
                        selectedNames.append(section.sectionName)
                else:
                    LOG_ERROR('Change operation, section not found', section)
                    self.__steps -= 1

            if not self.__steps:
                self.__onServerResponsesReceived()
        return
Ejemplo n.º 37
0
 def __cv_onChanged(self):
     if not g_currentVehicle.isReadyToFight():
         if g_currentVehicle.isCrewFull() and not g_currentVehicle.isBroken():
             self.closeWindow()
     else:
         self.as_setActionsLockedS(g_currentVehicle.isLocked() or g_currentVehicle.isBroken())
Ejemplo n.º 38
0
def onXfwCommand(cmd, *args):
    try:
        if cmd == COMMANDS.PUT_PREVIOUS_CREW:
            if g_currentVehicle.isInHangar() and not (g_currentVehicle.isCrewFull() or g_currentVehicle.isInBattle() or g_currentVehicle.isLocked()):
                PutPreviousCrew(g_currentVehicle, False)
            return (None, True)
    except Exception, ex:
        err(traceback.format_exc())
        return (None, True)
Ejemplo n.º 39
0
    def applyCustomization(self, sections):
        if g_currentVehicle.isLocked():
            SystemMessages.pushI18nMessage(
                SYSTEM_MESSAGES.CUSTOMIZATION_VEHICLE_LOCKED,
                type=SystemMessages.SM_TYPE.Error)
            yield lambda callback=None: callback
        if g_currentVehicle.isBroken():
            SystemMessages.pushI18nMessage(
                SYSTEM_MESSAGES.customization_vehicle(
                    g_currentVehicle.item.getState()),
                type=SystemMessages.SM_TYPE.Error)
            yield lambda callback=None: callback
        notSelected = []
        selected = []
        remove = []
        selectedNames = []
        totalGold = 0
        totalCredits = 0
        for section in sections:
            interface = self.__interfaces.get(section.sectionName)
            if interface is not None:
                if interface.isNewItemSelected():
                    costValue = interface.getSelectedItemCost()
                    if type(costValue) is list:
                        for price in costValue:
                            cost = price.get('cost')
                            isGold = price.get('isGold')
                            if cost > 0:
                                if isGold and section.isGold:
                                    totalGold += cost
                                elif not isGold and not section.isGold:
                                    totalCredits += cost

                    else:
                        cost, isGold = costValue
                        if cost > 0:
                            if isGold:
                                totalGold += cost
                            else:
                                totalCredits += cost
                    if section.sectionName not in selectedNames:
                        selected.append(
                            i18n.makeString(
                                '#menu:customization/change/{0:>s}'.format(
                                    section.sectionName)))
                        selectedNames.append(section.sectionName)
                    if interface.isCurrentItemRemove():
                        remove.append(
                            gui.makeHtmlString(
                                'html_templates:lobby/customization',
                                'remove-{0:>s}'.format(section.sectionName)))
                else:
                    notSelected.append(
                        i18n.makeString(
                            '#menu:customization/items/{0:>s}'.format(
                                section.sectionName)))
            else:
                LOG_ERROR('Section not found', section.sectionName)

        if len(notSelected) > 0:
            DialogsInterface.showI18nInfoDialog(
                'customization/selectNewItems', lambda success: None,
                I18nInfoDialogMeta(
                    'customization/selectNewItems',
                    messageCtx={'items': ', '.join(notSelected)}))
            yield lambda callback=None: callback
        isConfirmed = yield DialogsInterface.showDialog(
            I18nConfirmDialogMeta('customization/changeConfirmation',
                                  messageCtx={
                                      'selected': ', '.join(selected),
                                      'remove': '\n'.join(remove)
                                  }))
        if isConfirmed:
            creditsNotEnough = totalCredits > self.__credits
            goldNotEnough = totalGold > self.__gold
            if creditsNotEnough or goldNotEnough:
                if creditsNotEnough and goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_AND_GOLD_NOT_ENOUGH
                elif goldNotEnough:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_GOLD_NOT_ENOUGH
                else:
                    key = SYSTEM_MESSAGES.CUSTOMIZATION_CREDITS_NOT_ENOUGH
                SystemMessages.pushI18nMessage(
                    key, type=SystemMessages.SM_TYPE.Error)
                yield lambda callback=None: callback
            self.__returnHangar = True
            vehInvID = g_currentVehicle.invID
            self.__steps = 0
            self.__messages = []
            self.flashObject.applyButton.disabled = True
            if len(sections) > 0:
                Waiting.show('customizationApply')
                self.__lockUpdate = True
            selectedNames = []
            for section in sections:
                interface = self.__interfaces.get(section.sectionName)
                if interface is not None:
                    self.__steps += interface.getSelectedItemsCount(
                        section.isGold)
                    if section.sectionName not in selectedNames:
                        interface.change(vehInvID, section)
                        selectedNames.append(section.sectionName)
                else:
                    LOG_ERROR('Change operation, section not found', section)
                    self.__steps -= 1

            if not self.__steps:
                self.__onServerResponsesReceived()
        return