class AppealCMHandler(BaseUserCMHandler):

    def __init__(self, cmProxy, ctx = None):
        super(AppealCMHandler, self).__init__(cmProxy, ctx)
        self._denunciator = LobbyDenunciator()

    def fini(self):
        self._denunciator = None
        super(AppealCMHandler, self).fini()
        return

    def appealOffend(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.OFFEND)

    def appealFlood(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FLOOD)

    def appealBlackmail(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BLACKMAIL)

    def appealSwindle(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.SWINDLE)

    def appealNotFairPlay(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.NOT_FAIR_PLAY)

    def appealForbiddenNick(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FORBIDDEN_NICK)

    def appealBot(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BOT)

    def _getHandlers(self):
        handlers = super(AppealCMHandler, self)._getHandlers()
        handlers.update({DENUNCIATIONS.OFFEND: 'appealOffend',
         DENUNCIATIONS.FLOOD: 'appealFlood',
         DENUNCIATIONS.BLACKMAIL: 'appealBlackmail',
         DENUNCIATIONS.SWINDLE: 'appealSwindle',
         DENUNCIATIONS.NOT_FAIR_PLAY: 'appealNotFairPlay',
         DENUNCIATIONS.FORBIDDEN_NICK: 'appealForbiddenNick',
         DENUNCIATIONS.BOT: 'appealBot'})
        return handlers

    def _addAppealInfo(self, options):
        if self.wasInBattle:
            options.append(self._createSubMenuItem())
        return options

    def _getSubmenuData(self):
        return [self._makeItem(DENUNCIATIONS.OFFEND, MENU.contextmenu(DENUNCIATIONS.OFFEND)),
         self._makeItem(DENUNCIATIONS.FLOOD, MENU.contextmenu(DENUNCIATIONS.FLOOD)),
         self._makeItem(DENUNCIATIONS.BLACKMAIL, MENU.contextmenu(DENUNCIATIONS.BLACKMAIL)),
         self._makeItem(DENUNCIATIONS.SWINDLE, MENU.contextmenu(DENUNCIATIONS.SWINDLE)),
         self._makeItem(DENUNCIATIONS.NOT_FAIR_PLAY, MENU.contextmenu(DENUNCIATIONS.NOT_FAIR_PLAY)),
         self._makeItem(DENUNCIATIONS.FORBIDDEN_NICK, MENU.contextmenu(DENUNCIATIONS.FORBIDDEN_NICK)),
         self._makeItem(DENUNCIATIONS.BOT, MENU.contextmenu(DENUNCIATIONS.BOT))]

    def _createSubMenuItem(self):
        labelStr = i18n.makeString(MENU.CONTEXTMENU_APPEAL) + ' (' + str(self._denunciator.getDenunciationsLeft()) + ')'
        return self._makeItem(DENUNCIATIONS.APPEAL, labelStr, optInitData={'enabled': self._denunciator.isAppealsEnabled()}, optSubMenu=self._getSubmenuData())
Example #2
0
class AppealCMHandler(BaseUserCMHandler):

    def __init__(self, cmProxy, ctx=None):
        super(AppealCMHandler, self).__init__(cmProxy, ctx)
        self._denunciator = LobbyDenunciator()

    def fini(self):
        self._denunciator = None
        super(AppealCMHandler, self).fini()
        return

    def appealIncorrectBehavior(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.INCORRECT_BEHAVIOR, self._arenaUniqueID)

    def appealNotFairPlay(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.NOT_FAIR_PLAY, self._arenaUniqueID)

    def appealForbiddenNick(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FORBIDDEN_NICK, self._arenaUniqueID)

    def appealBot(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BOT, self._arenaUniqueID)

    def showVehicleInfo(self):
        vehicleCD = getValidVehicleCDForNationChange(self._vehicleCD)
        shared_events.showVehicleInfo(vehicleCD)

    def showVehiclePreview(self):
        vehicleCD = getValidVehicleCDForNationChange(self._vehicleCD)
        shared_events.showVehiclePreview(vehicleCD)
        shared_events.hideBattleResults()

    def _initFlashValues(self, ctx):
        self._vehicleCD = None
        vehicleCD = getattr(ctx, 'vehicleCD', None)
        if vehicleCD is not None and not math.isnan(vehicleCD):
            self._vehicleCD = int(vehicleCD)
        clientArenaIdx = getattr(ctx, 'clientArenaIdx', 0)
        self._arenaUniqueID = self.lobbyContext.getArenaUniqueIDByClientID(clientArenaIdx)
        self._arenaGuiType = getattr(ctx, 'arenaType', ARENA_GUI_TYPE.UNKNOWN)
        self._isAlly = getattr(ctx, 'isAlly', False)
        super(AppealCMHandler, self)._initFlashValues(ctx)
        return

    def _clearFlashValues(self):
        super(AppealCMHandler, self)._clearFlashValues()
        self._vehicleCD = None
        self._arenaGuiType = None
        self._isAlly = None
        return

    def _getHandlers(self):
        handlers = super(AppealCMHandler, self)._getHandlers()
        handlers.update({DENUNCIATIONS.INCORRECT_BEHAVIOR: 'appealIncorrectBehavior',
         DENUNCIATIONS.NOT_FAIR_PLAY: 'appealNotFairPlay',
         DENUNCIATIONS.FORBIDDEN_NICK: 'appealForbiddenNick',
         DENUNCIATIONS.BOT: 'appealBot',
         USER.VEHICLE_INFO: 'showVehicleInfo',
         USER.VEHICLE_PREVIEW: 'showVehiclePreview'})
        return handlers

    def _addAppealInfo(self, options):
        if self.wasInBattle:
            options.append(self._createSubMenuItem())
        return options

    def _addVehicleInfo(self, options):
        if self._vehicleCD > 0:
            vehicle = self.itemsCache.items.getItemByCD(self._vehicleCD)
            if not vehicle.isSecret:
                isEnabled = True
                if vehicle.isPreviewAllowed():
                    isEnabled = not self.prbDispatcher.getFunctionalState().isNavigationDisabled()
                    action = USER.VEHICLE_PREVIEW
                    label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
                else:
                    action = USER.VEHICLE_INFO
                    label = MENU.contextmenu(USER.VEHICLE_INFO)
                options.append(self._makeItem(action, label, optInitData={'enabled': isEnabled}))
        return options

    def _isAppealsForTopicEnabled(self, topic):
        topicID = DENUNCIATIONS_MAP[topic]
        return self._denunciator.isAppealsForTopicEnabled(self.databaseID, topicID, self._arenaUniqueID)

    def _getSubmenuData(self):
        if self._isAlly or self._arenaGuiType in (ARENA_GUI_TYPE.UNKNOWN, ARENA_GUI_TYPE.TRAINING):
            order = DENUNCIATIONS.ORDER
        else:
            order = DENUNCIATIONS.ENEMY_ORDER
        make = self._makeItem
        return [ make(denunciation, MENU.contextmenu(denunciation), optInitData={'enabled': self._isAppealsForTopicEnabled(denunciation)}) for denunciation in order ]

    def _createSubMenuItem(self):
        labelStr = '{} {}/{}'.format(i18n.makeString(MENU.CONTEXTMENU_APPEAL), self._denunciator.getDenunciationsLeft(), DENUNCIATIONS_PER_DAY)
        return self._makeItem(DENUNCIATIONS.APPEAL, labelStr, optInitData={'enabled': self._denunciator.isAppealsEnabled()}, optSubMenu=self._getSubmenuData())
class AppealCMHandler(BaseUserCMHandler):

    def __init__(self, cmProxy, ctx = None):
        super(AppealCMHandler, self).__init__(cmProxy, ctx)
        self._denunciator = LobbyDenunciator()

    def fini(self):
        self._denunciator = None
        super(AppealCMHandler, self).fini()
        return

    def appealOffend(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.OFFEND)

    def appealFlood(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FLOOD)

    def appealBlackmail(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BLACKMAIL)

    def appealSwindle(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.SWINDLE)

    def appealNotFairPlay(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.NOT_FAIR_PLAY)

    def appealForbiddenNick(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FORBIDDEN_NICK)

    def appealBot(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BOT)

    def showVehicleInfo(self):
        shared_events.showVehicleInfo(self._vehicleCD)

    def showVehiclePreview(self):
        shared_events.showVehiclePreview(self._vehicleCD)
        shared_events.hideBattleResults()

    def _initFlashValues(self, ctx):
        self._vehicleCD = None
        vehicleCD = getattr(ctx, 'vehicleCD', None)
        if vehicleCD is not None and not math.isnan(vehicleCD):
            self._vehicleCD = int(vehicleCD)
        super(AppealCMHandler, self)._initFlashValues(ctx)
        return

    def _clearFlashValues(self):
        super(AppealCMHandler, self)._clearFlashValues()
        self._vehicleCD = None
        return

    def _getHandlers(self):
        handlers = super(AppealCMHandler, self)._getHandlers()
        handlers.update({DENUNCIATIONS.OFFEND: 'appealOffend',
         DENUNCIATIONS.FLOOD: 'appealFlood',
         DENUNCIATIONS.BLACKMAIL: 'appealBlackmail',
         DENUNCIATIONS.SWINDLE: 'appealSwindle',
         DENUNCIATIONS.NOT_FAIR_PLAY: 'appealNotFairPlay',
         DENUNCIATIONS.FORBIDDEN_NICK: 'appealForbiddenNick',
         DENUNCIATIONS.BOT: 'appealBot',
         USER.VEHICLE_INFO: 'showVehicleInfo',
         USER.VEHICLE_PREVIEW: 'showVehiclePreview'})
        return handlers

    def _addAppealInfo(self, options):
        if self.wasInBattle:
            options.append(self._createSubMenuItem())
        return options

    def _addVehicleInfo(self, options):
        if self._vehicleCD > 0:
            vehicle = g_itemsCache.items.getItemByCD(self._vehicleCD)
            if not vehicle.isSecret:
                if vehicle.isPreviewAllowed():
                    action = USER.VEHICLE_PREVIEW
                    label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
                else:
                    action = USER.VEHICLE_INFO
                    label = MENU.contextmenu(USER.VEHICLE_INFO)
                options.append(self._makeItem(action, label))
        return options

    def _getSubmenuData(self):
        return [self._makeItem(DENUNCIATIONS.OFFEND, MENU.contextmenu(DENUNCIATIONS.OFFEND)),
         self._makeItem(DENUNCIATIONS.FLOOD, MENU.contextmenu(DENUNCIATIONS.FLOOD)),
         self._makeItem(DENUNCIATIONS.BLACKMAIL, MENU.contextmenu(DENUNCIATIONS.BLACKMAIL)),
         self._makeItem(DENUNCIATIONS.SWINDLE, MENU.contextmenu(DENUNCIATIONS.SWINDLE)),
         self._makeItem(DENUNCIATIONS.NOT_FAIR_PLAY, MENU.contextmenu(DENUNCIATIONS.NOT_FAIR_PLAY)),
         self._makeItem(DENUNCIATIONS.FORBIDDEN_NICK, MENU.contextmenu(DENUNCIATIONS.FORBIDDEN_NICK)),
         self._makeItem(DENUNCIATIONS.BOT, MENU.contextmenu(DENUNCIATIONS.BOT))]

    def _createSubMenuItem(self):
        labelStr = i18n.makeString(MENU.CONTEXTMENU_APPEAL) + ' (' + str(self._denunciator.getDenunciationsLeft()) + ')'
        return self._makeItem(DENUNCIATIONS.APPEAL, labelStr, optInitData={'enabled': self._denunciator.isAppealsEnabled()}, optSubMenu=self._getSubmenuData())
Example #4
0
class AppealCMHandler(BaseUserCMHandler):

    def __init__(self, cmProxy, ctx = None):
        super(AppealCMHandler, self).__init__(cmProxy, ctx)
        self._denunciator = LobbyDenunciator()

    def fini(self):
        self._denunciator = None
        super(AppealCMHandler, self).fini()
        return

    def appealIncorrectBehavior(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.INCORRECT_BEHAVIOR, self._arenaUniqueID)

    def appealNotFairPlay(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.NOT_FAIR_PLAY, self._arenaUniqueID)

    def appealForbiddenNick(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FORBIDDEN_NICK, self._arenaUniqueID)

    def appealBot(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BOT, self._arenaUniqueID)

    def showVehicleInfo(self):
        shared_events.showVehicleInfo(self._vehicleCD)

    def showVehiclePreview(self):
        shared_events.showVehiclePreview(self._vehicleCD)
        shared_events.hideBattleResults()

    def _initFlashValues(self, ctx):
        self._vehicleCD = None
        vehicleCD = getattr(ctx, 'vehicleCD', None)
        if vehicleCD is not None and not math.isnan(vehicleCD):
            self._vehicleCD = int(vehicleCD)
        clientArenaIdx = getattr(ctx, 'clientArenaIdx', 0)
        self._arenaUniqueID = g_lobbyContext.getArenaUniqueIDByClientID(clientArenaIdx)
        super(AppealCMHandler, self)._initFlashValues(ctx)
        return

    def _clearFlashValues(self):
        super(AppealCMHandler, self)._clearFlashValues()
        self._vehicleCD = None
        return

    def _getHandlers(self):
        handlers = super(AppealCMHandler, self)._getHandlers()
        handlers.update({DENUNCIATIONS.INCORRECT_BEHAVIOR: 'appealIncorrectBehavior',
         DENUNCIATIONS.NOT_FAIR_PLAY: 'appealNotFairPlay',
         DENUNCIATIONS.FORBIDDEN_NICK: 'appealForbiddenNick',
         DENUNCIATIONS.BOT: 'appealBot',
         USER.VEHICLE_INFO: 'showVehicleInfo',
         USER.VEHICLE_PREVIEW: 'showVehiclePreview'})
        return handlers

    def _addAppealInfo(self, options):
        if self.wasInBattle:
            options.append(self._createSubMenuItem())
        return options

    def _addVehicleInfo(self, options):
        if self._vehicleCD > 0:
            vehicle = g_itemsCache.items.getItemByCD(self._vehicleCD)
            if not vehicle.isSecret:
                isEnabled = True
                if vehicle.isPreviewAllowed():
                    isEnabled = not self.prbDispatcher.getFunctionalState().isNavigationDisabled()
                    action = USER.VEHICLE_PREVIEW
                    label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
                else:
                    action = USER.VEHICLE_INFO
                    label = MENU.contextmenu(USER.VEHICLE_INFO)
                options.append(self._makeItem(action, label, optInitData={'enabled': isEnabled}))
        return options

    def _isAppealsForTopicEnabled(self, topic):
        topicID = DENUNCIATIONS_MAP[topic]
        return self._denunciator.isAppealsForTopicEnabled(self.databaseID, topicID, self._arenaUniqueID)

    def _getSubmenuData(self):
        make = self._makeItem
        return [ make(denunciation, MENU.contextmenu(denunciation), optInitData={'enabled': self._isAppealsForTopicEnabled(denunciation)}) for denunciation in DENUNCIATIONS.ORDER ]

    def _createSubMenuItem(self):
        labelStr = '{} {}/{}'.format(i18n.makeString(MENU.CONTEXTMENU_APPEAL), self._denunciator.getDenunciationsLeft(), DENUNCIATIONS_PER_DAY)
        return self._makeItem(DENUNCIATIONS.APPEAL, labelStr, optInitData={'enabled': self._denunciator.isAppealsEnabled()}, optSubMenu=self._getSubmenuData())
Example #5
0
class AppealCMHandler(BaseUserCMHandler):

    def __init__(self, cmProxy, ctx = None):
        super(AppealCMHandler, self).__init__(cmProxy, ctx)
        self._denunciator = LobbyDenunciator()

    def fini(self):
        self._denunciator = None
        super(AppealCMHandler, self).fini()
        return

    def appealOffend(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.OFFEND)

    def appealFlood(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FLOOD)

    def appealBlackmail(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BLACKMAIL)

    def appealSwindle(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.SWINDLE)

    def appealNotFairPlay(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.NOT_FAIR_PLAY)

    def appealForbiddenNick(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.FORBIDDEN_NICK)

    def appealBot(self):
        self._denunciator.makeAppeal(self.databaseID, self.userName, DENUNCIATIONS.BOT)

    def showVehicleInfo(self):
        shared_events.showVehicleInfo(self._vehicleCD)

    def showVehiclePreview(self):
        shared_events.showVehiclePreview(self._vehicleCD)
        shared_events.hideBattleResults()

    def _initFlashValues(self, ctx):
        self._vehicleCD = None
        vehicleCD = getattr(ctx, 'vehicleCD', None)
        if vehicleCD is not None and not math.isnan(vehicleCD):
            self._vehicleCD = int(vehicleCD)
        super(AppealCMHandler, self)._initFlashValues(ctx)
        return

    def _clearFlashValues(self):
        super(AppealCMHandler, self)._clearFlashValues()
        self._vehicleCD = None
        return

    def _getHandlers(self):
        handlers = super(AppealCMHandler, self)._getHandlers()
        handlers.update({DENUNCIATIONS.OFFEND: 'appealOffend',
         DENUNCIATIONS.FLOOD: 'appealFlood',
         DENUNCIATIONS.BLACKMAIL: 'appealBlackmail',
         DENUNCIATIONS.SWINDLE: 'appealSwindle',
         DENUNCIATIONS.NOT_FAIR_PLAY: 'appealNotFairPlay',
         DENUNCIATIONS.FORBIDDEN_NICK: 'appealForbiddenNick',
         DENUNCIATIONS.BOT: 'appealBot',
         USER.VEHICLE_INFO: 'showVehicleInfo',
         USER.VEHICLE_PREVIEW: 'showVehiclePreview'})
        return handlers

    def _addAppealInfo(self, options):
        if self.wasInBattle:
            options.append(self._createSubMenuItem())
        return options

    def _addVehicleInfo(self, options):
        if self._vehicleCD > 0:
            vehicle = g_itemsCache.items.getItemByCD(self._vehicleCD)
            if not vehicle.isSecret:
                if vehicle.isPreviewAllowed():
                    action = USER.VEHICLE_PREVIEW
                    label = MENU.contextmenu(USER.VEHICLE_PREVIEW)
                else:
                    action = USER.VEHICLE_INFO
                    label = MENU.contextmenu(USER.VEHICLE_INFO)
                options.append(self._makeItem(action, label))
        return options

    def _getSubmenuData(self):
        return [self._makeItem(DENUNCIATIONS.OFFEND, MENU.contextmenu(DENUNCIATIONS.OFFEND)),
         self._makeItem(DENUNCIATIONS.FLOOD, MENU.contextmenu(DENUNCIATIONS.FLOOD)),
         self._makeItem(DENUNCIATIONS.BLACKMAIL, MENU.contextmenu(DENUNCIATIONS.BLACKMAIL)),
         self._makeItem(DENUNCIATIONS.SWINDLE, MENU.contextmenu(DENUNCIATIONS.SWINDLE)),
         self._makeItem(DENUNCIATIONS.NOT_FAIR_PLAY, MENU.contextmenu(DENUNCIATIONS.NOT_FAIR_PLAY)),
         self._makeItem(DENUNCIATIONS.FORBIDDEN_NICK, MENU.contextmenu(DENUNCIATIONS.FORBIDDEN_NICK)),
         self._makeItem(DENUNCIATIONS.BOT, MENU.contextmenu(DENUNCIATIONS.BOT))]

    def _createSubMenuItem(self):
        labelStr = i18n.makeString(MENU.CONTEXTMENU_APPEAL) + ' (' + str(self._denunciator.getDenunciationsLeft()) + ')'
        return self._makeItem(DENUNCIATIONS.APPEAL, labelStr, optInitData={'enabled': self._denunciator.isAppealsEnabled()}, optSubMenu=self._getSubmenuData())