def _initialize(self, *args, **kwargs): fillBonusFormula(self.viewModel.bonusFormula) with self.viewModel.transaction() as tx: tx.setMaxBonus( inPercents(CreditsBonusHelper.getMaxBonus(), digitsToRound=0)) tx.setCreditsBonus( inPercents(self._nyController.getActiveSettingBonusValue())) tx.setIsPostNYEnabled(self._nyController.isPostEvent())
def _updateCollectionData(self): super(CurrentAlbumSubModelPresenter, self)._updateCollectionData() if self._collectionType == ToySettings.MEGA_TOYS: self.viewModel.setBonusValue( inPercents(CreditsBonusHelper.getMegaToysBonus())) else: self.viewModel.setBonusValue( inPercents( CreditsBonusHelper.getCollectionFactor( self._collectionType))) self.viewModel.setCreditBonusValue( CreditsBonusHelper.getBonusInPercents()) self.__prepareNewData()
def __hangToy(self, toyID, slotID): result = yield self._nyController.hangToy(toyID, slotID) if result.success and self.isLoaded: with self.viewModel.transaction() as tx: for toyRenderer in tx.getToys(): if toyRenderer.getToyID() == toyID: toyRenderer.setBonusValue( inPercents( CreditsBonusHelper.getMegaToysBonusValue())) toyRenderer.setState(MegaToyState.INSTALLED) tx.getToys().invalidate() tx.setBonusValue( inPercents(CreditsBonusHelper.getMegaToysBonus())) tx.setCreditBonusValue(CreditsBonusHelper.getBonusInPercents())
def _onLoading(self, *args, **kwargs): super(NyCollectionBonusTooltip, self)._onLoading(*args, **kwargs) selectedCollection = args[0] collectionNames = NY20SubCollectionBuilder.ORDER[:-1] collectionBonuses = {collectionName:CreditsBonusHelper.getCollectionBonuses(collectionName) for collectionName in collectionNames} collectionLevels = CreditsBonusHelper.getCollectionLevels() with self.viewModel.transaction() as tx: tx.setSelectedCollection(selectedCollection) fillBonusFormula(self.viewModel.bonusFormula) for i, interval in enumerate(CreditsBonusHelper.getCollectionBonusLevels()): row = NyCollectionTableValueModel() fromValue, toValue = interval if toValue is not None: row.setInterval(backport.text(R.strings.ny.collectionBonusTooltip.levelsPattern(), lower=fromValue, higher=toValue)) else: row.setInterval(backport.text(R.strings.ny.collectionBonusTooltip.moreThan(), level=fromValue)) row.setIsEnabled(CreditsBonusHelper.getCollectionLevelByName(selectedCollection) == i) for collectionName in collectionNames: level = collectionLevels[collectionName] bonus = NySingleCollectionBonusModel() bonus.setValue(inPercents(collectionBonuses[collectionName][i], digitsToRound=2)) bonus.setIsEnabled(level == i) row.collectionBonuses.addViewModel(bonus) self.viewModel.collectionsTable.addViewModel(row) return
def _initialize(self, *args, **kwargs): toy = self.__itemsCache.items.festivity.getToys()[self.__toyID] hasPureSlotForToy = self.__nyController.hasPureSlotForToy(toy) with self.viewModel.transaction() as model: model.setName(toy.getName()) model.setDescription(toy.getDesc()) model.setShardsPrice(toy.getShards()) model.setIsPure(bool(self.__isPureToy)) model.setPureSlotAtmosphere( toy.getAtmosphere(self.__isPureToy, hasPureSlotForToy)) model.setBonus( inPercents(CreditsBonusHelper.getMegaToysBonusValue())) model.setIcon( toy.getIcon(size=EPIC_AWARD_SIZE) if self. __isToyIconEnabled else R.invalid()) model.setIsMaxAtmosphereLevel( self.__nyController.isMaxAtmosphereLevel()) model.setIsPostNYEnabled(self.__nyController.isPostEvent()) model.setIsFinished(self.__nyController.isFinished())
def _onLoading(self, *args, **kwargs): super(NyMegaCollectionBonusTooltip, self)._initialize(args, kwargs) ownedMegaToys = {toy.getToyType():toy.getID() for toy in self._itemsCache.items.festivity.getToys().values() if toy.isMega()} bonusValue = inPercents(CreditsBonusHelper.getMegaToysBonusValue()) slots = self._itemsCache.items.festivity.getSlots() with self.viewModel.transaction() as tx: tx.setBonusValue(bonusValue) for toyType in ToyTypes.MEGA: row = NySingleMegaCollectionBonusModel() row.setType(toyType) row.setValue(bonusValue) if toyType in ownedMegaToys: if ownedMegaToys[toyType] in slots: row.setStatus(NySingleMegaCollectionBonusModel.INSTALLED) else: row.setStatus(NySingleMegaCollectionBonusModel.NOT_INSTALLED) else: row.setStatus(NySingleMegaCollectionBonusModel.ABSENCE) tx.collectionsTable.addViewModel(row) fillBonusFormula(self.viewModel.bonusFormula)
def getBonusInPercents(cls): return inPercents(cls.getBonus())
def fillBonusFormula(formulaViewModel, nyController=None): with formulaViewModel.transaction() as tx: tx.setCreditsBonus(inPercents(nyController.getActiveSettingBonusValue())) tx.setMultiplier(nyController.getActiveMultiplier()) tx.setMegaBonus(inPercents(nyController.getActiveMegaToysBonus())) tx.setCollectionBonus(inPercents(nyController.getActiveCollectionsBonus()))