def _getFalloutVehLevelStr(self):
     if self._extra is None:
         return
     else:
         config = g_eventsCache.getFalloutConfig(self._extra.eventType)
         requiredLevelStr = int2roman(config.vehicleLevelRequired)
         return (CYBERSPORT.WINDOW_UNIT_MESSAGE_FALLOUTLEVEL, {'level': requiredLevelStr})
 def _getFalloutVehLevelStr(self):
     config = g_eventsCache.getFalloutConfig(self._extra.eventType)
     if len(config.allowedLevels) > 1:
         return ('#cyberSport:window/unit/message/falloutMin', {
             'level': toRomanRangeString(list(config.allowedLevels), 1)
         })
     else:
         return ('#cyberSport:window/unit/message/falloutLevel', {
             'level': int2roman(config.vehicleLevelRequired)
         })
 def _getFalloutVehMinStr(self):
     if self._extra is None:
         return
     else:
         config = g_eventsCache.getFalloutConfig(self._extra.eventType)
         allowedLevelsList = list(config.allowedLevels)
         if len(allowedLevelsList) > 1:
             return (CYBERSPORT.WINDOW_UNIT_MESSAGE_FALLOUTMIN_LEVELRANGE, {'level': toRomanRangeString(allowedLevelsList, 1)})
         return (CYBERSPORT.WINDOW_UNIT_MESSAGE_FALLOUTMIN_REQUIREDLEVEL, {'level': int2roman(config.vehicleLevelRequired)})
         return
Пример #4
0
 def getConfig(self):
     return g_eventsCache.getFalloutConfig(self.getBattleType())
Пример #5
0
 def getConfig(self):
     return g_eventsCache.getFalloutConfig(self.getBattleType())
Пример #6
0
def _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app = None, levelsRange = None, checkForVehicles = True):
    isPlayerCreator = pInfo.isCreator()
    isPlayerInSlot = pInfo.isInSlot
    slots = []
    userGetter = storage_getter('users')().getUser
    colorGetter = g_settings.getColorScheme('rosters').getColors
    vehicleGetter = g_itemsCache.items.getItemByCD
    canTakeSlot = not pInfo.isLegionary()
    if app:
        isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking
    else:
        isPlayerSpeaking = lambda dbID: False
    if unit.isSquad():
        falloutBattleType = unit.getExtra().eventType
        isFallout = falloutBattleType != FALLOUT_BATTLE_TYPE.UNDEFINED
        falloutCfg = g_eventsCache.getFalloutConfig(falloutBattleType)
    else:
        falloutBattleType = FALLOUT_BATTLE_TYPE.UNDEFINED
        isFallout = False
        falloutCfg = None
    if unit is None:
        makeVO = makePlayerVO
    elif unit.isFortBattle():
        makeVO = makeClanBattlePlayerVO
    elif unit.isSortie():
        makeVO = makeSortiePlayerVO
    elif unit.isClub():
        makeVO = makeStaticFormationPlayerVO
    else:
        makeVO = makePlayerVO
    for slotInfo in slotsIter:
        index = slotInfo.index
        slotState = slotInfo.state
        player = slotInfo.player
        vehicle = slotInfo.vehicle
        canAssign, vehicles = pInfo.canAssignToSlot(index)
        vehCount = len(vehicles)
        slotLevel = 0
        vehicleVO = None
        slotPlayerUI = None
        if player is not None:
            dbID = player.dbID
            slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID))
            isCurrentPlayer = player.isCurrentPlayer()
            if vehicle:
                if 'vehLevel' in vehicle:
                    slotLevel = vehicle['vehLevel']
                if 'vehTypeCompDescr' in vehicle:
                    vehicleVO = makeVehicleVO(vehicleGetter(vehicle['vehTypeCompDescr']), levelsRange, isCurrentPlayer=isCurrentPlayer)
        if unit is not None and unit.isClub():
            slotLabel = makeStaticSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, pInfo.isLegionary(), unit.isRated())
        else:
            isRequired = falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM
            slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, isRequired=isRequired)
        if unit.isSquad():
            playerStatus = getSquadPlayerStatus(slotState, player)
        else:
            playerStatus = getPlayerStatus(slotState, player)
        if unit is not None:
            restrictions = makeUnitRosterVO(unit, pInfo, index=index, isSortie=unit.isSortie(), levelsRange=levelsRange)['conditions']
        else:
            restrictions = []
        slot = {'rallyIdx': unitIdx,
         'isCommanderState': isPlayerCreator,
         'isCurrentUserInSlot': isPlayerInSlot,
         'playerStatus': playerStatus,
         'isClosed': slotState.isClosed,
         'isFreezed': unitState.isFreezed(),
         'slotLabel': slotLabel,
         'player': slotPlayerUI,
         'canBeTaken': canAssign and canTakeSlot,
         'compatibleVehiclesCount': vehCount,
         'selectedVehicle': vehicleVO,
         'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel,
         'restrictions': restrictions,
         'isFallout': isFallout}
        if isFallout:
            vehiclesNotify = [None, None, None]
            selectedVehicles = [None, None, None]
            if player is not None:
                dbID = player.dbID
                isCurrentPlayer = player.isCurrentPlayer()
                if isCurrentPlayer:
                    if falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM:
                        vehiclesNotify[0] = [i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)]
                    else:
                        vehiclesNotify[0] = [i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFY, level=text_styles.main(int2roman(falloutCfg.vehicleLevelRequired)))]
                    if len(falloutCfg.allowedLevels) > 1:
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYRANGE, level=text_styles.main(toRomanRangeString(list(falloutCfg.allowedLevels), 1)))
                    else:
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)
                    for slotIdx in range(1, falloutCfg.minVehiclesPerPlayer):
                        vehiclesNotify[slotIdx] = statusTemplate

                for idx, (vInvID, vehIntCD) in enumerate(unit.getExtra().accountVehicles.get(dbID, ())):
                    selectedVehicles[idx] = makeVehicleVO(vehicleGetter(vehIntCD), falloutCfg.allowedLevels, isCurrentPlayer=isCurrentPlayer)

            slot['vehiclesNotify'] = vehiclesNotify
            slot['selectedVehicle'] = selectedVehicles
        slots.append(slot)

    return slots
Пример #7
0
 def __updateFalloutState(self):
     self.__falloutType = self.unitFunctional.getExtra().eventType
     self.__isFallout = self.__falloutType > 0
     self.__falloutCfg = g_eventsCache.getFalloutConfig(self.__falloutType)
 def _getFalloutVehMinStr(self):
     config = g_eventsCache.getFalloutConfig(self._extra.eventType)
     return ('#cyberSport:window/unit/message/falloutMin', {
         'min': str(config.minVehiclesPerPlayer),
         'level': toRomanRangeString(list(config.allowedLevels), 1)
     })
Пример #9
0
def _getSlotsData(unitIdx,
                  unit,
                  unitState,
                  pInfo,
                  slotsIter,
                  app=None,
                  levelsRange=None,
                  checkForVehicles=True):
    isPlayerCreator = pInfo.isCreator()
    isPlayerInSlot = pInfo.isInSlot
    slots = []
    userGetter = storage_getter('users')().getUser
    colorGetter = g_settings.getColorScheme('rosters').getColors
    vehicleGetter = g_itemsCache.items.getItemByCD
    canTakeSlot = not pInfo.isLegionary()
    if app:
        isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking
    else:
        isPlayerSpeaking = lambda dbID: False
    if unit.isSquad():
        falloutBattleType = unit.getExtra().eventType
        isFallout = falloutBattleType != FALLOUT_BATTLE_TYPE.UNDEFINED
        falloutCfg = g_eventsCache.getFalloutConfig(falloutBattleType)
    else:
        falloutBattleType = FALLOUT_BATTLE_TYPE.UNDEFINED
        isFallout = False
        falloutCfg = None
    if unit is None:
        makeVO = makePlayerVO
    elif unit.isFortBattle():
        makeVO = makeClanBattlePlayerVO
    elif unit.isSortie():
        makeVO = makeSortiePlayerVO
    elif unit.isClub():
        makeVO = makeStaticFormationPlayerVO
    else:
        makeVO = makePlayerVO
    for slotInfo in slotsIter:
        index = slotInfo.index
        slotState = slotInfo.state
        player = slotInfo.player
        vehicle = slotInfo.vehicle
        canAssign, vehicles = pInfo.canAssignToSlot(index)
        vehCount = len(vehicles)
        slotLevel = 0
        vehicleVO = None
        slotPlayerUI = None
        if player is not None:
            dbID = player.dbID
            slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter,
                                  isPlayerSpeaking(dbID))
            isCurrentPlayer = player.isCurrentPlayer()
            if vehicle:
                if 'vehLevel' in vehicle:
                    slotLevel = vehicle['vehLevel']
                if 'vehTypeCompDescr' in vehicle:
                    vehicleVO = makeVehicleVO(vehicleGetter(
                        vehicle['vehTypeCompDescr']),
                                              levelsRange,
                                              isCurrentPlayer=isCurrentPlayer)
        if unit is not None and unit.isClub():
            slotLabel = makeStaticSlotLabel(unitState, slotState,
                                            isPlayerCreator, vehCount,
                                            checkForVehicles,
                                            pInfo.isLegionary(),
                                            unit.isRated())
        else:
            isRequired = falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM
            slotLabel = makeSlotLabel(unitState,
                                      slotState,
                                      isPlayerCreator,
                                      vehCount,
                                      checkForVehicles,
                                      isRequired=isRequired)
        if unit.isSquad():
            playerStatus = getSquadPlayerStatus(slotState, player)
        else:
            playerStatus = getPlayerStatus(slotState, player)
        if unit is not None:
            restrictions = makeUnitRosterVO(
                unit,
                pInfo,
                index=index,
                isSortie=unit.isSortie(),
                levelsRange=levelsRange)['conditions']
        else:
            restrictions = []
        slot = {
            'rallyIdx': unitIdx,
            'isCommanderState': isPlayerCreator,
            'isCurrentUserInSlot': isPlayerInSlot,
            'playerStatus': playerStatus,
            'isClosed': slotState.isClosed,
            'isFreezed': unitState.isFreezed(),
            'slotLabel': slotLabel,
            'player': slotPlayerUI,
            'canBeTaken': canAssign and canTakeSlot,
            'compatibleVehiclesCount': vehCount,
            'selectedVehicle': vehicleVO,
            'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel,
            'restrictions': restrictions,
            'isFallout': isFallout
        }
        if isFallout:
            vehiclesNotify = [None, None, None]
            selectedVehicles = [None, None, None]
            if player is not None:
                dbID = player.dbID
                isCurrentPlayer = player.isCurrentPlayer()
                if isCurrentPlayer:
                    if falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM:
                        vehiclesNotify[0] = [
                            i18n.makeString(
                                MESSENGER.
                                DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM
                            )
                        ]
                    else:
                        vehiclesNotify[0] = [
                            i18n.makeString(
                                MESSENGER.
                                DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFY,
                                level=text_styles.main(
                                    int2roman(
                                        falloutCfg.vehicleLevelRequired)))
                        ]
                    if len(falloutCfg.allowedLevels) > 1:
                        statusTemplate = i18n.makeString(
                            MESSENGER.
                            DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYRANGE,
                            level=text_styles.main(
                                toRomanRangeString(
                                    list(falloutCfg.allowedLevels), 1)))
                    else:
                        statusTemplate = i18n.makeString(
                            MESSENGER.
                            DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)
                    for slotIdx in range(1, falloutCfg.minVehiclesPerPlayer):
                        vehiclesNotify[slotIdx] = statusTemplate

                for idx, (vInvID, vehIntCD) in enumerate(
                        unit.getExtra().accountVehicles.get(dbID, ())):
                    selectedVehicles[idx] = makeVehicleVO(
                        vehicleGetter(vehIntCD),
                        falloutCfg.allowedLevels,
                        isCurrentPlayer=isCurrentPlayer)

            slot['vehiclesNotify'] = vehiclesNotify
            slot['selectedVehicle'] = selectedVehicles
        slots.append(slot)

    return slots
 def _getFalloutVehMinStr(self):
     config = g_eventsCache.getFalloutConfig(self._extra.eventType)
     return ('#cyberSport:window/unit/message/falloutMin', {'min': str(config.minVehiclesPerPlayer),
       'level': toRomanRangeString(list(config.allowedLevels), 1)})
 def _getFalloutVehLevelStr(self):
     config = g_eventsCache.getFalloutConfig(self._extra.eventType)
     if len(config.allowedLevels) > 1:
         return ('#cyberSport:window/unit/message/falloutMin', {'level': toRomanRangeString(list(config.allowedLevels), 1)})
     else:
         return ('#cyberSport:window/unit/message/falloutLevel', {'level': int2roman(config.vehicleLevelRequired)})
Пример #12
0
 def __updateFalloutState(self):
     self.__falloutType = self.unitFunctional.getExtra().eventType
     self.__isFallout = self.__falloutType > 0
     self.__falloutCfg = g_eventsCache.getFalloutConfig(self.__falloutType)