Exemple #1
0
 def onFilterChange(self, type, index):
     oldPrice = self._newYearController.getPriceForCraft(
         self.__toyType, self.__toyNation, self.__toyLevel)
     if type == NY_CONSTANTS.TYPES_SECTION:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_TYPE_OR_LEVEL)
         self.__toyType = toyTypeByIndex(index)
     elif type == NY_CONSTANTS.LEVELS_SECTION:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_TYPE_OR_LEVEL)
         self.__toyLevel = toyLevelByIndex(index)
     elif type == NY_CONSTANTS.NATIONS_SECTION:
         self.__toyNation = toyNationByIndex(index)
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_SELECT_SETTING)
         NYSoundEvents.setBoxSwitch(self.__toyNation)
     newPrice = self._newYearController.getPriceForCraft(
         self.__toyType, self.__toyNation, self.__toyLevel)
     fragments = self._newYearController.getToyFragments()
     if newPrice > fragments >= oldPrice:
         NYSoundEvents.playSound(NYSoundEvents.CRAFT_COST_SAME)
     if newPrice != oldPrice:
         NYSoundEvents.playSound(
             NYSoundEvents.CRAFT_COST_INCREASED
             if newPrice > oldPrice else NYSoundEvents.CRAFT_COST_DECREASED)
     NYSoundEvents.playSound(NYSoundEvents.CRAFT_MACHINE_ANIMATION)
     selectedToy = {
         'type': self.__toyType,
         'level': self.__toyLevel,
         'nation': self.__toyNation
     }
     self.newYearUIManager.setSelectedCraftToy(selectedToy)
     self.__updatePrice()
Exemple #2
0
    def _populate(self):
        super(NYCollections, self)._populate()
        levelSettings = self._newYearUIManager.getSelectedCollectionLevels()
        if levelSettings:
            self.__navigation = levelSettings
        else:
            for toyId in self._newYearController.receivedToysCollection:
                toy = g_cache.toys[toyId]
                self.__navigation[toy.setting] = max(
                    toy.rank - 1, self.__navigation[toy.setting])

            self._newYearUIManager.setSelectedCollectionLevels(
                self.__navigation)
        data = _DEF_DATA
        data['selectedSettings'] = self.__selectedSetting
        data['selectedLevel'] = [{
            'nation': nation,
            'selectedLevel': level
        } for nation, level in self.__navigation.iteritems()]
        data['nationOrder'] = sorted(NATIONAL_SETTINGS,
                                     key=lambda s: self._newYearController.
                                     getSettingIndexInNationsOrder(s))
        self.as_setDataS(data)
        self._newYearController.onToyCollectionChanged += self.__onToyCollectionChanged
        self.__updateDataByLevel(self.__navigation[self.__selectedSetting] + 1)
        NYSoundEvents.setBoxSwitch(self.__selectedSetting)
 def __restartAnimation(self):
     setting_id = self.__getOpeningBoxSettingID()
     if setting_id is not None:
         LOG_DEBUG('Box "{}" animation restarting.'.format(setting_id))
         animMapping = BOX_ANIM_MAPPING_LOW if self.__isNeedLowQualityAnim(
         ) else BOX_ANIM_MAPPING
         self.as_restartAnimationS(animMapping.get(setting_id))
         NYSoundEvents.setBoxSwitch(setting_id)
     return