def __setBattleSettingsStatus(self):
        if self.__sessionStatsSettings.validateSettings(
                self.__currentSettings):
            textStyle = text_styles.neutral
            warningFlag = False
        else:
            textStyle = text_styles.error
            warningFlag = self.__lastChangedIdentifier in SESSION_STATS.getEfficiencyBlock(
            )
        parameters = list(SESSION_STATS.getEfficiencyBlock())
        for parameter in SESSION_STATS.getImmutableEfficiencyBlockParameters():
            parameters.remove(parameter)

        maxSelectedItems = MAX_STATS - len(
            SESSION_STATS.getImmutableEfficiencyBlockParameters())
        numberSelectedItems = sum(
            [self.__currentSettings[key] for key in parameters])
        self.as_setBattleSettingsStatusS(
            text_styles.main(
                backport.text(
                    R.strings.session_stats.settings.efficiencyBlock.subheader(
                    ),
                    selected=textStyle(toIntegral(numberSelectedItems)),
                    max=text_styles.main(toIntegral(maxSelectedItems)))),
            warningFlag)
 def __getControlsData(self):
     enableApplyBtn = self.__sessionStatsSettings.validateSettings(
         self.__currentSettings)
     warning = {}
     if not enableApplyBtn:
         maxStats = MAX_STATS - len(
             SESSION_STATS.getImmutableEfficiencyBlockParameters())
         text = backport.text(
             R.strings.session_stats.settings.efficiencyBlock.error(),
             max=maxStats)
         warning['text'] = text_styles.alert(text)
         warning['icon'] = backport.image(
             R.images.gui.maps.icons.library.alertBigIcon())
     else:
         enableApplyBtn = self.__currentSettings != self.__sessionStatsSettings.getSettings(
         )
     return {
         'warning':
         warning,
         'states': [{
             'btnEnabled':
             enableApplyBtn,
             'btnLabel':
             backport.text(
                 R.strings.session_stats.settings.controls.applyBtn())
         }, {
             'btnEnabled':
             True,
             'btnLabel':
             backport.text(
                 R.strings.session_stats.settings.controls.backBtn())
         }]
     }
    def __getBattlesBlock(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getEfficiencyBlock():
            if key in SESSION_STATS.getImmutableEfficiencyBlockParameters():
                continue
            inputs.append({
                'id': key,
                'label': _EFFICIENCY_BLOCK[key]['label'],
                'tooltip': _EFFICIENCY_BLOCK[key]['tooltip'],
                'selected': bool(settings[key])
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(R.strings.session_stats.settings.efficiencyBlock.
                              header())),
            'inputs':
            inputs
        }
Beispiel #4
0
 def __makeVO(self):
     data = self.itemsCache.items.sessionStats.getAccountStats(
         ARENA_BONUS_TYPE.REGULAR)
     parameters = SESSION_STATS.getAccountEfficiencyBlock()
     return {
         'collapseLabel':
         text_styles.middleTitle(
             backport.text(
                 R.strings.session_stats.label.battleEfficiency())),
         'lastBattle':
         packLastBattleData(data),
         'total':
         packTotalData(data),
         'battleEfficiency':
         packBattleEfficiencyData(data, parameters)
     }
    def __getCommonBlocks(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getCommonBlock():
            inputs.append({
                'id': key,
                'label': _COMMON_BLOCK[key]['label'],
                'tooltip': _COMMON_BLOCK[key]['tooltip'],
                'selected': bool(settings[key])
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(
                    R.strings.session_stats.settings.commonSettings.header())),
            'inputs':
            inputs
        }
    def __getEconomicsBlock(self):
        settings = self.__currentSettings
        inputs = []
        for key in SESSION_STATS.getEconomicBlockView():
            inputs.append({
                'id': str(key),
                'label': _ECONOMIC_BLOCK_VIEW[key]['label']
            })

        return {
            'title':
            text_styles.highlightText(
                backport.text(
                    R.strings.session_stats.settings.economicBlock.header())),
            'selectedRadioIndex':
            settings[SESSION_STATS.ECONOMIC_BLOCK_VIEW],
            'id':
            SESSION_STATS.ECONOMIC_BLOCK_VIEW,
            'inputs':
            inputs
        }
 def validateSettings(settings):
     efficiencyBlockParametersList = [
         settings[key] for key in SESSION_STATS.getEfficiencyBlock()
     ]
     return False if sum(
         efficiencyBlockParametersList) > MAX_STATS else True
Beispiel #8
0
 def _getBattleEfficiencyData(self):
     parameters = SESSION_STATS.getVehiclesEfficiencyBlock()
     return TankBattleEfficiencyStatsVO(battleEfficiency=packBattleEfficiencyData(self.vehicleStats, parameters), collapseLabel='')