def makeCantJoinReasonTextVO(event, playerData): playerState = playerData.getPlayerStateByEventId(event.getEventID()) stateReasons = playerState.getPlayerStateReasons() if playerState else [] stateReason = stateReasons[0] if stateReasons else None tooltip = None buttonVisible = False if event.isRegistrationFinished(): result = formatErrorTextWithIcon( EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION) elif _psr.SPECIALACCOUNT in stateReasons: result = getStatusTitleStyle( _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_SPECIAL)) elif stateReason is _psr.WASUNREGISTERED: result = getStatusTitleStyle( _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_LEFTEVENT)) tooltip = makeTooltip( EVENT_BOARDS.STATUS_CANTJOIN_REASON_LEFTEVENT, EVENT_BOARDS.STATUS_CANTJOIN_REASON_LEFTEVENT_TOOLTIP) else: limits = event.getLimits() if len(stateReasons) > 1: reasonText = _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_MANY, number=len(stateReasons)) tooltip = _makeCantJoinReasonTooltip(stateReasons, playerData, limits) elif stateReason is _psr.BYWINRATE: winRate = playerData.getWinRate() winRateMin = limits.getWinRateMin() winRateMax = limits.getWinRateMax() if winRate < winRateMin: reasonText = _ms( EVENT_BOARDS.STATUS_CANTJOIN_REASON_BYWINRATELOW, number=str(winRateMin)) else: reasonText = _ms( EVENT_BOARDS.STATUS_CANTJOIN_REASON_BYWINRATEHIGH, number=str(winRateMax)) elif stateReason is _psr.BYAGE: date = BigWorld.wg_getShortDateFormat( limits.getRegistrationDateMaxTs()) reasonText = _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_BYAGE, date=date) elif stateReason is _psr.BYBATTLESCOUNT: battlesCount = playerData.getBattlesCount() reasonText = _ms( EVENT_BOARDS.STATUS_CANTJOIN_REASON_BYBATTLESCOUNT, number=battlesCount) elif stateReason is _psr.BYBAN: reasonText = _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_BANNED) elif stateReason is _psr.VEHICLESMISSING: reasonText = _ms( EVENT_BOARDS.STATUS_CANTJOIN_REASON_VEHICLESMISSING) else: reasonText = '' notAvailableText = formatErrorTextWithIcon( EVENT_BOARDS.STATUS_CANTJOIN_NOTAVAILABLE) reasonText = text_styles.main(reasonText) result = '{} {}'.format(notAvailableText, reasonText) buttonVisible = True return (result, tooltip, buttonVisible)
def __updateStatus(self): event = self.__eventData playerState = self.__playerState myInfo = self.__myInfo state = playerState.getPlayerState() if playerState else None canJoin = playerState.getCanJoin() if playerState else True stateReasons = playerState.getPlayerStateReasons( ) if playerState else [] joined = state is _es.JOINED cardinality = event.getCardinality() battleCount = myInfo.battlesCount if myInfo else 0 notFull = cardinality is not None and battleCount < cardinality outOfScore = not myInfo.fullData.getIsInsideViewsize( ) if myInfo else False visible = True title = '' tooltip = None showPoints = False titleTooltip = None buttonVisible = False buttonEnabled = False buttonLabel = TOOLTIPS.ELEN_BUTTON_REGISTRATION_STARTED_HEADER buttonTooltip = makeTooltip( buttonLabel, TOOLTIPS.ELEN_BUTTON_REGISTRATION_STARTED_BODY) method = event.getMethod() if event.isFinished(): if not joined: title = getStatusTitleStyle( _ms(EVENT_BOARDS.EXCEL_PARTICIPATE_NOTPARTICIPATED)) elif notFull: title = getStatusTitleStyle( _ms(EVENT_BOARDS.EXCEL_PARTICIPATE_NOTPARTICIPATED)) elif outOfScore: showPoints = True title = getStatusTitleStyle( _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_OUTOFRATING)) else: visible = False elif joined: if notFull: showPoints = True count = getStatusCountStyle(str(cardinality - battleCount)) title = getStatusTitleStyle( _ms(EVENT_BOARDS.EXCEL_HEADER_REASON_BATTLESLEFT, number=count)) elif outOfScore: showPoints = True title = getStatusTitleStyle( _ms(EVENT_BOARDS.STATUS_CANTJOIN_REASON_OUTOFRATING)) else: visible = False elif event.isRegistrationFinished(): title = formatErrorTextWithIcon( EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION) tooltip = makeTooltip( EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION, EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION_TOOLTIP) elif canJoin: buttonVisible = _psr.SPECIALACCOUNT not in stateReasons buttonEnabled = True else: title, tooltip, buttonVisible = makeCantJoinReasonTextVO( event, self.__playerData) if joined and outOfScore and notFull and not event.isFinished(): amount = myInfo.fullData.getLastInLeaderboardValue() parameter = event.getObjectiveParameter() titleTooltip = makeParameterTooltipVO(method, amount, parameter) playerName = getattr(BigWorld.player(), 'name', '') playerName = getFullName(playerName, myInfo.fullData.getClanTag(), myInfo.fullData.getClanColor()) myPosition = self.__myInfo.rank self.as_setStatusVisibleS(visible) self.as_setMyPlaceVisibleS(not visible and myPosition is not None) if visible: p1 = myInfo.fullData.getP1() p2 = myInfo.fullData.getP2() p3 = myInfo.fullData.getP3() self.as_setStatusDataS( makeEventBoardsTableViewStatusVO(title, tooltip, playerName, p1, p2, p3, showPoints, buttonLabel, buttonTooltip, buttonVisible, buttonEnabled, titleTooltip, method)) return