Esempio n. 1
0
 def doUpdateMonthCheckin(self, gameId, userId, clientId):
     try:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         status = monthcheckin.loadStatus(userId)
         mo.setResult('curDate', status.curDate.strftime('%Y%m%d'))
         mo.setResult('checkinDates', [d.strftime('%Y%m%d') for d in status.checkinDateList])
         mo.setResult('supCheckinDates', [d.strftime('%Y%m%d') for d in status.supplementCheckinDateList])
         mo.setResult('rewardDaysList', status.rewardDaysList)
         daysRewards = []
         for _days, rewardContent in enumerate(monthcheckin.getConf().get('daysRewards', [])):
             reward = rewardContent.get('reward')
             monthRange = monthcheckin.getMonthRange()
             if rewardContent.get('days') < monthRange:
                 monthRange = rewardContent.get('days')
             daysRewards.append({
                 'days': monthRange,
                 'desc': reward.get('desc'),
                 'picUrl': reward.get('picUrl'),
                 'state': self.calcDaysRewardState(status, monthRange)
             })
             ftlog.debug('doUpdateMonthCheckin daysRewards monthRange =', monthRange)
         mo.setResult('daysRewards', daysRewards)
         checkinRewardMap = monthcheckin.getConf().get('checkDesc', {})
         mo.setResult('specailDate', monthcheckin.getNowSpecailDate(status.curDate.strftime('%Y%m%d')))
         mo.setResult('checkinRewardImg', checkinRewardMap.get('picUrl'))
         mo.setResult('checkinRewardDesc', checkinRewardMap.get('desc', '500金币+1幸运卡'))
         activies = []
         for _days, rewardContent in enumerate(monthcheckin.getConf().get('activies', [])):
             activies.append({
                 'date': rewardContent.get('date'),
                 'tip': rewardContent.get('tip')
             })
         mo.setResult('activies', activies)
         mo.setResult('action', 'update')
         mo.setResult('supCheckinCount', monthcheckin.getSupplementCheckinCardCount(userId, gameId))
         ftlog.debug('doUpdateMonthCheckin userId =', userId
                     , 'gameId =', gameId
                     , 'clientId =', clientId
                     , 'curDate =', status.curDate.strftime('%Y%m%d')
                     , 'checkinDates =', [d.strftime('%Y%m%d') for d in status.checkinDateList]
                     , 'supCheckinDates =', [d.strftime('%Y%m%d') for d in status.supplementCheckinDateList])
         router.sendToUser(mo, userId)
     except MonthCheckinException, e:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         mo.setResult('action', 'update')
         mo.setError(e.errorCode, e.message)
         router.sendToUser(mo, userId)
         ftlog.warn('doupdate ' + str(e))
Esempio n. 2
0
 def doCheckinMonth(self, gameId, userId, clientId):
     try:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         status = monthcheckin.checkin(userId, gameId, clientId)
         if not status:
             mo.setResult('userId', userId)
             ftlog.info('maybe is script userId =', userId)
             mo.setResult('tip', 'maybe is script')
             router.sendToUser(mo, userId)
             return
         mo.setResult(
             'checkinDateList',
             [d.strftime('%Y%m%d') for d in status.checkinDateList])
         mo.setResult('supplementCheckinDateList', [
             d.strftime('%Y%m%d') for d in status.supplementCheckinDateList
         ])
         mo.setResult('rewardDaysList', status.rewardDaysList)
         mo.setResult('descSucess', '恭喜你获得500金币+1幸运卡')
         mo.setResult(
             'supCheckinCount',
             monthcheckin.getSupplementCheckinCardCount(userId, gameId))
         daysRewards = []
         for _days, rewardContent in enumerate(monthcheckin.getConf().get(
                 'daysRewards', [])):
             reward = rewardContent.get('reward')
             monthRange = monthcheckin.getMonthRange()
             if rewardContent.get('days') < monthRange:
                 monthRange = rewardContent.get('days')
             daysRewards.append({
                 'days':
                 monthRange,
                 'desc':
                 reward.get('desc'),
                 'picUrl':
                 reward.get('picUrl'),
                 'state':
                 self.calcDaysRewardState(status, monthRange)
             })
             ftlog.debug('doCheckinMonth daysRewards monthRange =',
                         monthRange)
         mo.setResult('daysRewards', daysRewards)
         mo.setResult('action', 'checkin')
         ftlog.debug('doCheckinMonth userId =', userId, 'gameId =', gameId,
                     'clientId =', clientId, 'checkinDateList =',
                     [d.strftime('%Y%m%d') for d in status.checkinDateList],
                     'supplementCheckinDateList =', [
                         d.strftime('%Y%m%d')
                         for d in status.supplementCheckinDateList
                     ])
         router.sendToUser(mo, userId)
         datachangenotify.sendDataChangeNotify(gameId, userId,
                                               ['free', 'promotion_loc'])
     except MonthCheckinException, e:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         mo.setResult('action', 'checkin')
         mo.setError(e.errorCode, e.message)
         router.sendToUser(mo, userId)
         ftlog.warn('MonthCheckinException', userId, e.errorCode, e.message)
Esempio n. 3
0
 def doGetDaysRewardMonth(self, gameId, userId, clientId):
     msg = runcmd.getMsgPack()
     days = msg.getParam('days')
     try:
         mo = MsgPack()
         MonthCheckinStatus = monthcheckin.getDaysReward(
             userId, days, gameId)
         mo.setCmd('month_checkin')
         if not MonthCheckinStatus:
             mo.setResult('userId', userId)
             mo.setResult('tip', 'maybe is script')
             ftlog.info('maybe is script userId =', userId)
             router.sendToUser(mo, userId)
             return
         mo.setResult('action', 'getDaysReward')
         mo.setResult('checkinDateList', [
             d.strftime('%Y%m%d')
             for d in MonthCheckinStatus.checkinDateList
         ])
         daysRewards = []
         for days, rewardContent in enumerate(monthcheckin.getConf().get(
                 'daysRewards', [])):
             reward = rewardContent.get('reward')
             monthRange = monthcheckin.getMonthRange()
             if rewardContent.get('days') < monthRange:
                 monthRange = rewardContent.get('days')
             daysRewards.append({
                 'days':
                 monthRange,
                 'desc':
                 reward.get('desc'),
                 'picUrl':
                 reward.get('picUrl'),
                 'state':
                 self.calcDaysRewardState(MonthCheckinStatus, monthRange)
             })
             ftlog.debug('doGetDaysRewardMonth daysRewards monthRange =',
                         monthRange)
         mo.setResult('daysRewards', daysRewards)
         mo.setResult('supplementCheckinDateList', [
             d.strftime('%Y%m%d')
             for d in MonthCheckinStatus.supplementCheckinDateList
         ])
         mo.setResult('rewardDaysList', MonthCheckinStatus.rewardDaysList)
         ftlog.debug('doGetDaysRewardMonth userId =', userId, 'gameId =',
                     gameId, 'clientId =', clientId, 'daysRewards =',
                     daysRewards)
         router.sendToUser(mo, userId)
         datachangenotify.sendDataChangeNotify(gameId, userId,
                                               ['free', 'promotion_loc'])
     except MonthCheckinException, e:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         mo.setResult('action', 'getDaysReward')
         mo.setError(e.errorCode, e.message)
         router.sendToUser(mo, userId)
         ftlog.warn('doGetDaysRewardMonth ' + str(e))
Esempio n. 4
0
    def doSupCheckinMonth(self, gameId, userId, clientId):
        try:
            mo = MsgPack()
            typeData, status = monthcheckin.supplementCheckin(userId, gameId, clientId)

            mo.setCmd('month_checkin')
            if not status:
                mo.setResult('userId', userId)
                mo.setResult('tip', 'maybe is script')
                ftlog.info('maybe is script userId =', userId)
                router.sendToUser(mo, userId)
                return
            if typeData == 1:
                mo.setResult('action', 'supCheckin')
                mo.setResult('lessCard', status['lessCard'])
                router.sendToUser(mo, userId)
            else:
                mo.setResult('action', 'supCheckin')
                mo.setResult('supCheckinCount', monthcheckin.getSupplementCheckinCardCount(userId, gameId))
                mo.setResult('checkinDateList', [d.strftime('%Y%m%d') for d in status.checkinDateList])
                mo.setResult('supplementCheckinDateList',
                             [d.strftime('%Y%m%d') for d in status.supplementCheckinDateList])
                mo.setResult('rewardDaysList', status.rewardDaysList)
                daysRewards = []
                for _days, rewardContent in enumerate(monthcheckin.getConf().get('daysRewards', [])):
                    reward = rewardContent.get('reward')
                    monthRange = monthcheckin.getMonthRange()
                    if rewardContent.get('days') < monthRange:
                        monthRange = rewardContent.get('days')
                    daysRewards.append({
                        'days': monthRange,
                        'desc': reward.get('desc'),
                        'picUrl': reward.get('picUrl'),
                        'state': self.calcDaysRewardState(status, monthRange)
                    })
                    ftlog.debug('doSupCheckinMonth daysRewards monthRange =', monthRange)
                mo.setResult('daysRewards', daysRewards)
                mo.setResult('descSucess', '恭喜你获得500金币+1幸运卡')
                ftlog.debug('doSupCheckinMonth usereId =', userId
                            , 'gameId =', gameId
                            , 'clientId =', clientId
                            , 'checkinDateList =', [d.strftime('%Y%m%d') for d in status.checkinDateList]
                            , 'supplementCheckinDateList =',
                            [d.strftime('%Y%m%d') for d in status.supplementCheckinDateList])
                router.sendToUser(mo, userId)
                datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
        except MonthCheckinException, e:
            mo = MsgPack()
            mo.setCmd('month_checkin')
            mo.setResult('action', 'supCheckin')
            mo.setError(e.errorCode, e.message)
            router.sendToUser(mo, userId)
            ftlog.debug('dosupCheckin ' + str(e))
Esempio n. 5
0
def doSupCheckinMonth(gameId, userId, clientId):
    ftlog.debug('doSupCheckinMonth..userId', userId)
    try:
        mo = MsgPack()
        typeData, status = monthcheckin.supplementCheckin(
            userId, gameId, clientId)
        ftlog.debug('doCheckinMonth..supplementCheckin = ', status)
        mo.setCmd('month_checkin')
        if typeData == 1:
            mo.setResult('action', 'supCheckin')
            mo.setResult('lessCard', status['lessCard'])
            router.sendToUser(mo, userId)
        else:
            mo.setResult('action', 'supCheckin')
            mo.setResult(
                'checkinDateList',
                [d.strftime('%Y%m%d') for d in status.checkinDateList])
            mo.setResult('supplementCheckinDateList', [
                d.strftime('%Y%m%d') for d in status.supplementCheckinDateList
            ])
            mo.setResult('rewardDaysList', status.rewardDaysList)
            daysRewards = []
            for days, rewardContent in enumerate(monthcheckin.getConf().get(
                    'daysRewards', [])):
                reward = rewardContent.get('reward')
                daysRewards.append({
                    'days':
                    rewardContent.get('days'),
                    'desc':
                    reward.get('desc'),
                    'picUrl':
                    reward.get('picUrl'),
                    'state':
                    MonthCheckinHandler.calcDaysRewardState(
                        status, rewardContent.get('days'))
                })
                ftlog.debug(
                    'doUpdateMonthCheckin..days', rewardContent.get('days'),
                    'desc = ', reward.get('desc'), 'state = ',
                    MonthCheckinHandler.calcDaysRewardState(
                        status, rewardContent.get('days')))
            mo.setResult('daysRewards', daysRewards)
            mo.setResult('descSucess', '恭喜你获得500金币+1幸运卡')
            router.sendToUser(mo, userId)
    except MonthCheckinException, e:
        mo = MsgPack()
        mo.setCmd('month_checkin')
        mo.setResult('action', 'supCheckin')
        mo.setError(e.errorCode, e.message)
        router.sendToUser(mo, userId)
        ftlog.warn('MonthCheckinException', e.errorCode, e.message)
Esempio n. 6
0
 def doGetDaysRewardMonth(self, gameId, userId, clientId):
     msg = runcmd.getMsgPack()
     days = msg.getParam('days')
     try:
         mo = MsgPack()
         MonthCheckinStatus = monthcheckin.getDaysReward(userId, days, gameId)
         mo.setCmd('month_checkin')
         if not MonthCheckinStatus:
             mo.setResult('userId', userId)
             mo.setResult('tip', 'maybe is script')
             ftlog.info('maybe is script userId =', userId)
             router.sendToUser(mo, userId)
             return
         mo.setResult('action', 'getDaysReward')
         mo.setResult('checkinDateList', [d.strftime('%Y%m%d') for d in MonthCheckinStatus.checkinDateList])
         daysRewards = []
         for days, rewardContent in enumerate(monthcheckin.getConf().get('daysRewards', [])):
             reward = rewardContent.get('reward')
             monthRange = monthcheckin.getMonthRange()
             if rewardContent.get('days') < monthRange:
                 monthRange = rewardContent.get('days')
             daysRewards.append({
                 'days': monthRange,
                 'desc': reward.get('desc'),
                 'picUrl': reward.get('picUrl'),
                 'state': self.calcDaysRewardState(MonthCheckinStatus, monthRange)
             })
             ftlog.debug('doGetDaysRewardMonth daysRewards monthRange =', monthRange)
         mo.setResult('daysRewards', daysRewards)
         mo.setResult('supplementCheckinDateList',
                      [d.strftime('%Y%m%d') for d in MonthCheckinStatus.supplementCheckinDateList])
         mo.setResult('rewardDaysList', MonthCheckinStatus.rewardDaysList)
         ftlog.debug('doGetDaysRewardMonth userId =', userId
                     , 'gameId =', gameId
                     , 'clientId =', clientId
                     , 'daysRewards =', daysRewards)
         router.sendToUser(mo, userId)
         datachangenotify.sendDataChangeNotify(gameId, userId, ['free', 'promotion_loc'])
     except MonthCheckinException, e:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         mo.setResult('action', 'getDaysReward')
         mo.setError(e.errorCode, e.message)
         router.sendToUser(mo, userId)
         ftlog.warn('doGetDaysRewardMonth ' + str(e))
Esempio n. 7
0
 def doUpdateMonthCheckin(self, gameId, userId, clientId):
     try:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         status = monthcheckin.loadStatus(userId)
         mo.setResult('curDate', status.curDate.strftime('%Y%m%d'))
         mo.setResult(
             'checkinDates',
             [d.strftime('%Y%m%d') for d in status.checkinDateList])
         mo.setResult('supCheckinDates', [
             d.strftime('%Y%m%d') for d in status.supplementCheckinDateList
         ])
         mo.setResult('rewardDaysList', status.rewardDaysList)
         daysRewards = []
         for _days, rewardContent in enumerate(monthcheckin.getConf().get(
                 'daysRewards', [])):
             reward = rewardContent.get('reward')
             monthRange = monthcheckin.getMonthRange()
             if rewardContent.get('days') < monthRange:
                 monthRange = rewardContent.get('days')
             daysRewards.append({
                 'days':
                 monthRange,
                 'desc':
                 reward.get('desc'),
                 'picUrl':
                 reward.get('picUrl'),
                 'state':
                 self.calcDaysRewardState(status, monthRange)
             })
             ftlog.debug('doUpdateMonthCheckin daysRewards monthRange =',
                         monthRange)
         mo.setResult('daysRewards', daysRewards)
         checkinRewardMap = monthcheckin.getConf().get('checkDesc', {})
         mo.setResult(
             'specailDate',
             monthcheckin.getNowSpecailDate(
                 status.curDate.strftime('%Y%m%d')))
         mo.setResult('checkinRewardImg', checkinRewardMap.get('picUrl'))
         _, clientVer, _ = strutil.parseClientId(clientId)
         if clientVer < client_ver_judge.client_ver_397:
             mo.setResult('checkinRewardDesc', '500金币+1幸运卡')
         else:
             mo.setResult('checkinRewardDesc',
                          checkinRewardMap.get('desc', '500金币'))
         activies = []
         for _days, rewardContent in enumerate(monthcheckin.getConf().get(
                 'activies', [])):
             activies.append({
                 'date': rewardContent.get('date'),
                 'tip': rewardContent.get('tip')
             })
         mo.setResult('activies', activies)
         mo.setResult('action', 'update')
         mo.setResult(
             'supCheckinCount',
             monthcheckin.getSupplementCheckinCardCount(userId, gameId))
         ftlog.debug('doUpdateMonthCheckin userId =', userId, 'gameId =',
                     gameId, 'clientId =', clientId, 'curDate =',
                     status.curDate.strftime('%Y%m%d'), 'checkinDates =',
                     [d.strftime('%Y%m%d') for d in status.checkinDateList],
                     'supCheckinDates =', [
                         d.strftime('%Y%m%d')
                         for d in status.supplementCheckinDateList
                     ])
         router.sendToUser(mo, userId)
     except MonthCheckinException, e:
         mo = MsgPack()
         mo.setCmd('month_checkin')
         mo.setResult('action', 'update')
         mo.setError(e.errorCode, e.message)
         router.sendToUser(mo, userId)
         ftlog.warn('doupdate ' + str(e))
Esempio n. 8
0
    def doSupCheckinMonth(self, gameId, userId, clientId):
        try:
            mo = MsgPack()
            typeData, status = monthcheckin.supplementCheckin(
                userId, gameId, clientId)

            mo.setCmd('month_checkin')
            if not status:
                mo.setResult('userId', userId)
                mo.setResult('tip', 'maybe is script')
                ftlog.info('maybe is script userId =', userId)
                router.sendToUser(mo, userId)
                return
            if typeData == 1:
                mo.setResult('action', 'supCheckin')
                mo.setResult('lessCard', status['lessCard'])
                router.sendToUser(mo, userId)
            else:
                mo.setResult('action', 'supCheckin')
                mo.setResult(
                    'supCheckinCount',
                    monthcheckin.getSupplementCheckinCardCount(userId, gameId))
                mo.setResult(
                    'checkinDateList',
                    [d.strftime('%Y%m%d') for d in status.checkinDateList])
                mo.setResult('supplementCheckinDateList', [
                    d.strftime('%Y%m%d')
                    for d in status.supplementCheckinDateList
                ])
                mo.setResult('rewardDaysList', status.rewardDaysList)
                daysRewards = []
                for _days, rewardContent in enumerate(
                        monthcheckin.getConf().get('daysRewards', [])):
                    reward = rewardContent.get('reward')
                    monthRange = monthcheckin.getMonthRange()
                    if rewardContent.get('days') < monthRange:
                        monthRange = rewardContent.get('days')
                    daysRewards.append({
                        'days':
                        monthRange,
                        'desc':
                        reward.get('desc'),
                        'picUrl':
                        reward.get('picUrl'),
                        'state':
                        self.calcDaysRewardState(status, monthRange)
                    })
                    ftlog.debug('doSupCheckinMonth daysRewards monthRange =',
                                monthRange)
                mo.setResult('daysRewards', daysRewards)
                supplementCheckinRewardMap = monthcheckin.getConf().get(
                    'supplementCheckinReward', {})
                _, clientVer, _ = strutil.parseClientId(clientId)
                if clientVer < client_ver_judge.client_ver_397:
                    mo.setResult('descSucess', '恭喜你获得500金币+1幸运卡')
                else:
                    mo.setResult(
                        'descSucess', '恭喜你获得%s' %
                        supplementCheckinRewardMap.get('desc', '500金币'))
                ftlog.debug(
                    'doSupCheckinMonth usereId =', userId, 'gameId =', gameId,
                    'clientId =', clientId, 'checkinDateList =',
                    [d.strftime('%Y%m%d') for d in status.checkinDateList],
                    'supplementCheckinDateList =', [
                        d.strftime('%Y%m%d')
                        for d in status.supplementCheckinDateList
                    ])
                router.sendToUser(mo, userId)
                datachangenotify.sendDataChangeNotify(
                    gameId, userId, ['free', 'promotion_loc'])
        except MonthCheckinException, e:
            mo = MsgPack()
            mo.setCmd('month_checkin')
            mo.setResult('action', 'supCheckin')
            mo.setError(e.errorCode, e.message)
            router.sendToUser(mo, userId)
            ftlog.debug('dosupCheckin ' + str(e))