def synchronize(self, isFullSync, diff): if isFullSync: self.__cache.clear() cache = self.__cache statsDiff = diff.get('stats', None) if statsDiff is not None: for stat in _SIMPLE_VALUE_STATS: if stat in statsDiff: cache[stat] = statsDiff[stat] for stat in _DICT_STATS: stat_r = (stat, '_r') if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: synchronizeDicts(statsDiff[stat], cache.setdefault(stat, dict())) for stat in _GROWING_SET_STATS: stat_r = (stat, '_r') if stat_r in statsDiff: cache[stat] = statsDiff[stat_r] if stat in statsDiff: cache.setdefault(stat, set()).update(statsDiff[stat]) accountDiff = diff.get('account', None) if accountDiff is not None: for stat in _ACCOUNT_STATS: if stat in accountDiff: cache[stat] = accountDiff[stat] if _ADDITIONAL_XP_CACHE_KEY in accountDiff: synchronizeDicts(accountDiff[_ADDITIONAL_XP_CACHE_KEY], cache.setdefault(_ADDITIONAL_XP_CACHE_KEY, {})) if cache.get('premiumInfo') is None: cache['premiumInfo'] = PremiumInfo() premiumDiff = diff.get('premium') if premiumDiff is not None: cache['premiumInfo'].update(premiumDiff) economicsDiff = diff.get('economics', None) if economicsDiff is not None: for stat in ('unlocks', 'eliteVehicles'): if stat in economicsDiff: cache.setdefault(stat, set()).update(economicsDiff[stat]) cache.setdefault(('initial', stat), set()).update(economicsDiff[stat]) cacheDiff = diff.get('cache', None) if cacheDiff is not None: for stat in _CACHE_STATS: if stat in cacheDiff: LOG_DEBUG_DEV('CACHE stat change', stat, cacheDiff[stat]) cache[stat] = cacheDiff[stat] spaDiff = cacheDiff.get('SPA', None) if spaDiff: synchronizeDicts(spaDiff, cache.setdefault('SPA', dict())) piggyBankDiff = diff.get('piggyBank', None) if piggyBankDiff is not None: synchronizeDicts(piggyBankDiff, cache.setdefault('piggyBank', dict())) if _PREFERRED_MAPS_KEY in diff: synchronizeDicts(diff[_PREFERRED_MAPS_KEY], cache.setdefault(_PREFERRED_MAPS_KEY, {})) return
def premiumInfo(self): return self.getCacheValue('premiumInfo', PremiumInfo()).data
def activePremiumExpiryTime(self): return self.getCacheValue('premiumInfo', PremiumInfo()).activePremiumExpiryTime
def totalPremiumExpiryTime(self): return self.getCacheValue('premiumInfo', PremiumInfo()).totalPremiumExpiryTime
def isPremium(self): return self.getCacheValue('premiumInfo', PremiumInfo()).isPremium
def activePremiumType(self): return self.getCacheValue('premiumInfo', PremiumInfo()).activePremiumType
def isActivePremium(self, checkPremiumType): return self.getCacheValue( 'premiumInfo', PremiumInfo()).isActivePremium(checkPremiumType)