Exemplo n.º 1
0
 def getStatusData(self):
     event = self._event
     playerData = self._playerData
     anyTops = any(self.topInfos)
     title = ''
     registrationTooltip = ''
     description1 = ''
     description2 = ''
     isRegistration = self.isRegistration()
     isRegistrationButtonEnabled = True
     isRegistrationTop = False
     started = self._event.isStarted()
     titleTooltip = None
     buttonRegistrationLabel = ''
     description1Tooltip = ''
     description2Tooltip = ''
     if event.isFinished() and not anyTops:
         title = text_styles.main(EVENT_BOARDS.STATUS_PARTICIPATE_NOTPARTICIPATED)
     elif self._joined:
         title = text_styles.highTitle(EVENT_BOARDS.STATUS_BESTRESULTS_MANY)
         if self._topMeta:
             recalculationTS = self._topMeta.getLastLeaderboardRecalculationTS()
             if recalculationTS is not None:
                 if not event.isFinished():
                     description1 = text_styles.standard(formatUpdateTime(recalculationTS))
                 recalculationInterval = self._topMeta.getRecalculationInterval()
                 if recalculationInterval is not None:
                     interval = int(recalculationInterval / ONE_MINUTE)
                     description1Tooltip = makeTooltip(_ms(TOOLTIPS.SUMMARY_STATUS_TOOLTIP, interval=interval))
         if not anyTops:
             description2 = formatAttentionTextWithIcon(text_styles.neutral(EVENT_BOARDS.STATUS_PARTICIPATE_NEEDMOREBATTLES))
     elif not self._canJoin:
         title, titleTooltip, isRegistration = makeCantJoinReasonTextVO(event, playerData)
         if _psr.SPECIALACCOUNT in self._stateReasons or _psr.WASUNREGISTERED in self._stateReasons:
             title = ''
             titleTooltip = None
         buttonRegistrationLabel = EVENT_BOARDS.EXCEL_PARTICIPATE_JOIN
         isRegistrationButtonEnabled = False
     else:
         isRegistrationTop = True
         if started:
             buttonRegistrationLabel = EVENT_BOARDS.EXCEL_PARTICIPATE_JOIN
             registrationTooltip = TOOLTIPS.ELEN_BUTTON_REGISTRATION_STARTED
         else:
             buttonRegistrationLabel = EVENT_BOARDS.TABLE_SELECTREGISTRATIONBTN
             registrationTooltip = TOOLTIPS.ELEN_BUTTON_REGISTRATION_NOTSTARTED
     return {'title': title,
      'description1': description1,
      'description2': description2,
      'isRegistrationTop': isRegistrationTop,
      'isRegistration': isRegistration,
      'isRegistrationEnabled': isRegistrationButtonEnabled,
      'registrationTooltip': registrationTooltip,
      'titleTooltip': titleTooltip,
      'ratingTooltip': makeTooltip(TOOLTIPS.ELEN_BUTTON_RAITING_HEADER, TOOLTIPS.ELEN_BUTTON_RAITING_BODY),
      'isRating': started,
      'buttonRegistrationLabel': buttonRegistrationLabel,
      'description1Tooltip': description1Tooltip,
      'description2Tooltip': description2Tooltip}
Exemplo n.º 2
0
 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
 def getParticipateInfo(self):
     event = self._event
     playerData = self._playerData
     started = event.isStarted()
     isRegistrationFinished = event.isRegistrationFinished()
     participateTooltip = None
     buttonTooltip = None
     participate = ''
     buttonLabel = ''
     title = ''
     titleTooltip = ''
     isButton = False
     isButtonRegistration = not self._joined and self._canJoin and not isRegistrationFinished
     isButtonEnabled = True
     isButtonRegistrationEnabled = True
     dateTs = event.getParticipantsFreezeDeadlineTs()
     date = formatTimeAndDate(dateTs)
     if event.isFinished():
         return {}
     else:
         if started:
             buttonRegistrationLabel = EVENT_BOARDS.EXCEL_PARTICIPATE_JOIN
             buttonRegistrationTooltip = makeTooltip(
                 TOOLTIPS.ELEN_BUTTON_REGISTRATION_STARTED_HEADER,
                 TOOLTIPS.ELEN_BUTTON_REGISTRATION_STARTED_BODY)
         else:
             buttonRegistrationLabel = EVENT_BOARDS.TABLE_SELECTREGISTRATIONBTN
             buttonRegistrationTooltip = makeTooltip(
                 TOOLTIPS.ELEN_BUTTON_REGISTRATION_NOTSTARTED_HEADER,
                 TOOLTIPS.ELEN_BUTTON_REGISTRATION_NOTSTARTED_BODY)
         if self._joined:
             isButton = True
             buttonLabel = EVENT_BOARDS.HEADER_PARTICIPATE_BUTTON_LEAVE
             if isRegistrationFinished:
                 participate = formatOkTextWithIcon(
                     EVENT_BOARDS.HEADER_PARTICIPATE_STARTED)
                 participateTooltip = makeTooltip(
                     EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION,
                     TOOLTIPS.
                     ELEN_BUTTON_HEADER_PARTICIPATE_CANTLEAVE_HEADER)
                 buttonTooltip = makeTooltip(
                     TOOLTIPS.ELEN_BUTTON_HEADER_PARTICIPATE_LEAVE_HEADER,
                     _ms(TOOLTIPS.
                         ELEN_BUTTON_HEADER_PARTICIPATE_CANTLEAVE_BODY,
                         date=date))
                 isButtonEnabled = False
                 isButtonRegistrationEnabled = False
             elif started:
                 participate = formatOkTextWithIcon(
                     EVENT_BOARDS.HEADER_PARTICIPATE_STARTED)
                 participateTooltip = makeTooltip(
                     TOOLTIPS.ELEN_HEADER_PARTICIPATE_STARTED_HEADER,
                     TOOLTIPS.ELEN_HEADER_PARTICIPATE_STARTED_BODY)
                 buttonTooltip = makeTooltip(
                     TOOLTIPS.ELEN_BUTTON_HEADER_PARTICIPATE_LEAVE_HEADER,
                     _ms(TOOLTIPS.ELEN_BUTTON_HEADER_PARTICIPATE_LEAVE_BODY,
                         date=date))
             else:
                 participate = formatOkTextWithIcon(
                     EVENT_BOARDS.HEADER_PARTICIPATE_NOTSTARTED)
                 participateTooltip = makeTooltip(
                     TOOLTIPS.ELEN_HEADER_PARTICIPATE_NOTSTARTED_HEADER,
                     TOOLTIPS.ELEN_HEADER_PARTICIPATE_NOTSTARTED_BODY)
                 buttonTooltip = makeTooltip(
                     TOOLTIPS.
                     ELEN_HEADER_PARTICIPATE_BUTTON_LEAVENOTSTARTED_HEADER,
                     _ms(TOOLTIPS.
                         ELEN_HEADER_PARTICIPATE_BUTTON_LEAVENOTSTARTED_BODY,
                         date=date))
         elif isRegistrationFinished:
             participate = formatErrorTextWithIcon(
                 EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION)
             participateTooltip = makeTooltip(
                 EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION,
                 EVENT_BOARDS.STATUS_CANTJOIN_REASON_ENDREGISTRATION_TOOLTIP
             )
             isButtonEnabled = False
             isButtonRegistrationEnabled = False
         elif not self._canJoin:
             if self._stateReasons:
                 title, titleTooltip, isButtonRegistration = makeCantJoinReasonTextVO(
                     event, playerData)
                 if _psr.SPECIALACCOUNT in self._stateReasons or _psr.WASUNREGISTERED in self._stateReasons:
                     title = ''
                     titleTooltip = None
                 elif _psr.WASUNREGISTERED in self._stateReasons:
                     participateTooltip = makeTooltip(
                         EVENT_BOARDS.STATUS_CANTJOIN_REASON_LEFTEVENT,
                         EVENT_BOARDS.
                         STATUS_CANTJOIN_REASON_LEFTEVENT_TOOLTIP)
                 isButtonRegistrationEnabled = False
                 reasonText = self._cantJoinReason[self._stateReasons[0]]
                 participate = formatErrorTextWithIcon(reasonText)
         result = {
             'participate': participate,
             'participateTooltip': participateTooltip,
             'buttonLabel': buttonLabel,
             'buttonTooltip': buttonTooltip,
             'isButton': isButton,
             'isButtonEnabled': isButtonEnabled,
             'eventID': event.getEventID(),
             'title': title,
             'isButtonRegistration': isButtonRegistration,
             'isButtonRegistrationEnabled': isButtonRegistrationEnabled,
             'titleTooltip': titleTooltip,
             'buttonRegistrationTooltip': buttonRegistrationTooltip,
             'buttonRegistrationLabel': buttonRegistrationLabel
         }
         return result