Ejemplo n.º 1
0
 def __init__(self, viewModel, parentView, soundConfig=None):
     super(NyGiftSystemView, self).__init__(viewModel, parentView, soundConfig)
     self._tooltips = {}
     self.__forcedSending = False
     self.__messageID = getGiftSystemRandomCongratulationID()
     self.__targetSpaID = _NOT_SELECTED_SPA_ID
     self.__notifier = PeriodicNotifier(getTimerGameDayLeft, self.__updateProgressionTimer, (ONE_MINUTE,))
 def __startNotifier(self):
     if self.__periodicNotifier is None and self.__currentBlock.state != EventBlockStates.FINISHED:
         self.__periodicNotifier = PeriodicNotifier(
             self.__getTimeLeft, self.__updateCurrentBlockOnTimeChanged,
             (time_utils.ONE_MINUTE, ))
         self.__periodicNotifier.startNotification()
     return
Ejemplo n.º 3
0
 def _populate(self):
     super(EpicBattlesWidget, self)._populate()
     if not self.__eventProgression.isAvailable():
         return
     else:
         if self.__periodicNotifier is None:
             self.__periodicNotifier = PeriodicNotifier(self.__eventProgression.getTimer, self.update)
         self.__periodicNotifier.startNotification()
         return
Ejemplo n.º 4
0
 def _populate(self):
     super(EpicBattlesWidget, self)._populate()
     if not self.__epicController.isEnabled():
         return
     else:
         if self.__periodicNotifier is None:
             self.__periodicNotifier = PeriodicNotifier(
                 self.__epicController.getTimer, self.update)
         self.__periodicNotifier.startNotification()
         return
 def _populate(self):
     super(EpicBattlesWidget, self)._populate()
     if not self.__epicController.isEnabled():
         return
     else:
         if self.__periodicNotifier is None:
             self.__periodicNotifier = PeriodicNotifier(
                 self.__epicController.getTimer, self.update)
         self.__periodicNotifier.startNotification()
         g_clientUpdateManager.addCallbacks(
             {'tokens': self.__onTokensUpdate})
         return
Ejemplo n.º 6
0
 def _populate(self):
     super(RankedBattlesSeasonGapView, self)._populate()
     self.__rankedController.onUpdated += self.__update
     g_clientUpdateManager.addCallbacks({'tokens': self.__onTokensUpdate})
     self.__prevSeason = self.__rankedController.getPreviousSeason()
     self.__dossier = self.__itemsCache.items.getAccountDossier(
     ).getSeasonRankedStats(
         RankedDossierKeys.SEASON % self.__prevSeason.getNumber(),
         self.__prevSeason.getSeasonID())
     self.__periodicNotifier = PeriodicNotifier(self.__getTillUpdateTime,
                                                self.__update)
     self.__update()
     self.__periodicNotifier.startNotification()
 def _onLoading(self, *args, **kwargs):
     super(WotPlusPiggyBankCard, self)._onLoading()
     self._addListeners()
     self._notifier = PeriodicNotifier(self._getDeltaTime, self._updateTimer, (time_utils.ONE_MINUTE,))
     self._isTimerEnabled = False
     self._premState = BankState.AVAILABLE
     self._wotPlusState = BankState.AVAILABLE
     with self.viewModel.transaction() as model:
         self._setMaxAmounts(model=model)
         self._setCurrentCredits(model=model)
         self._setCurrentGold(model=model)
         self._updatePremState(model=model)
         self._updateWotPlusState(model=model)
         self._updateTimer(model=model)
Ejemplo n.º 8
0
 def onLobbyInited(self, _):
     self.__tankmanLiveTime = g_itemsCache.items.shop.tankmenRestoreConfig.goldDuration
     self.addNotificator(PeriodicNotifier(self.__getClosestTankmanUpdateTime, self.__updateTankmenList))
     if self.__restoreNotifyTimeCallback is None:
         self.__startRestoreTimeNotifyCallback()
     self.__checkLimitedRestoreNotification()
     return
 def init(self):
     self.addNotificators(
         PeriodicNotifier(self.__getClosestPremiumNotification,
                          self.__notifyPremiumTime),
         PeriodicNotifier(lambda: self.NOTIFY_PERIOD, self.__notifyClient),
         PeriodicNotifier(self.__getClosestNewDayNotification,
                          self.__notifyNewDay))
     self.__sessionStartedAt = -1
     self.__banCallback = None
     self.__lastBanMsg = None
     self.__curfewBlockTime = None
     self.__curfewUnblockTime = None
     self.__doNotifyInStart = False
     self.__battles = 0
     LOG_DEBUG('GameSessionController::init')
     return
 def init(self):
     super(BattleRoyaleController, self).init()
     self.__voControl = BRVoiceOverController()
     self.__voControl.init()
     self.__urlMacros = URLMacros()
     self.addNotificator(SimpleNotifier(self.getTimer, self.__timerUpdate))
     self.addNotificator(PeriodicNotifier(self.getTimer, self.__timerTick))
Ejemplo n.º 11
0
 def __init__(self, clubDbID, subscriptionType, clubsCtrl = None):
     super(_Subscription, self).__init__()
     self.__clubDbID = clubDbID
     self.__subscriptionType = subscriptionType
     self.__club = None
     self.__state = SUBSCRIPTION_STATE.NOT_SUBSCRIBED
     self.__lastRequestTime = -1
     if clubsCtrl is not None:
         self.__clubsCtrl = weakref.proxy(clubsCtrl)
     else:
         self.__clubsCtrl = None
     self.addNotificator(PeriodicNotifier(lambda : _SET - 10.0, BoundMethodWeakref(self._onSubscriptionUpdate), (_SET,)))
     self.__comparators = [SimpleTypeComparator('name', 'onClubNameChanged', 'getUserName'),
      SimpleTypeComparator('description', 'onClubDescriptionChanged', 'getUserDescription'),
      SimpleTypeComparator('owner', 'onClubOwnerChanged', 'getOwnerDbID'),
      SimpleTypeComparator('state', 'onClubStateChanged', 'getState'),
      SimpleTypeComparator('ladder', 'onClubLadderInfoChanged', 'getLadderInfo'),
      SimpleTypeComparator('members', 'onClubMembersChanged', 'getMembers'),
      SimpleTypeComparator('membersExtras', 'onClubMembersChanged', 'getMembers'),
      SimpleTypeComparator('invites', 'onClubInvitesChanged', 'getInvites'),
      SimpleTypeComparator('applicants', 'onClubApplicantsChanged', 'getApplicants'),
      SimpleTypeComparator('restrictions', 'onClubRestrictionsChanged', 'getRestrictions'),
      SimpleTypeComparator('minWinRate', 'onClubApplicantsRequirementsChanged', 'getApplicantsRequirements'),
      SimpleTypeComparator('minBattleCount', 'onClubApplicantsRequirementsChanged', 'getApplicantsRequirements'),
      SimpleTypeComparator('shortDescription', 'onClubApplicantsRequirementsChanged', 'getApplicantsRequirements')]
     return
Ejemplo n.º 12
0
class RankedMainSeasonOnPage(RankedMainPage):
    _COMMON_SOUND_SPACE = RANKED_MAIN_PAGE_SOUND_SPACE
    __rankedController = dependency.descriptor(IRankedBattlesController)

    def __init__(self, ctx):
        super(RankedMainSeasonOnPage, self).__init__(ctx)
        self.__currentSeason = None
        self.__periodicNotifier = PeriodicNotifier(self.__getTimeTillCurrentSeasonEnd, self._updateHeader)
        return

    def _dispose(self):
        self.__periodicNotifier.stopNotification()
        self.__periodicNotifier.clear()
        super(RankedMainSeasonOnPage, self)._dispose()

    def _populate(self):
        super(RankedMainSeasonOnPage, self)._populate()
        self.__periodicNotifier.startNotification()

    def _onRegisterFlashComponent(self, viewPy, alias):
        if alias == RANKEDBATTLES_ALIASES.RANKED_BATTLES_REWARDS_UI and self.__selectedRewardsItemID is not None:
            viewPy.setActiveTab(self.__selectedRewardsItemID)
            self.__selectedRewardsItemID = None
        return

    def _update(self):
        self.__currentSeason = self.__rankedController.getCurrentSeason()
        self.__periodicNotifier.startNotification()
        super(RankedMainSeasonOnPage, self)._update()

    def _updateHeader(self):
        self.as_setHeaderDataS(main_page_vos.getRankedMainSeasonOnHeader(self.__currentSeason, self._selectedItemID))

    def _updateMenuItems(self, isRankedShopEnabled, isYearLBEnabled, yearLBSize):
        leagues = self.__rankedController.isAccountMastered()
        menuItems = main_page_vos.getRankedMainSeasonOnItems(isRankedShopEnabled, isYearLBEnabled, yearLBSize, leagues)
        self.as_setDataS({'menuItems': menuItems,
         'selectedIndex': self._getSelectedIdx(menuItems)})

    def _updateSounds(self, onClose=False):
        super(RankedMainSeasonOnPage, self)._updateSounds()
        soundManager = self.__rankedController.getSoundManager()
        if self.__rankedController.isAccountMastered():
            soundManager.setProgressSound()
        elif onClose:
            soundManager.setDefaultProgressSound()
        else:
            soundManager.setProgressSound(self.__rankedController.getCurrentDivision().getUserID())

    def _processContext(self, ctx):
        super(RankedMainSeasonOnPage, self)._processContext(ctx)
        self.__selectedRewardsItemID = ctx.get('rewardsSelectedTab', None)
        return

    def __getTimeTillCurrentSeasonEnd(self):
        return time_utils.getTimeDeltaFromNowInLocal(time_utils.makeLocalServerTime(self.__currentSeason.getEndDate())) if self.__currentSeason else time_utils.ONE_MINUTE
Ejemplo n.º 13
0
 def __reloadNotification(self):
     self.clearNotification()
     timePeriod = self.__getClosestStatusUpdateTime()
     if timePeriod:
         self.addNotificator(
             PeriodicNotifier(self.__getClosestStatusUpdateTime,
                              self.__updateFlagState))
         self.startNotification()
 def init(self):
     super(EpicBattleMetaGameController, self).init()
     self.__urlMacros = URLMacros()
     self.addNotificator(SimpleNotifier(self.getTimer, self.__timerUpdate))
     self.addNotificator(PeriodicNotifier(self.getTimer, self.__timerTick))
     self.__eventEndedNotifier = SimpleNotifier(self.getEventTimeLeft,
                                                self.__onEventEnded)
     self.addNotificator(self.__eventEndedNotifier)
Ejemplo n.º 15
0
 def _onLoading(self, *args, **kwargs):
     super(BattlePassProgressionsView, self)._onLoading()
     self.__addListeners()
     self.__notifier = Notifiable()
     self.__notifier.addNotificator(
         PeriodicNotifier(self.__battlePassController.getSeasonTimeLeft,
                          self.__updateTimer))
     self.__notifier.addNotificator(
         PeriodicNotifier(
             self.__battlePassController.getSellAnyLevelsUnlockTimeLeft,
             self.__updateTimer))
     self.__notifier.addNotificator(
         SimpleNotifier(self.__battlePassController.getFinalOfferTimeLeft,
                        self.__updateTimer))
     self.__notifier.startNotification()
     self.__updateProgressData()
     self.__updateBuyButtonState()
     self.__updateExtrasAndVotingButtons()
Ejemplo n.º 16
0
 def onLobbyInited(self, event):
     self.itemsCache.onSyncCompleted += self._update
     self.__notificatorManager.addNotificator(
         PeriodicNotifier(self.__timeTillNextReserveTick,
                          self.onReserveTimerTick,
                          (time_utils.ONE_MINUTE, )))
     self.__notificatorManager.startNotification()
     if self.__boosterNotifyTimeCallback is None:
         self.__startBoosterTimeNotifyCallback()
     return
Ejemplo n.º 17
0
 def start(self):
     if not self.isPlaying():
         SOUND_DEBUG('Start playing sound event', self._soundEventID, self._params)
         _MC.g_musicController.play(self._soundEventID, self._params)
         if self._checkFinish:
             self._isStarted = True
             self.addNotificators(PeriodicNotifier(self._getNotificationDelta, self._onCheckAmbientNotification, (PLAYING_SOUND_CHECK_PERIOD,)))
             self.startNotification()
             self.onStarted()
     else:
         SOUND_DEBUG('Sound is already playing', self._soundEventID, self._params)
 def _onLoading(self, *args, **kwargs):
     super(BattlePassProgressionsView, self)._onLoading()
     self.__notifier = Notifiable()
     self.__notifier.addNotificator(
         PeriodicNotifier(self.__battlePass.getSeasonTimeLeft,
                          self.__updateTimer))
     self.__notifier.addNotificator(
         SimpleNotifier(self.__battlePass.getFinalOfferTimeLeft,
                        self.__updateTimer))
     self.__notifier.startNotification()
     self.__updateProgressData()
     self.__updateBuyButtonState()
Ejemplo n.º 19
0
 def _onLoading(self, *args, **kwargs):
     super(BattlePassBuyView, self)._onLoading(*args, **kwargs)
     self.__addListeners()
     self.__notifications.addNotificator(
         PeriodicNotifier(self.__timeTillUnlock, self.__updateUnlockTimes))
     with self.viewModel.transaction() as tx:
         tx.setIsBattlePassBought(self.__battlePassController.isBought())
         tx.setIsWalletAvailable(self.__wallet.isAvailable)
     self.__packages = generatePackages()
     self.__setPackages()
     switchHangarOverlaySoundFilter(on=True)
     self.__notifications.startNotification()
 def init(self):
     self.__timeTillKickNotifier = AcyclicNotifier(self.__getClosestTimeTillKickNotification, self.__notifyTimeTillKick)
     self.addNotificators(PeriodicNotifier(self.__getClosestPremiumNotification, self.__notifyPremiumTime), SimpleNotifier(self.__getClosestSessionTimeNotification, self.__notifyClient), PeriodicNotifier(self.__getClosestNewDayNotification, self.__notifyNewDay), self.__timeTillKickNotifier)
     self.__sessionStartedAt = -1
     self.__banCallback = None
     self.__lastBanMsg = None
     self.__curfewBlockTime = None
     self.__curfewUnblockTime = None
     self.__doNotifyInStart = False
     self.__battles = 0
     self.__lastNotifyTime = None
     LOG_DEBUG('GameSessionController::init')
     return
 def _populate(self):
     super(ReferralManagementWindow, self)._populate()
     self.startGlobalListening()
     g_messengerEvents.users.onUserStatusUpdated += self.__onUserStatusUpdated
     g_messengerEvents.users.onUserActionReceived += self.__onUserRosterChanged
     g_messengerEvents.users.onUsersListReceived += self.__onUsersListReceived
     g_messengerEvents.users.onClanMembersListChanged += self.__onClanMembersListChanged
     refSystem = game_control.g_instance.refSystem
     refSystem.onUpdated += self.__onRefSystemUpdated
     refSystem.onQuestsUpdated += self.__onRefSystemQuestsUpdated
     self.addNotificator(PeriodicNotifier(self.__getClosestNotification, self.__update, (time_utils.ONE_MINUTE,)))
     self.startNotification()
     self.__update()
Ejemplo n.º 22
0
class RankedBattlesUnreachableView(LobbySubView,
                                   RankedBattlesUnreachableViewMeta):
    __rankedController = dependency.descriptor(IRankedBattlesController)
    _COMMON_SOUND_SPACE = RANKED_SUBVIEW_SOUND_SPACE
    __background_alpha__ = 0.5

    def __init__(self, _):
        super(RankedBattlesUnreachableView, self).__init__()
        self.__currentSeason = None
        self.__periodicNotifier = PeriodicNotifier(
            self.__timeTillCurrentSeasonEnd, self.__updateData)
        return

    def onEscapePress(self):
        self.__close()

    def onCloseBtnClick(self):
        self.__close()

    def _populate(self):
        super(RankedBattlesUnreachableView, self)._populate()
        self.__rankedController.onUpdated += self.__update
        self.__update()

    def _dispose(self):
        self.__periodicNotifier.stopNotification()
        self.__periodicNotifier.clear()
        self.__rankedController.onUpdated -= self.__update
        super(RankedBattlesUnreachableView, self)._dispose()

    def __close(self):
        self.fireEvent(events.LoadViewEvent(VIEW_ALIAS.LOBBY_HANGAR),
                       scope=EVENT_BUS_SCOPE.LOBBY)
        self.destroy()

    def __checkDestroy(self):
        if self.__currentSeason is None:
            self.__close()
        return

    def __timeTillCurrentSeasonEnd(self):
        if self.__currentSeason:
            seasonEnd = time_utils.makeLocalServerTime(
                self.__currentSeason.getEndDate())
            return time_utils.getTimeDeltaFromNowInLocal(seasonEnd)
        return time_utils.ONE_MINUTE

    def __update(self):
        self.__currentSeason = self.__rankedController.getCurrentSeason()
        self.__checkDestroy()
        self.__periodicNotifier.startNotification()
        self.__updateData()

    def __updateData(self):
        minLvl, maxLvl = self.__rankedController.getSuitableVehicleLevels()
        self.as_setDataS(getUnreachableVO(self.__currentSeason, minLvl,
                                          maxLvl))
Ejemplo n.º 23
0
class NyBroTokenTooltip(ViewImpl):
    __slots__ = ('__notifier',)
    __eventsCache = dependency.descriptor(IEventsCache)
    __itemsCache = dependency.descriptor(IItemsCache)
    __uiLogger = NyGiftSystemViewTooltipLogger(LogGroups.BRO_ICON.value)

    def __init__(self, layoutID=R.views.lobby.new_year.tooltips.NyBroTokenTooltip()):
        super(NyBroTokenTooltip, self).__init__(ViewSettings(layoutID, model=NyBroTokenTooltipModel()))
        self.__notifier = PeriodicNotifier(getTimerGameDayLeft, self.__updateClearingTimer, (ONE_MINUTE,))

    @property
    def viewModel(self):
        return super(NyBroTokenTooltip, self).getViewModel()

    def _onLoading(self, *args, **kwargs):
        super(NyBroTokenTooltip, self)._onLoading()
        with self.viewModel.transaction() as model:
            self.__updateProgression(model=model)
            self.__updateClearingTimer()
        self.__notifier.startNotification()

    def _onLoaded(self, *args, **kwargs):
        super(NyBroTokenTooltip, self)._onLoaded(*args, **kwargs)
        self.__uiLogger.onTooltipOpened()

    def _initialize(self, *args, **kwargs):
        super(NyBroTokenTooltip, self)._initialize()
        self.__eventsCache.onSyncCompleted += self.__updateProgression

    def _finalize(self):
        super(NyBroTokenTooltip, self)._finalize()
        self.__eventsCache.onSyncCompleted -= self.__updateProgression
        self.__notifier.stopNotification()
        self.__notifier.clear()
        self.__uiLogger.onTooltipClosed()

    def __invalidateStages(self, requiredAmount):
        requiredAmount.clear()
        progressQuests = self.__eventsCache.getHiddenQuests(giftsPogressQuestFilter)
        for quest in sorted(progressQuests.itervalues(), key=lambda q: q.getID()):
            requiredAmount.addNumber(getGiftsTokensCountByID(quest.getID()))

        requiredAmount.invalidate()

    def __updateClearingTimer(self):
        self.viewModel.setRebootTimer(getDayTimeLeft())

    @replaceNoneKwargsModel
    def __updateProgression(self, model=None):
        subprogressQuests = self.__eventsCache.getHiddenQuests(giftsSubprogressQuestFilter)
        subprogressQuest = subprogressQuests.itervalues().next() if subprogressQuests else None
        model.setCurrentCount(self.__itemsCache.items.tokens.getTokenCount(NY_GIFT_SYSTEM_SUBPROGRESS_TOKEN))
        model.setTotalCount(getGiftsTokensCountByID(subprogressQuest.getID()) if subprogressQuest else 0)
        self.__invalidateStages(model.getAmountRequired())
        return
 def _populate(self):
     super(PrimeTimeViewBase, self)._populate()
     self.__serversDP = self._getAllServersDP()
     self.__serversDP.setFlashObject(self.as_getServersDPS())
     self.__updateList()
     self.__updateData()
     self._getController().onUpdated += self.__onControllerUpdated
     if not constants.IS_CHINA:
         if GUI_SETTINGS.csisRequestRate == REQUEST_RATE.ALWAYS:
             g_preDefinedHosts.startCSISUpdate()
         g_preDefinedHosts.onCsisQueryStart += self.__onServersUpdate
         g_preDefinedHosts.onCsisQueryComplete += self.__onServersUpdate
         g_preDefinedHosts.onPingPerformed += self.__onServersUpdate
     self.addNotificators(
         PeriodicNotifier(self.__getPeriodUpdateTime,
                          self.__onPeriodUpdate),
         SimpleNotifier(self.__getSimpleUpdateTime, self.__onSimpleUpdate))
     self.startNotification()
Ejemplo n.º 25
0
 def _populate(self):
     super(PrimeTimeViewBase, self)._populate()
     self.__serversDP = self.__buildDataProvider()
     self.__serversDP.setFlashObject(self.as_getServersDPS())
     self.__updateServersList()
     self.__updateSelectedServer()
     self.__updateSelectedServerData()
     self._getController().onUpdated += self.__onControllerUpdated
     if not constants.IS_CHINA:
         if GUI_SETTINGS.csisRequestRate == REQUEST_RATE.ALWAYS:
             g_preDefinedHosts.startCSISUpdate()
         g_preDefinedHosts.onCsisQueryStart += self.__onServersUpdate
         g_preDefinedHosts.onCsisQueryComplete += self.__onServersUpdate
         g_preDefinedHosts.onPingPerformed += self.__onServersUpdate
     self.addNotificators(
         PeriodicNotifier(self.__getInfoUpdatePeriod,
                          self.__onNotifierTriggered,
                          periods=(time_utils.ONE_MINUTE, )))
     self.startNotification()
class WotPlusPiggyBankCard(ViewImpl):
    _lobbyContext = dependency.descriptor(ILobbyContext)
    _itemsCache = dependency.descriptor(IItemsCache)
    _gameSession = dependency.descriptor(IGameSessionController)

    def __init__(self):
        settings = ViewSettings(R.views.lobby.premacc.dashboard.piggy_bank_cards.wot_plus_piggy_bank.WotPlusPiggyBankCard())
        settings.model = WotPlusPiggyBankCardModel()
        self._notifier = None
        self._premState = None
        self._wotPlusState = None
        self._wotPlusInfo = BigWorld.player().renewableSubscription
        super(WotPlusPiggyBankCard, self).__init__(settings)
        return

    @property
    def viewModel(self):
        return super(WotPlusPiggyBankCard, self).getViewModel()

    def _onLoading(self, *args, **kwargs):
        super(WotPlusPiggyBankCard, self)._onLoading()
        self._addListeners()
        self._notifier = PeriodicNotifier(self._getDeltaTime, self._updateTimer, (time_utils.ONE_MINUTE,))
        self._isTimerEnabled = False
        self._premState = BankState.AVAILABLE
        self._wotPlusState = BankState.AVAILABLE
        with self.viewModel.transaction() as model:
            self._setMaxAmounts(model=model)
            self._setCurrentCredits(model=model)
            self._setCurrentGold(model=model)
            self._updatePremState(model=model)
            self._updateWotPlusState(model=model)
            self._updateTimer(model=model)

    def _finalize(self):
        self._notifier.stopNotification()
        self._notifier.clear()
        self._notifier = None
        self._removeListeners()
        super(WotPlusPiggyBankCard, self)._finalize()
        return

    @replaceNoneKwargsModel
    def _setMaxAmounts(self, model=None):
        serverSettings = self._lobbyContext.getServerSettings()
        maxAmount = serverSettings.getPiggyBankConfig().get('creditsThreshold', PiggyBankConstants.MAX_AMOUNT)
        maxAmountStr = self.gui.systemLocale.getNumberFormat(maxAmount)
        model.setCreditMaxAmount(maxAmountStr)
        maxAmount = serverSettings.getRenewableSubMaxGoldReserveCapacity()
        maxAmountStr = self.gui.systemLocale.getNumberFormat(maxAmount)
        model.setGoldMaxAmount(maxAmountStr)

    @replaceNoneKwargsModel
    def _setCurrentCredits(self, value=None, model=None):
        creditsValue = value or self._itemsCache.items.stats.piggyBank.get('credits', 0)
        creditsValueStr = self.gui.systemLocale.getNumberFormat(creditsValue)
        model.setCreditCurrentAmount(creditsValueStr)

    def _updateCredits(self, value=None):
        self._setCurrentCredits(value)

    @replaceNoneKwargsModel
    def _setCurrentGold(self, gold=None, model=None):
        goldValue = gold or self._itemsCache.items.stats.piggyBank.get('gold', 0)
        goldValueStr = self.gui.systemLocale.getNumberFormat(goldValue)
        model.setGoldCurrentAmount(goldValueStr)

    def _updateGold(self, gold=None):
        self._setCurrentGold(gold)

    @replaceNoneKwargsModel
    def _updatePremState(self, model=None):
        serverSettings = self._lobbyContext.getServerSettings()
        isEnabled = serverSettings.getPiggyBankConfig().get('enabled', False)
        hasPremium = self._itemsCache.items.stats.isActivePremium(PREMIUM_TYPE.PLUS)
        state = BankState.AVAILABLE
        if not isEnabled:
            state = BankState.DISABLE
        elif hasPremium:
            state = BankState.ACTIVE
        if self._premState != state:
            self._premState = state
            self._updateTimerStatus()
        model.setPremState(state.value)

    def _updatePrem(self, *args):
        self._updatePremState()

    @replaceNoneKwargsModel
    def _updateWotPlusState(self, model=None):
        serverSettings = self._lobbyContext.getServerSettings()
        isGoldEnabled = serverSettings.isRenewableSubGoldReserveEnabled()
        hasWotPlus = self._wotPlusInfo.isEnabled()
        state = BankState.AVAILABLE
        if not isGoldEnabled:
            state = BankState.DISABLE
        elif hasWotPlus:
            state = BankState.ACTIVE
        if self._wotPlusState != state:
            self._wotPlusState = state
            self._updateTimerStatus()
        model.setWotPlusState(state.value)

    @replaceNoneKwargsModel
    def _updateTimer(self, model=None):
        isTimerEnabled = self._getIsTimerEnabled()
        if not isTimerEnabled:
            return
        finishDeltatime = self._getDeltaTime()
        model.setTimeToOpen(finishDeltatime)

    def _getDeltaTime(self):
        serverSettings = self._lobbyContext.getServerSettings()
        config = serverSettings.getPiggyBankConfig()
        data = self._itemsCache.items.stats.piggyBank
        return getDeltaTimeHelper(config, data)

    def _getIsTimerEnabled(self):
        hasGold = self._itemsCache.items.stats.piggyBank.get('gold', 0)
        hasCredits = self._itemsCache.items.stats.piggyBank.get('credits', 0)
        return self._wotPlusState == BankState.ACTIVE or self._premState == BankState.ACTIVE or hasCredits or hasGold

    def _updateTimerStatus(self):
        isTimerEnabled = self._getIsTimerEnabled()
        if self._isTimerEnabled != isTimerEnabled:
            self._isTimerEnabled = isTimerEnabled
            if isTimerEnabled:
                self._notifier.startNotification()
                self._updateTimer()
            else:
                self._notifier.stopNotification()
        elif isTimerEnabled:
            self._notifier.startNotification()
            self._updateTimer()

    def _updateLastSmashTimestamp(self, *args):
        self._updateTimerStatus()

    def _onServerSettingsChange(self, diff):
        if self.viewStatus == ViewStatus.DESTROYED:
            return
        if PremiumConfigs.PIGGYBANK not in diff and RENEWABLE_SUBSCRIPTION_CONFIG not in diff:
            return
        diffConfigPiggy = diff.get(PremiumConfigs.PIGGYBANK)
        diffConfigGold = diff.get(RENEWABLE_SUBSCRIPTION_CONFIG)
        if 'creditsThreshold' in diffConfigPiggy or 'maxGoldReserveCapacity' in diffConfigGold:
            self._setMaxAmounts()
        if 'enabled' in diffConfigPiggy:
            self._updatePremState()
        if 'enableGoldReserve' in diffConfigGold:
            self._updateWotPlusState()
        if 'cycleLength' in diffConfigPiggy or 'cycleStartTime' in diffConfigPiggy:
            self._updateTimerStatus()

    def _onWotPlusDataChanged(self, diff):
        if 'isEnabled' in diff:
            self._updateWotPlusState()

    def __onCardClick(self):
        showPiggyBankView()

    def _addListeners(self):
        self.viewModel.onCardClick += self.__onCardClick
        g_clientUpdateManager.addCallbacks({PiggyBankConstants.PIGGY_BANK_CREDITS: self._updateCredits,
         PiggyBankConstants.PIGGY_BANK_GOLD: self._updateGold,
         PiggyBankConstants.PIGGY_BANK_SMASH_TIMESTAMP_CREDITS: self._updateLastSmashTimestamp,
         PiggyBankConstants.PIGGY_BANK_SMASH_TIMESTAMP_GOLD: self._updateLastSmashTimestamp})
        self._gameSession.onPremiumNotify += self._updatePrem
        self._wotPlusInfo.onRenewableSubscriptionDataChanged += self._onWotPlusDataChanged
        self._lobbyContext.getServerSettings().onServerSettingsChange += self._onServerSettingsChange

    def _removeListeners(self):
        self.viewModel.onCardClick -= self.__onCardClick
        g_clientUpdateManager.removeObjectCallbacks(self)
        self._gameSession.onPremiumNotify -= self._updatePrem
        self._wotPlusInfo.onRenewableSubscriptionDataChanged -= self._onWotPlusDataChanged
        self._lobbyContext.getServerSettings().onServerSettingsChange -= self._onServerSettingsChange
Ejemplo n.º 27
0
 def init(self):
     self.addNotificators(
         PeriodicNotifier(
             lambda: _UPDATE_LOCKS_PERIOD, lambda: self.onClanLockUpdate(
                 self.__lockedVehicles, self.__isFullLock)))
Ejemplo n.º 28
0
 def init(self):
     self.itemsCache.onSyncCompleted += self._update
     self.addNotificator(
         PeriodicNotifier(self.__getClosestTankmanUpdateTime,
                          self.__updateTankmenList))
Ejemplo n.º 29
0
 def __createNotifier(self):
     return None if self.__notifierState not in _ENABLED_EVENT_NOTIFIER_STATES else PeriodicNotifier(self.__getTimeLeft, self.__updateTimer, self.__getPeriods())
Ejemplo n.º 30
0
 def onLobbyInited(self):
     self.addNotificator(
         PeriodicNotifier(self.__timeTillNextNotification, self.__notify))
     self.startNotification()