Exemplo n.º 1
0
    def getDay30Reward(self, gameId, userId, clientId):
        from dizhu.activities.login30_360 import Login30
        status = 0
        all_count = 0
        get_count = 0
        tip = ''
        ecode = 0
        try:
            conf = dizhuconf.getActivityConf("huiyuan_360")
            data = gamedata.getGameAttrJson(userId, gameId, Login30.attr_act,
                                            {})
            if data:
                if data["get_count"] != data["current_count"]:
                    reward = conf.get("login30", [])[data["current_count"] - 1]
                    contentItem = TYContentItem.decodeFromDict(reward)
                    tip = self.sendReward(gameId, userId, clientId,
                                          contentItem, 'HUI_YUAN_360', 0)
                    data["get_count"] = data["current_count"]

                all_count = data["all_count"]
                get_count = data["get_count"]

                status = int(data["get_count"] < data["current_count"])

                gamedata.setGameAttr(userId, gameId, Login30.attr_act,
                                     json.dumps(data))
        except:
            ftlog.exception()
            tip = "领取失败"
            ecode = 1

        return tip, ecode, status, all_count, get_count
Exemplo n.º 2
0
 def _reloadConf(cls):
     conf = dizhuconf.getActivityConf('ddz_fund')
     try:
         cls.conf = DdzFundConf().decodeFromDict(conf)
         ftlog.debug('ActivityDdzFund._reloadConf conf=', conf)
     except:
         ftlog.error('ActivityDdzFund._reloadConf conf=', conf)
Exemplo n.º 3
0
    def handleEvent(cls, event):
        try:
            gameId = 6
            userId = event.userId
            conf = dizhuconf.getActivityConf("huiyuan_360")

            if not cls.clientCheck(gameId, userId, conf):
                return

            if not cls.dateCheck(gameId, userId, conf):
                return

            data = gamedata.getGameAttrJson(userId, gameId, cls.attr_act, {})
            now = datetime.now()
            now_day = '%d%02d%02d' % (now.year, now.month, now.day)

            choujiang_round = conf.get("choujiang_round", [])

            if isinstance(event, EventUserLogin):
                if (not data) or (now_day != data["date"]):
                    data = {
                        "round": 0,
                        "date": now_day,
                        "all_count": len(choujiang_round),
                        "current_count": 0,
                        "get_count": 0
                    }
            else:
                if not data:
                    data = {
                        "round": 1,
                        "date": now_day,
                        "all_count": len(choujiang_round),
                        "current_count": 0,
                        "get_count": 0
                    }
                else:
                    if now_day == data["date"]:
                        data["round"] += 1
                        if data["round"] in choujiang_round:
                            data["current_count"] += 1
                    else:
                        data = {
                            "round": 1,
                            "date": now_day,
                            "all_count": len(choujiang_round),
                            "current_count": 0,
                            "get_count": 0
                        }
                        if data["round"] in choujiang_round:
                            data["current_count"] += 1

            ftlog.debug("choujiang360 gameId=", gameId, "userId=", userId,
                        "data=", data)
            gamedata.setGameAttr(userId, gameId, cls.attr_act,
                                 json.dumps(data))

        except:
            ftlog.exception()
Exemplo n.º 4
0
    def handleEvent(cls, event):
        try:
            gameId = 6
            userId = event.userId
            conf = dizhuconf.getActivityConf("vip_send")

            if not cls.dateCheck(gameId, userId, conf):
                cls.removeVipItems(gameId, userId, conf)
                return

            if not cls.gameCheck(userId, gameId):
                return

            vipLevel = int(
                hallvip.userVipSystem.getUserVip(userId).vipLevel.level)
            vipLevelLimit = conf.get("vip_level", 1)

            ftlog.debug('VipSend.handleEvent vipLevel=', vipLevel,
                        'vipLevelLimit=', vipLevelLimit, 'userId=', userId)

            if vipLevel >= vipLevelLimit:
                attrname = cls.getFlagAttr(conf.get('start_date',
                                                    '2015-01-01'))
                is_send = gamedata.getGameAttr(userId, gameId, attrname)

                if is_send:
                    return

                items = conf.get("item_send", [])
                timestamp = pktimestamp.getCurrentTimestamp()
                for item in items:
                    contentItem = TYContentItem.decodeFromDict(item)
                    userAssets = hallitem.itemSystem.loadUserAssets(userId)
                    assetKind, _, _ = userAssets.addAsset(
                        gameId, contentItem.assetKindId, contentItem.count,
                        timestamp, 'DIZHU_VIP_SEND', 0)
                mail = conf.get("mail", "")
                if mail:
                    pkmessage.sendPrivate(9999, userId, 0, mail)

                if assetKind.keyForChangeNotify:
                    datachangenotify.sendDataChangeNotify(
                        gameId, userId,
                        [assetKind.keyForChangeNotify, 'message'])

                gamedata.setGameAttr(userId, gameId, attrname, 1)

                ftlog.debug('vipsend vipLevel=', vipLevel, 'vipLevelLimit=',
                            vipLevelLimit, 'userId=', userId, "attrname=",
                            attrname)
        except:
            ftlog.exception()
Exemplo n.º 5
0
    def doHuiYuanInfo(self, gameId, userId, clientId):
        ftlog.debug("activity_pc dohuiyuaninfo gameId=", gameId, "userId=",
                    userId, "clientId=", clientId)
        conf = dizhuconf.getActivityConf("huiyuan_360")

        isopen = 1
        if not self.dateCheck(gameId, userId, conf):
            isopen = 0

        gifts = {
            "day_30": self.getDay30StatusInfo(gameId, userId),
            "choujiang_5": self.getChouJiang5StatusInfo(gameId, userId)
        }

        mo = MsgPack()
        ProtocolBuilder.buildHuiYuanInfo(gameId, userId, isopen, gifts, mo)
        router.sendToUser(mo, userId)
Exemplo n.º 6
0
 def getDdzActivityConf(cls):
     return dizhuconf.getActivityConf("matchscore")
Exemplo n.º 7
0
    def handleEvent(cls, event):
        conf = dizhuconf.getActivityConf('month_checkin_gift')
        monthDayCount = calendar.monthrange(event.checkinDate.year,
                                            event.checkinDate.month)[1]
        giftDayCount = conf.get('giftDayCount', -1)
        if giftDayCount <= 0:
            giftDayCount = monthDayCount
        giftDayCount = min(giftDayCount, monthDayCount)

        clientId = sessiondata.getClientId(event.userId)
        hallGameId = strutil.getGameIdFromHallClientId(clientId)

        if hallGameId != DIZHU_GAMEID:
            return

        if ftlog.is_debug():
            ftlog.debug('MonthCheckinGift.handleEvent userId=',
                        event.userId, 'gameId=', event.gameId, 'eventType=',
                        type(event), 'checkinDate=', event.checkinDate,
                        'allCheckinCount=', event.status.allCheckinCount,
                        'giftDayCount=', giftDayCount, 'monthDayCount=',
                        monthDayCount)

        giftContent = None
        try:
            if not Tool.checkNow(conf.get('datetime_start'),
                                 conf.get('datetime_end')):
                ftlog.debug('MonthCheckinGift.handleEvent outOfDate userId=',
                            event.userId, 'gameId=', event.gameId,
                            'eventType=', type(event), 'checkinDate=',
                            event.checkinDate, 'allCheckinCount=',
                            event.status.allCheckinCount, 'giftDayCount=',
                            giftDayCount, 'monthDayCount=', monthDayCount)
                return

            giftContent = TYContentRegister.decodeFromDict(
                conf.get('giftContent'))
        except:
            ftlog.error('MonthCheckinGift.handleEvent userId=',
                        event.userId, 'gameId=', event.gameId, 'eventType=',
                        type(event), 'checkinDate=', event.checkinDate,
                        'allCheckinCount=', event.status.allCheckinCount,
                        'giftDayCount=', giftDayCount, 'monthDayCount=',
                        monthDayCount)
            return

        if event.status.allCheckinCount >= giftDayCount:
            assetList = None
            if giftContent:
                userAssets = hallitem.itemSystem.loadUserAssets(event.userId)
                assetList = userAssets.sendContent(
                    DIZHU_GAMEID, giftContent, 1, True,
                    pktimestamp.getCurrentTimestamp(), 'ACTIVITY_REWARD',
                    cls.ACTIVITY_ID)
                changed = TYAssetUtils.getChangeDataNames(assetList)
                mail = conf.get('mail', '')
                if mail:
                    gotContent = giftContent.desc if giftContent.desc else TYAssetUtils.buildContentsString(
                        assetList)
                    mail = strutil.replaceParams(mail,
                                                 {'gotContent': gotContent})
                    message.sendPrivate(HALL_GAMEID, event.userId, 0, mail)
                    changed.add('message')
                datachangenotify.sendDataChangeNotify(HALL_GAMEID,
                                                      event.userId, changed)

            ftlog.info('MonthCheckinGift.statics sendGift userId=',
                       event.userId, 'gameId=', event.gameId, 'eventType=',
                       type(event), 'checkinDate=', event.checkinDate,
                       'allCheckinCount=', event.status.allCheckinCount,
                       'giftDayCount=', giftDayCount, 'monthDayCount=',
                       monthDayCount, 'rewards=',
                       [(a[0].kindId, a[1])
                        for a in assetList] if assetList else None)
Exemplo n.º 8
0
 def getActivityConfig(cls):
     '''
     game/6/activity/0.json
     '''
     return dizhuconf.getActivityConf('bindphonelead')
Exemplo n.º 9
0
 def getDdzActivityConf(cls):
     return dizhuconf.getActivityConf("skilllevel_gift")
Exemplo n.º 10
0
 def getDdzActivityConf(cls):
     '''
     获得game/6/activity/0.json的ddz_dumplings配置
     '''
     return dizhuconf.getActivityConf("ddz_dumplings")
Exemplo n.º 11
0
    def handleEvent(cls, event):
        try:
            gameId = 6
            userId = event.userId
            conf = dizhuconf.getActivityConf("dashi_send")

            # 检查日期在活动日期内
            if not cls.dateCheck(gameId, userId, conf):
                cls.removeDashiItems(gameId, userId, conf)
                return

            # 检查用户当前在地主游戏中
            if not cls.gameCheck(userId, gameId):
                return

            # 获得大师分段位
            dashi_score = gamedata.getGameAttr(userId, gameId,
                                               'skillscore') or 1
            dashi_level = skillscore.get_skill_level(dashi_score)

            # 获取配置中大师分的段位限制
            dashi_level_limit = conf.get("dashi_level", 1)

            if dashi_level < dashi_level_limit:
                return

            # 如果已经发送过大师登陆礼包,则不发送
            attrname = cls.getFlagAttr(conf.get('start_date', '2015-01-01'))
            is_send = gamedata.getGameAttr(userId, gameId, attrname)
            if is_send:
                return

            # 道具生成时间
            timestamp = pktimestamp.getCurrentTimestamp()

            # 要发送的道具列表
            items = conf.get("item_send", [])
            for item in items:
                contentItem = TYContentItem.decodeFromDict(item)
                userAssets = hallitem.itemSystem.loadUserAssets(userId)
                assetKind, _, _ = userAssets.addAsset(gameId,
                                                      contentItem.assetKindId,
                                                      contentItem.count,
                                                      timestamp,
                                                      'DIZHU_DASHI_SEND', 0)

            # 发送邮箱信息
            mail_message = conf.get("mail", "")
            if mail_message:
                pkmessage.sendPrivate(9999, userId, 0, mail_message)

            # 通知用户道具和消息存在改变
            if assetKind.keyForChangeNotify:
                datachangenotify.sendDataChangeNotify(
                    gameId, userId, [assetKind.keyForChangeNotify, 'message'])

            # 成功发送大师登陆礼包,记录下来,避免重复发送
            gamedata.setGameAttr(userId, gameId, attrname, 1)

            ftlog.debug('dashisend dashi_level=', dashi_level,
                        'dashi_level_limit=', dashi_level_limit, 'userId=',
                        userId)

        except:
            ftlog.exception()
Exemplo n.º 12
0
 def getAllRound(cls):
     conf = dizhuconf.getActivityConf("huiyuan_360")
     return len(conf.get("choujiang_round", []))
Exemplo n.º 13
0
    def handleEvent(cls, event):
        try:
            gameId = 6
            userId = event.userId
            conf = dizhuconf.getActivityConf("huiyuan_360")

            if not cls.clientCheck(gameId, userId, conf):
                return

            if not cls.dateCheck(gameId, userId, conf):
                return

            data = gamedata.getGameAttrJson(userId, gameId, cls.attr_act, {})
            now = datetime.now()
            now_day = '%d%02d%02d' % (now.year, now.month, now.day)

            if not data:
                data = {
                    "days": now_day,
                    "all_count": 30,
                    "current_count": 1,
                    "get_count": 0
                }
            else:
                if now_day == data["days"]:
                    # 这段代码用于fix以前的bug
                    if data["get_count"] > data["current_count"]:
                        data["get_count"] = 0
                        gamedata.setGameAttr(userId, gameId, cls.attr_act,
                                             json.dumps(data))
                    return

                lastdate = datetime.strptime(data["days"], '%Y%m%d').date()
                if (now.date() - lastdate).days != 1:
                    data = {
                        "days": now_day,
                        "all_count": 30,
                        "current_count": 1,
                        "get_count": 0
                    }
                else:
                    data["days"] = now_day
                    data["current_count"] += 1

                    # 这段代码用于fix以前的bug
                    if data["get_count"] > data["current_count"]:
                        data["get_count"] = 0

                    if data["current_count"] >= data["all_count"]:
                        data = {
                            "days": now_day,
                            "all_count": 30,
                            "current_count": 1,
                            "get_count": 0
                        }

            ftlog.debug("login30 gameId=", gameId, "userId=", userId, "data=",
                        data)
            gamedata.setGameAttr(userId, gameId, cls.attr_act,
                                 json.dumps(data))

        except:
            ftlog.exception()
Exemplo n.º 14
0
 def getDdzActivityConf(cls):
     return dizhuconf.getActivityConf("item_sender")