Example #1
0
 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
Example #2
0
 def _updateHeader(self):
     functional = self.unitFunctional
     isBalancedSquadEnabled = g_eventsCache.isBalancedSquadEnabled()
     isSquadXpFactorsEnabled = g_eventsCache.isSquadXpFactorsEnabled()
     isArtVisible = isSquadXpFactorsEnabled
     if isArtVisible:
         if isBalancedSquadEnabled:
             if functional.isDynamic():
                 headerIconSource = RES_ICONS.MAPS_ICONS_SQUAD_SQUAD_SILVER_STARS_ATTENTION
                 headerMessageText = text_styles.middleTitle(i18n.makeString(MESSENGER.DIALOGS_SQUADCHANNEL_HEADERMSG_DYNSQUAD))
                 iconXPadding = 0
                 iconYPadding = 0
             else:
                 headerIconSource = RES_ICONS.MAPS_ICONS_SQUAD_SQUAD_SILVER_STARS
                 headerMessageText = text_styles.main(i18n.makeString(MESSENGER.DIALOGS_SQUADCHANNEL_HEADERMSG_SQUADFORMATION))
                 iconXPadding = 9
                 iconYPadding = 9
             tooltipType = TOOLTIPS_CONSTANTS.COMPLEX
             tooltip = TOOLTIPS.SQUADWINDOW_INFOICON_TECH
         else:
             tooltipType = TOOLTIPS_CONSTANTS.SPECIAL
             tooltip = TOOLTIPS_CONSTANTS.SQUAD_RESTRICTIONS_INFO
             headerIconSource = RES_ICONS.MAPS_ICONS_SQUAD_SQUAD_SILVER_STARS
             headerMessageText = text_styles.main(i18n.makeString(MESSENGER.DIALOGS_SQUADCHANNEL_HEADERMSG_SQUADFORMATIONRESTRICTION))
             iconXPadding = 9
             iconYPadding = 9
     else:
         tooltip = ''
         tooltipType = ''
         headerIconSource = ''
         headerMessageText = ''
         iconXPadding = 0
         iconYPadding = 0
     data = {'infoIconTooltip': tooltip,
      'infoIconTooltipType': tooltipType,
      'isVisibleInfoIcon': isArtVisible,
      'isVisibleHeaderIcon': isArtVisible,
      'headerIconSource': headerIconSource,
      'icoXPadding': iconXPadding,
      'icoYPadding': iconYPadding,
      'headerMessageText': headerMessageText,
      'isVisibleHeaderMessage': isArtVisible}
     self.as_setSimpleTeamSectionDataS(data)
Example #3
0
 def _updateHeader(self):
     isSquadXpFactorsEnabled = g_eventsCache.isSquadXpFactorsEnabled()
     isArtVisible = isSquadXpFactorsEnabled
     if isArtVisible:
         tooltip, tooltipType = self._getInfoIconTooltipParams()
         hdrIconSource, iXPadding, iYPadding, hdrMessageText = self._getHeaderMessageParams()
     else:
         tooltip = ''
         tooltipType = ''
         hdrIconSource = ''
         hdrMessageText = ''
         iXPadding = 0
         iYPadding = 0
     data = {'infoIconTooltip': tooltip,
      'infoIconTooltipType': tooltipType,
      'isVisibleInfoIcon': isArtVisible,
      'isVisibleHeaderIcon': isArtVisible,
      'headerIconSource': hdrIconSource,
      'icoXPadding': iXPadding,
      'icoYPadding': iYPadding,
      'headerMessageText': hdrMessageText,
      'isVisibleHeaderMessage': isArtVisible}
     self.as_setSimpleTeamSectionDataS(data)
Example #4
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()
    bwPlugin = proto_getter(PROTO_TYPE.BW_CHAT2)(None)
    isPlayerSpeaking = bwPlugin.voipController.isPlayerSpeaking
    falloutCtrl = getFalloutCtrl()
    isFallout = falloutCtrl.isEnabled()
    if isFallout:
        falloutBattleType = falloutCtrl.getBattleType()
        falloutCfg = falloutCtrl.getConfig()
    else:
        falloutBattleType = QUEUE_TYPE.UNKNOWN
        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
    rosterSlots = {}
    isDefaultSlot = False
    if unit is not None:
        roster = unit.getRoster()
        rosterSlots = roster.slots
        isDefaultSlot = roster.isDefaultSlot
    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:
                slotLevel = vehicle.vehLevel
                if vehicle.vehTypeCompDescr:
                    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 == QUEUE_TYPE.FALLOUT_MULTITEAM
            slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, isRequired=isRequired)
        if unit.isPrebattlesSquad():
            playerStatus = getSquadPlayerStatus(slotState, player)
        else:
            playerStatus = getPlayerStatus(slotState, player)
        if unit is not None:
            restrictions = makeUnitRosterConditions(rosterSlots, isDefaultSlot, index=index, isSortie=unit.isSortie(), levelsRange=levelsRange)
        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 unit.isSquad():
            if g_eventsCache.isBalancedSquadEnabled():
                isVisibleAdtMsg = player and player.isCurrentPlayer() and not isPlayerCreator and not vehicle and unit and bool(unit.getMemberVehicles(unit.getCommanderDBID()))
                if isVisibleAdtMsg:
                    rangeString = toRomanRangeString(levelsRange, 1)
                    additionMsg = text_styles.main(i18n.makeString(MESSENGER.DIALOGS_SIMPLESQUAD_VEHICLELEVEL, level=rangeString))
                else:
                    additionMsg = ''
                slot.update({'isVisibleAdtMsg': isVisibleAdtMsg,
                 'additionalMsg': additionMsg})
            elif g_eventsCache.isSquadXpFactorsEnabled():
                vehicles = unit.getVehicles()
                levels = unit.getSelectedVehicleLevels()
                isVisibleAdtMsg = False
                additionalMsg = ''
                unitHasXpBonus = True
                unitHasXpPenalty = False
                if vehicles:
                    distance = levels[-1] - levels[0]
                    unitHasXpBonus = distance in g_eventsCache.getSquadBonusLevelDistance()
                    unitHasXpPenalty = distance in g_eventsCache.getSquadPenaltyLevelDistance()
                    isVisibleAdtMsg = unitHasXpBonus and player and player.isCurrentPlayer() and not vehicle
                    if isVisibleAdtMsg:
                        maxDistance = max(g_eventsCache.getSquadBonusLevelDistance())
                        minLevel = max(MIN_VEHICLE_LEVEL, levels[0] - maxDistance)
                        maxLevel = min(MAX_VEHICLE_LEVEL, levels[0] + maxDistance)
                        rangeString = toRomanRangeString(range(minLevel, maxLevel + 1), 1)
                        additionalMsg = text_styles.main(i18n.makeString(MESSENGER.DIALOGS_SIMPLESQUAD_VEHICLELEVEL, level=rangeString))
                slotNotificationIcon = ''
                slotNotificationIconTooltip = ''
                if vehicle:
                    if unitHasXpPenalty:
                        slotNotificationIcon = RES_ICONS.MAPS_ICONS_LIBRARY_CYBERSPORT_ALERTICON
                        slotNotificationIconTooltip = makeTooltip(TOOLTIPS.SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_HEADER, TOOLTIPS.SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_BODY, None, TOOLTIPS.SQUADWINDOW_SIMPLESLOTNOTIFICATION_ALERT_ALERT)
                    elif not unitHasXpBonus:
                        slotNotificationIcon = RES_ICONS.MAPS_ICONS_LIBRARY_ATTENTIONICON
                        slotNotificationIconTooltip = makeTooltip(TOOLTIPS.SQUADWINDOW_SIMPLESLOTNOTIFICATION_INFO_HEADER, TOOLTIPS.SQUADWINDOW_SIMPLESLOTNOTIFICATION_INFO_BODY)
                slot.update({'isVisibleAdtMsg': isVisibleAdtMsg,
                 'additionalMsg': additionalMsg,
                 'slotNotificationIconTooltip': slotNotificationIconTooltip,
                 'slotNotificationIcon': slotNotificationIcon})
        if unit.isEvent():
            isVisibleAdtMsg = player and player.isCurrentPlayer() and not vehicle
            additionMsg = ''
            if isVisibleAdtMsg:
                vehiclesNames = [ veh.userName for veh in g_eventsCache.getEventVehicles() ]
                additionMsg = text_styles.main(i18n.makeString(MESSENGER.DIALOGS_EVENTSQUAD_VEHICLE, vehName=', '.join(vehiclesNames)))
            slot.update({'isVisibleAdtMsg': isVisibleAdtMsg,
             'additionalMsg': additionMsg})
        if isFallout:
            vehiclesNotify = [None, None, None]
            selectedVehicles = [None, None, None]
            if player is not None:
                dbID = player.dbID
                isCurrentPlayer = player.isCurrentPlayer()
                if isCurrentPlayer:
                    statusTemplate = None
                    if falloutBattleType == QUEUE_TYPE.FALLOUT_MULTITEAM:
                        minVehiclesPerPlayer = falloutCfg.minVehiclesPerPlayer
                        if len(falloutCtrl.getSelectedVehicles()) < minVehiclesPerPlayer:
                            statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)
                    elif falloutCtrl.mustSelectRequiredVehicle():
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFY, level=text_styles.main(int2roman(falloutCfg.vehicleLevelRequired)))
                    else:
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYRANGE, level=text_styles.main(toRomanRangeString(list(falloutCfg.allowedLevels), 1)))
                    if statusTemplate is not None:
                        for slotIdx in range(falloutCfg.minVehiclesPerPlayer):
                            vehiclesNotify[slotIdx] = statusTemplate

                for idx, vehicle in enumerate(unit.getVehicles().get(dbID, ())):
                    selectedVehicles[idx] = makeVehicleVO(vehicleGetter(vehicle.vehTypeCompDescr), falloutCfg.allowedLevels, isCurrentPlayer=isCurrentPlayer)

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

    return slots