示例#1
0
 def _doChangeNameTry(self, userId, clientId, newName):
     #         renameConf = hallconf.getClientRenameConf(clientId)
     #         if (renameConf
     #             and not renameConf.get('containsSensitive', 1)
     #             and keywords.isContains(newName)):
     #             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
     #             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
     if ftlog.is_debug():
         ftlog.debug('hallrename._doChangeNameTry->', code, info)
     if code == -3:
         # name not changed !!
         pass
     elif code == -2:
         # 没有改名卡
         info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     elif code == 0:
         # 改名成功
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
     else:
         # SDK改名失败
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
示例#2
0
 def _sendTodoTaskJumpHighRoom(cls, userId, playMode, clientId):
     # todo fix the pop wnd to ddz's
     if not playMode in dizhuconf.PLAYMODE_ALLSET:
         playMode = dizhuconf.PLAYMODE_DEFAULT
     chosenRoomId, _ = cls._chooseRoom(userId, DIZHU_GAMEID, playMode)
     if chosenRoomId:
         quick_start_ = TodoTaskQuickStart(DIZHU_GAMEID, chosenRoomId)
         info_str_ = dizhuconf.getQuickStartErrorMsg(
             TYRoom.ENTER_ROOM_REASON_GREATER_MAX)
         show_info_ = TodoTaskShowInfo(info_str_, True)
         show_info_.setSubCmd(quick_start_)
         try:
             if cls._useSelfPopWnd(userId):
                 todoTaskObj = TodoTaskHelper.encodeTodoTasks(quick_start_)
                 Alert.sendNormalAlert2Button(DIZHU_GAMEID, userId, '提示',
                                              info_str_, todoTaskObj[0],
                                              '确定', None, '取消')
                 return
         except:
             ftlog.error('_sendTodoTaskJumpHighRoom error userId = ',
                         userId, ' clientId = ', clientId, 'playMode = ',
                         playMode)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId,
                                              show_info_)
         router.sendToUser(msg, userId)
     else:
         cls._sendTodoTaskToUser(userId,
                                 TYRoom.ENTER_ROOM_REASON_GREATER_ALL)
示例#3
0
    def doGetPrize(self, gameId, userId, clientId):
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            status = neituiguang.loadStatus(userId, timestamp)
            if not status.isBindMobile:
                conf = neituiguang.getConf()
                TodoTaskHelper.sendTodoTask(
                    gameId, userId, TodoTaskBindPhone(conf.pleaseBindPhone,
                                                      ''))
                return
            count, assetList = neituiguang.getAllReward(status)
            if count > 0:
                conf = neituiguang.getConf()
                prizeRewardTips = strutil.replaceParams(
                    conf.prizeRewardTips, {
                        'rewardContent':
                        TYAssetUtils.buildContentsString(assetList)
                    })
                TodoTaskHelper.sendTodoTask(gameId, userId,
                                            TodoTaskGoldRain(prizeRewardTips))

                mo = self.buildQueryPrizeResponse(gameId, userId, clientId)
                router.sendToUser(mo, userId)
            else:
                TodoTaskHelper.sendTodoTask(gameId, userId,
                                            TodoTaskShowInfo('奖励已经领取', True))
            datachangenotify.sendDataChangeNotify(gameId, userId,
                                                  ['free', 'promotion_loc'])
        except TYBizException, e:
            TodoTaskHelper.sendTodoTask(gameId, userId,
                                        TodoTaskShowInfo(e.message, True))
示例#4
0
 def _doChangeNameTry(self, userId, clientId, newName):
     #         renameConf = hallconf.getClientRenameConf(clientId)
     #         if (renameConf
     #             and not renameConf.get('containsSensitive', 1)
     #             and keywords.isContains(newName)):
     #             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
     #             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
     if ftlog.is_debug():
         ftlog.debug('hallrename._doChangeNameTry->', code, info)
     if code == -3:
         # name not changed !!
         pass
     elif code == -2:
         # 没有改名卡
         info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(
                 HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
     elif code == 0:
         # 改名成功
         return TodoTaskHelper.sendTodoTask(
             HALL_GAMEID, userId,
             TodoTaskPopTip(hallrename.stringRenameSuccessed))
     else:
         # SDK改名失败
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId,
                                            TodoTaskPopTip(info))
示例#5
0
def sendFriendInviteTodotask(userId, invite_uid, gameId, play_mode, roomId, tableId, info_str, purl):
    """ 推送牌桌好友邀请的todotask
    * 版本 3.732 之后,改为麻将自己的todotask
    """
    todotask = TodoTaskQuickStart(gameId, roomId, tableId)
    todotask.setParam('play_mode', play_mode)
    client_ver = sessiondata.getClientIdVer(userId)

    if client_ver < 3.732:
        show_info_ = TodoTaskShowInfo(info_str, True)
        show_info_.setSubCmd(todotask)
        msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
        router.sendToUser(msg, userId)
    else:
        task = {
                'action':       'pop_wnd_invite',
                'params':       {
                                 'tasks':       [todotask.toDict()],
                                 'invite_uid':   invite_uid,
                                 'purl':         purl,
                                 'info_str':     info_str
                                 }
                }
        mo = MsgPack()
        mo.setCmd('majiang_todotasks')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('tasks', [task])
        router.sendToUser(mo, userId)
示例#6
0
def sendFriendInviteTodotask(userId, invite_uid, gameId, play_mode, roomId,
                             tableId, info_str, purl):
    """ 推送牌桌好友邀请的todotask
    * 版本 3.732 之后,改为麻将自己的todotask
    """
    todotask = TodoTaskQuickStart(gameId, roomId, tableId)
    todotask.setParam('play_mode', play_mode)
    client_ver = sessiondata.getClientIdVer(userId)

    if client_ver < 3.732:
        show_info_ = TodoTaskShowInfo(info_str, True)
        show_info_.setSubCmd(todotask)
        msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
        router.sendToUser(msg, userId)
    else:
        task = {
            'action': 'pop_wnd_invite',
            'params': {
                'tasks': [todotask.toDict()],
                'invite_uid': invite_uid,
                'purl': purl,
                'info_str': info_str
            }
        }
        mo = MsgPack()
        mo.setCmd('majiang_todotasks')
        mo.setResult('gameId', gameId)
        mo.setResult('userId', userId)
        mo.setResult('tasks', [task])
        router.sendToUser(mo, userId)
示例#7
0
文件: httpgame.py 项目: zhaozw/hall37
    def on_praise_friend(cls, gameId, uid, clientId, mo):
        code = mo.getResult('code', 0)
        # vip = mo.getResult('vip')
        if code == 0:
            friend_uid = int(mo.getResult('friend_uid'))
            nick_name = mo.getResult('nick_name')
            friend_nick_name = mo.getResult('friend_nick_name')
            my_add_charm = mo.getResult('my_add_charm')
            friend_add_charm = mo.getResult('friend_add_charm')
            my_charm = mo.getResult('my_charm')
            friend_charm = mo.getResult('friend_charm')

            msg1 = '给"' + friend_nick_name + '"点赞获得' + str(my_add_charm) + '个魅力值'
            msg2 = '"' + nick_name + '"给您点赞获得' + str(friend_add_charm) + '个魅力值'
            from poker.entity.biz.message import message
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(uid), msg1)
            message.send(gameId, message.MESSAGE_TYPE_SYSTEM, int(friend_uid), msg2)
            ftlog.debug('on praise friend.... ' + msg1)
            ftlog.debug('on praise friend.... ' + msg2)

            datachangenotify.sendDataChangeNotify(gameId, uid, 'charm')

            from hall.entity.hallranking import rankingSystem, TYRankingInputTypes
            timestamp = pktimestamp.getCurrentTimestamp()
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             uid, my_charm, timestamp)
            rankingSystem.setUserByInputType(gameId, TYRankingInputTypes.CHARM,
                                             friend_uid, friend_charm, timestamp)
            # 历史获赞次数
            history_praised_num = gamedata.incrGameAttr(friend_uid, gameId, 'history_praised_num', 1)
            mo.setResult('friend_history_praised_num', history_praised_num)

        if code != 2:
            return

        from hall.entity.todotask import TodoTaskPayOrder, TodoTaskShowInfo
        from hall.entity.todotask import TodoTaskHelper
        from hall.entity import hallvip, hallitem

        user_vip = hallvip.userVipSystem.getUserVip(uid)
        delta_exp = user_vip.deltaExpToNextLevel()

        product, _ = hallstore.findProductByContains(gameId, uid, clientId,
                                                     ['coin'], None,
                                                     hallitem.ASSET_CHIP_KIND_ID,
                                                     delta_exp * 1000)

        pay_order = TodoTaskPayOrder(product)
        if user_vip == 0:
            msg = '点赞次数已达今日上限,开通VIP可提高点赞次数上限获得更多福利哦~'
            btnTxt = '开通VIP'
        else:
            msg = '点赞次数已达今日上限,升级VIP等级可提高点赞次数上限获得更多福利哦~'
            btnTxt = '升级VIP'
        dialog_task = TodoTaskShowInfo(msg, True)
        dialog_task.setSubCmd(pay_order)
        dialog_task.setSubText(btnTxt)
        TodoTaskHelper.sendTodoTask(gameId, uid, [dialog_task])
示例#8
0
    def onCmdQuickStart1(cls, msg, userId, gameId, roomId, tableId, playMode,
                         clientId):
        '''
        拦截父类处理的选择房间逻辑,先于父类处理,若选择成功,则不进行父类的选择房间处理逻辑,否则正常走父类的处理逻辑
        '''

        if not pokerconf.isOpenMoreTable(clientId):
            ok, loc = cls.checkUserLoc(userId, gameId, roomId, tableId,
                                       clientId)
            if not ok:
                # 弹框
                tipsPlaying = dizhuconf.getPublicConf('tips.playing',
                                                      '您正在其它房间对局,是否回去?')
                showInfo = TodoTaskShowInfo(tipsPlaying)
                showInfo.setSubCmd(
                    TodoTaskQuickStart(loc[0], loc[1], loc[2], loc[3]))
                TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
                ftlog.debug('DizhuQuickStartV4_0.onCmdQuickStart Fail userId=',
                            userId, 'roomId=', roomId, 'tableId=', tableId,
                            'clientId=', clientId, 'loc=', loc)
                return
            if loc:
                tableId = loc[2]

        _, version, _ = strutil.parseClientId(clientId)
        ftlog.debug("DizhuQuickStartV4_0.onCmdQuickStart: clientId=", clientId,
                    "userId=", userId, "roomId=", roomId,
                    "tableId=", tableId, "version=", version, "type:",
                    type(version), "playMode=", playMode)

        # 地主会优先去匹配比赛的房间,客户端是3.76及更高版本才支持
        if (playMode == None or playMode == "match" or playMode
                == "straightMatch") and roomId == 0 and gameId == 6 and (
                    version >= 3.76 or
                    (version >= 3.73
                     and not (clientId in _DIZHU_QMATCH_V3_73_IGNORE))):
            chose_roomid, ok = cls._chooseDizhuMatchRoom(
                userId, gameId, playMode)
            ftlog.debug(
                "DizhuQuickStartV4_0._chooseDizhuMatchRoom:chosen|room_id=",
                chose_roomid, "userId=", userId, "ok=", ok)
            if ok:
                bigroomid = gdata.getBigRoomId(chose_roomid)
                ftlog.debug(
                    "DizhuQuickStartV4_0._chooseDizhuMatchRoom: userId=",
                    userId, "roomId=", chose_roomid)
                cls.notifyQuickGotoDizhuMatch(gameId, userId, bigroomid)
                return

        if playMode == "match":
            playMode = dizhuconf.PLAYMODE_123

        super(DizhuQuickStartV4_0,
              cls).onCmdQuickStart(msg, userId, gameId, roomId, tableId,
                                   playMode, clientId)
        return
示例#9
0
    def doGetInviteReward(self, gameId, userId, inviteeId, clientId):
        """
        获取推荐人奖励
        作为上线奖励
        """
        if (not inviteeId) or (inviteeId <= 0):
            TodoTaskHelper.sendTodoTask(gameId, userId,
                                        TodoTaskShowInfo('请输入推荐人ID', True))
            return

        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            status = hall_simple_invite.loadStatus(userId, timestamp)
            inviteeInvitation = status.findInvitee(inviteeId)
            if not inviteeInvitation:
                TodoTaskHelper.sendTodoTask(
                    gameId, userId, TodoTaskShowInfo('没有推荐此人,请重新领取', True))
                return

            if inviteeInvitation.inviterState == Invitation.STATE_REWARDED:
                TodoTaskHelper.sendTodoTask(gameId, userId,
                                            TodoTaskShowInfo('已经领取推荐奖励', True))
                return

            if hall_simple_invite.getGameCount(inviteeId, clientId) == 0:
                TodoTaskHelper.sendTodoTask(gameId, userId,
                                            TodoTaskShowInfo('玩家还未进行游戏', True))
                return

            inviteeInvitation.inviterState = Invitation.STATE_REWARDED
            hall_simple_invite.saveStatus(status)
            ftlog.info('doGetInviteReward userId=', status.userId, 'invitee=',
                       inviteeId)

            conf = hall_simple_invite.getSimpleInviteConf(
                userId, gameId, clientId)
            mo = MsgPack()
            mo.setCmd('invite_info')
            mo.setResult('action', 'get_invite_reward')
            mo.setResult('gameId', gameId)
            count = self.getTotalReward(status)
            if conf.inviteRewardItem:
                mo.setResult('totalReward',
                             count * conf.inviteRewardItem.count)
                self.addUserItemByKindId(userId, gameId, clientId,
                                         conf.inviteRewardItem.assetKindId,
                                         conf.inviteRewardItem.count)

            userInfo = {}
            userInfo['userId'] = inviteeId
            userInfo['rewardState'] = inviteeInvitation.inviterState
            mo.setResult('updateInfo', userInfo)
            router.sendToUser(mo, userId)
        except TYBizException, e:
            TodoTaskHelper.sendTodoTask(gameId, userId,
                                        TodoTaskShowInfo(e.message, True))
示例#10
0
    def onRoomCreateCustomTable(self, gameId, msg):
        '''在GR处理自建桌逻辑
        '''
        if ftlog.is_debug():
            ftlog.debug("<< |msg", msg, caller=self)

        userId = msg.getParam("userId")
        selectedRoomOptions = msg.getParam("selectedRoomOptions")
        if not selectedRoomOptions:
            return
        customConfVer = msg.getParam("customConfVer")
        if customConfVer != difangConf.getCustomRoomConf(gameId, 'ver'):
            ftlog.warn("onRoomCreateCustomTable confVer error! |msg:", msg, caller=self)
            return
        gameRoundN = selectedRoomOptions.get("gameRoundN")
        if not gameRoundN:
            return
        roomId = msg.getParam("roomId")
        room = gdata.rooms()[roomId]
        clientId = msg.getParam("clientId")

        needRoomCardN = difangConf.getCustomRoomConf(gameId, 'roomCardNCost').get(str(gameRoundN), -1)
        if needRoomCardN == -1:
            tips = difangConf.getCustomRoomConf(difangConf.GAME_ID, 'err_tips')
            tip = tips[self.CREATE_CUSTOM_TABLE_ERR_NO_NOT_ALLOW]
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(tip, True))
            ftlog.warn("onRoomCreateCustomTable get needRoomCardN error! |msg:", msg, caller=self)
            self.sendGameCreateCustomTableRes(0, userId)
            return

        if ftlog.is_debug():
            ftlog.debug("|userId, gameId, customConfVer, gameRoundN, needRoomCardN:",
                        userId, gameId, customConfVer, gameRoundN, needRoomCardN, caller=self)

        if needRoomCardN > 0 and not self.isCardEnough(gameId, userId, needRoomCardN, clientId):
            tips = difangConf.getCustomRoomConf(difangConf.GAME_ID, 'err_tips')
            tip = tips[self.CREATE_CUSTOM_TABLE_ERR_NO_NOT_ENOUGH]
            TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(tip, True))
            self.sendGameCreateCustomTableRes(0, userId)
            return

        tableId = room.getIdleTableId()
        if not tableId:
            ftlog.error("there are no idle tables!", "|userId, roomId:", userId, room.roomId)
            return

        ftId = self.assignFriendTableId(gameId, tableId)

        ftlog.info("onRoomCreateCustomTable |userId, tableId, ftId:", userId, tableId, ftId, caller=self)
        self.sendGameCreateCustomTableRes(ftId, userId)
        gamedata.setGameAttr(userId, gameId, "selectedRoomOptions", json.dumps(selectedRoomOptions))
        gamedata.setGameAttr(userId, gameId, "customConfVer", customConfVer)

        shadowRoomId = tableId / 10000
        room.querySitReq(userId, shadowRoomId, tableId, clientId,
                         extParams={"selectedRoomOptions": selectedRoomOptions, "ftId": ftId})
示例#11
0
 def _doChangeNameCheck(self, userId, clientId):
     canRename, desc = hallrename.checkRename(HALL_GAMEID, userId)
     if canRename:
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskRename(desc))
     else:
         info = TodoTaskShowInfo(desc, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
示例#12
0
 def _doChangeNameCheck(self, userId, clientId):
     canRename, desc = hallrename.checkRename(HALL_GAMEID, userId)
     if canRename:
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskRename(desc))
     else:
         info = TodoTaskShowInfo(desc, True)
         if hallrename.payOrder:
             product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
             if product:
                 info.setSubCmd(TodoTaskPayOrder(product))
         return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
示例#13
0
    def _doChangeNameTry(self, userId, clientId, newName):
#         renameConf = hallconf.getClientRenameConf(clientId)
#         if (renameConf
#             and not renameConf.get('containsSensitive', 1)
#             and keywords.isContains(newName)):
#             info = TodoTaskShowInfo(hallrename.stringRenameContainsSensitive)
#             return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        code, info = hallrename.tryRename(HALL_GAMEID, userId, newName)
        if ftlog.is_debug():
            ftlog.debug('hallrename._doChangeNameTry->', code, info)

        CLIENT_VER = 4.57
        _, clientVer, _ = strutil.parseClientId(clientId)

        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry clientVer", userId, clientId, newName, code, info, clientVer)

        reInfo = ""
        if code == -3 :
            reInfo = "昵称没有变化"
        elif code == -2 :
            # 没有改名卡
            info = TodoTaskShowInfo(hallrename.stringRenameCardRequired, True)
            if hallrename.payOrder:
                product, _ = hallstore.findProductByPayOrder(HALL_GAMEID, userId, clientId, hallrename.payOrder)
                if product:
                    info.setSubCmd(TodoTaskPayOrder(product))
            return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, info)
        elif code == 0 :
            reInfo = "昵称修改成功"
            # 改名成功
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry ok", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(hallrename.stringRenameSuccessed))
        else:
            #reInfo = "修改昵称失败,请重试"
            reInfo = info
            # SDK改名失败
            if clientVer < CLIENT_VER:
                if ftlog.is_debug():
                    ftlog.debug("_doChangeNameTry fail", userId, clientId, newName, code, info, clientVer)
                return TodoTaskHelper.sendTodoTask(HALL_GAMEID, userId, TodoTaskPopTip(info))
                    
        mo = MsgPack()
        mo.setCmd('change_name')
        mo.setResult('action', 'try')
        mo.setResult('userId', userId)
        mo.setResult('code', code)
        mo.setResult('reInfo', reInfo)
        router.sendToUser(mo, userId)
        if ftlog.is_debug():
            ftlog.debug("_doChangeNameTry result",userId, clientId, newName, code, reInfo)
示例#14
0
 def handleItemBindingsException(self, itemId, gameId, userId, clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.itemBindings.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.itemBindings.getParam('todotask')
         if todotask:
             todotask = TodoTaskRegister.decodeFromDict(todotask).newTodoTask(gameId, userId, clientId)
             TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
             return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
示例#15
0
 def doGetInviteReward(self, gameId, userId, inviteeId, clientId):
     """
     获取推荐人奖励
     作为上线奖励
     """
     if (not inviteeId) or (inviteeId <= 0):
         TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('请输入推荐人ID', True))
         return
         
     try:
         status = hall_simple_invite.loadStatus(userId)
         inviteeInvitation = status.findInvitee(inviteeId)
         if not inviteeInvitation:
             TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('没有推荐此人,请重新领取', True))
             return
             
         if inviteeInvitation.inviterState == Invitation.STATE_REWARDED:
             TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo('已经领取推荐奖励', True))
             return
         
         inviteeInvitation.inviterState = Invitation.STATE_REWARDED
         hall_simple_invite.saveStatus(status)
         ftlog.info('doGetInviteReward userId=', status.userId, 'invitee=', inviteeId)
         
         mo = MsgPack()
         mo.setCmd('invite_info')
         mo.setResult('action', 'get_invite_reward')
         mo.setResult('gameId', gameId)
         _, rCounts = self.getInviteesRewardInfo(status, Invitation.STATE_REWARDED, clientId)
         count = self.getTotalReward(status, userId, gameId, clientId)
         rObj = hall_simple_invite.getSimpleInviteRewardByIndex(userId, gameId, rCounts, clientId)
         if rObj:
             mo.setResult('totalReward', count)
             self.addUserItemByKindId(userId, gameId, clientId, rObj.assetKindId, rObj.count)
             
         userInfo = {}
         userInfo['userId'] = inviteeId
         userInfo['rewardState'] = inviteeInvitation.inviterState
         mo.setResult('updateInfo', userInfo)
         router.sendToUser(mo, userId)
         
         # 給userId补发一个系统消息
         inviteeName, _ = self.getUserNameAndPic(inviteeId)
         inviteRewardDesc = hall_simple_invite.getSimpleInviteRewardDescByIndex(userId, gameId, rCounts, clientId)
         if inviteRewardDesc:
             pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId, inviteeName + '通过您的分享登录斗地主游戏,您获得' + inviteRewardDesc)
         
     except TYBizException, e:
         TodoTaskHelper.sendTodoTask(gameId, userId, TodoTaskShowInfo(e.message, True))
示例#16
0
    def doPutMessage(self, gameId, fromUid, toUid, mtype, msg, ismgr, scope,
                     clientIds):
        button = runhttp.getParamStr('button', None)
        button = strutil.loads(button, ignoreException=True)
        data = None
        mo = MsgPack()

        if mtype == 0 and len(msg) > 0 and toUid > 0 and gameId >= 0:
            # 发送私人消息
            # 必须参数
            # 1)msg - 消息
            # 2)toUid - 接收消息的userId
            # 3)gameId
            data = pkmessage.sendPrivate(gameId, toUid, fromUid, msg, button)
        elif mtype == 1 and len(msg) > 0 and gameId >= 0:
            # 发送站内消息到全体用户
            # 必选参数
            # msg - 消息
            # gameId
            data = pkmessage.sendGlobal(gameId, msg, button)
        elif mtype == 2 and gameId > 0 and len(msg) > 0:
            # 发送LED
            # TODO 当前Game服务为4,5,6号 , 每个服务都发送
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            mo.setParam('gameId', gameId)
            mo.setParam('ismgr', 1)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True
        elif mtype == 3 and gameId > 0 and toUid > 0 and len(msg) > 0:
            # 封装popwnd
            # 必选参数
            # gameId
            # toUid 接收弹窗的userId
            # msg 弹窗消息内容
            task = TodoTaskShowInfo(msg, True)
            mo = TodoTaskHelper.makeTodoTaskMsg(gameId, toUid, task)
            # 将消息发送给此人
            router.sendToUser(mo, toUid)
            data = True
        elif mtype == 4 and gameId > 0 and len(msg) > 0 and len(scope) > 0:
            mo.setCmd('send_led')
            mo.setParam('msg', msg)
            ftlog.info('send_led new msg=', msg)
            mo.setParam('gameId', gameId)
            ftlog.info('send_led new gameId=', gameId)
            mo.setParam('ismgr', ismgr)
            ftlog.info('send_led new ismgr=', ismgr)
            mo.setParam('scope', scope)
            ftlog.info('send_led new scope=', scope)
            mo.setParam('clientIds', clientIds)
            ftlog.info('send_led new clientIds=', clientIds)
            router.sendToAll(mo, gdata.SRV_TYPE_UTIL)
            data = True

        if data == None:
            mo.setError(1, 'params error')
        else:
            mo.setResult('ok', 'true')
        return mo
示例#17
0
 def handleItemActionConditionException(self, itemId, gameId, userId, clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.condition.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.condition.getParam('todotask')
         if todotask:
             factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask)
             if factory:
                 todotask = factory.newTodoTask(gameId, userId, clientId)
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
                 return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
示例#18
0
 def sendTodoTaskShowInfo(cls, gameId, userId, info):
     '''
     弹窗提示TodoTask
     '''
     task = TodoTaskShowInfo(info, True)
     mo = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, task)
     router.sendToUser(mo, userId)
示例#19
0
 def handleItemBindingsException(self, itemId, gameId, userId, clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.itemBindings.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(
             gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.itemBindings.getParam('todotask')
         if todotask:
             todotask = TodoTaskRegister.decodeFromDict(
                 todotask).newTodoTask(gameId, userId, clientId)
             TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
             return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
示例#20
0
    def _handleSigninFeeNotEnoughException(cls, room, ex, uid, mo):
        payOrder = ex.fee.getParam('payOrder')

        clientId = sessiondata.getClientId(uid)
        clientOs, _clientVer, _ = strutil.parseClientId(clientId)
        msg = runcmd.getMsgPack()
        ddzver = msg.getParam('ddzver', 0) if msg else 0

        ftlog.debug("groupmatch._handleSigninFeeNotEnoughException", "userId", uid, "_clientVer=", _clientVer)
        if ddzver >= 3.772:
            cls._handleSigninFeeNotEnoughException_V3_772(room, ex, uid, mo)
            return

        if payOrder:
            clientOs = clientOs.lower()
            product, _shelves = hallstore.findProductByPayOrder(room.gameId, uid, clientId, payOrder)
            if product:
                buyType = ''
                btnTxt = ''
                if ex.fee.assetKindId == hallitem.ASSET_CHIP_KIND_ID and clientOs == 'winpc':
                    user_diamond = userdata.getAttrInt(uid, 'diamond')
                    if user_diamond >= int(product.priceDiamond):
                        buyType = 'consume'
                        btnTxt = '兑换'
                    else:
                        buyType = 'charge'
                        btnTxt = '去充值'
                orderShow = TodoTaskOrderShow.makeByProduct(ex.fee.failure, '', product, buyType)
                orderShow.setParam('sub_action_btn_text', btnTxt)
                mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, orderShow)
                router.sendToUser(mo, uid)
                return True
        mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, TodoTaskShowInfo(ex.fee.failure))
        router.sendToUser(mo, uid)
示例#21
0
    def doGetBindReward(self, gameId, userId, clientId):
        """
        获取绑定推荐人奖励
        作为下线领取的奖励,只有一次
        """
        try:
            timestamp = pktimestamp.getCurrentTimestamp()
            status = hall_simple_invite.loadStatus(userId, timestamp)
            if (status.rewardState != Invitation.STATE_REWARDED) and \
                            status.getRewardState(userId, gameId, clientId) == Invitation.STATE_CAN_GET_REWARD:
                conf = hall_simple_invite.getSimpleInviteConf(
                    userId, gameId, clientId)
                status.setRewardState(Invitation.STATE_REWARDED)
                hall_simple_invite.saveStatus(status)
                mo = MsgPack()
                mo.setCmd('invite_info')
                mo.setResult('action', 'get_bind_reward')
                mo.setResult('rewardState', status.rewardState)
                mo.setResult('gameId', gameId)
                count = self.getTotalReward(status)
                if conf.inviteRewardItem:
                    if 0 == count:
                        mo.setResult('totalReward', 0)
                    else:
                        total = gamedata.getGameAttrInt(
                            userId, HALL_GAMEID, 'simpleInviteRewardCount')
                        if 0 == total:
                            total = count * conf.inviteRewardItem.count
                            gamedata.incrGameAttr(userId, HALL_GAMEID,
                                                  'simpleInviteRewardCount',
                                                  total)
                        mo.setResult('totalReward', total)

                    self.addUserItemByKindId(userId, gameId, clientId,
                                             conf.inviteRewardItem.assetKindId,
                                             conf.inviteRewardItem.count)
                    gamedata.incrGameAttr(userId, HALL_GAMEID,
                                          'simpleInviteRewardCount',
                                          conf.inviteRewardItem.count)

                router.sendToUser(mo, userId)
            else:
                TodoTaskHelper.sendTodoTask(gameId, userId,
                                            TodoTaskShowInfo('奖励已经领取', True))
        except TYBizException, e:
            TodoTaskHelper.sendTodoTask(gameId, userId,
                                        TodoTaskShowInfo(e.message, True))
示例#22
0
    def _doSit(self, msg, userId, seatId, clientId, checkGameStart=True):

        selectedRoomOptions = msg.getParam("selectedRoomOptions")
        ftId = msg.getParam("ftId")
        if ftlog.is_debug():
            ftlog.debug(self._baseLogStr("<<", userId),
                        "|selectedRoomOptions, ftId, self.cMaxSeatNum:",
                        selectedRoomOptions,
                        ftId,
                        self.cMaxSeatNum,
                        caller=self)

        if selectedRoomOptions:
            self._refreshCustomConf(selectedRoomOptions)
            self.firstPlayerId = userId  # 房主
            self.ftId = ftId  # 6位自建号
            self.createTime = int(time.time())
            ftlog.info(self._baseLogStr("_doSit <<", userId),
                       "|selectedRoomOptions, ftId, self.cMaxSeatNum:",
                       selectedRoomOptions,
                       ftId,
                       self.cMaxSeatNum,
                       caller=self)

        result = super(DiFangCustomTable, self)._doSit(msg, userId, seatId,
                                                       clientId)

        if result["reason"] == TYRoom.ENTER_ROOM_REASON_TABLE_FULL:
            tip = u"您好, 牌桌已满。"
            TodoTaskHelper.sendTodoTask(self.gameId, userId,
                                        TodoTaskShowInfo(tip, True))
            return result

        if result["reason"] != TYRoom.ENTER_ROOM_REASON_OK:
            return result

        # 坐下成功, 人满后检查开桌
        if ftlog.is_debug():
            ftlog.debug(self._baseLogStr(">>", userId),
                        "|self.playersNum, self.cMaxSeatNum:",
                        self.playersNum,
                        self.cMaxSeatNum,
                        caller=self)

        if selectedRoomOptions:
            for _ in range(self.cMaxSeatNum - self.playersNum):
                self.sendRobotNotifyCallUp(None)

        if self.gamePlay.isWaitingState(
        ) and checkGameStart and self.playersNum == self.cMaxSeatNum:
            func = functools.partial(self.gamePlay.doActionCheckStartGame)
            msgPackParams = {"seatId": result["seatId"] - 1}
            self.callLaterFunc(0,
                               func,
                               userId,
                               timer=None,
                               msgPackParams=msgPackParams)  # 需要异步锁桌子

        return result
示例#23
0
def sendFriendInviteEnterGameTodotask(userId, gameId, play_mode, roomId, tableId, info_str):
    """ 构造从大厅主界面进桌子的todotask
    """
    enter_param = {
                 'type':         'quickstart',
                 'pluginParams': {
                     'play_mode':       play_mode,
                     'roomId':          roomId,
                     'tableId':         tableId,
                     'gameType':        9   # TODO: 写死了9,因为目前只有贵宾桌使用到了这个功能
                 }
            }
    todotask = TodoTaskEnterGameNew(gameId, enter_param)
    show_info_ = TodoTaskShowInfo(info_str, True)
    show_info_.setSubCmd(todotask)
    msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
    router.sendToUser(msg, userId)
示例#24
0
文件: todotask.py 项目: zhaozw/hall37
def sendFriendInviteEnterGameTodotask(userId, gameId, play_mode, roomId, tableId, info_str):
    """ 构造从大厅主界面进桌子的todotask
    """
    enter_param = {
        'type': 'quickstart',
        'pluginParams': {
            'play_mode': play_mode,
            'roomId': roomId,
            'tableId': tableId,
            'gameType': 9  # TODO: 写死了9,因为目前只有贵宾桌使用到了这个功能
        }
    }
    todotask = TodoTaskEnterGameNew(gameId, enter_param)
    show_info_ = TodoTaskShowInfo(info_str, True)
    show_info_.setSubCmd(todotask)
    msg = TodoTaskHelper.makeTodoTaskMsg(gameId, userId, show_info_)
    router.sendToUser(msg, userId)
示例#25
0
    def sendRewards(self, userId, gameId, clientId):
        bSend = True

        for cond in self.conditions:
            if not cond.check(gameId, userId, clientId,
                              pktimestamp.getCurrentTimestamp()):
                bSend = False

        if bSend:
            from hall.entity import hallitem
            userAssets = hallitem.itemSystem.loadUserAssets(userId)
            assetList = userAssets.sendContent(
                gameId, self.items, 1, True, pktimestamp.getCurrentTimestamp(),
                'LOGIN_REWARD', 0)

            if assetList:
                if ftlog.is_debug():
                    ftlog.debug('hall_login_reward.sendReward gameId=', gameId,
                                'userId=', userId, 'rewards=',
                                [(atup[0].kindId, atup[1])
                                 for atup in assetList])
                # 记录登录奖励获取时间
                gamedata.setGameAttr(userId, HALL_GAMEID, 'login_reward',
                                     pktimestamp.getCurrentTimestamp())
                # 通知更新
                changedDataNames = TYAssetUtils.getChangeDataNames(assetList)
                datachangenotify.sendDataChangeNotify(gameId, userId,
                                                      changedDataNames)
                pkmessage.send(gameId, pkmessage.MESSAGE_TYPE_SYSTEM, userId,
                               self.mail)
                from poker.util import strutil
                _, cVer, _ = strutil.parseClientId(clientId)
                if cVer < 3.90:
                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowInfo(self.mail, True))
                else:
                    rewardsList = []
                    for assetItemTuple in assetList:
                        '''
                        0 - assetItem
                        1 - count
                        2 - final
                        '''
                        assetItem = assetItemTuple[0]
                        reward = {}
                        reward['name'] = assetItem.displayName
                        reward['pic'] = assetItem.pic
                        reward['count'] = assetItemTuple[1]
                        rewardsList.append(reward)

                    if ftlog.is_debug():
                        ftlog.debug(
                            'hall_login_reward.TodoTaskShowRewards rewardsList: ',
                            rewardsList)

                    TodoTaskHelper.sendTodoTask(
                        gameId, userId, TodoTaskShowRewards(rewardsList))
示例#26
0
 def handleItemActionConditionException(self, itemId, gameId, userId,
                                        clientId, e):
     showInfo = TodoTaskShowInfo(e.message)
     payOrder = e.condition.getParam('payOrder')
     if payOrder:
         product, shelves = hallstore.findProductByPayOrder(
             gameId, userId, clientId, payOrder)
         if product:
             showInfo.setSubCmd(TodoTaskGotoShop(shelves.name))
     else:
         todotask = e.condition.getParam('todotask')
         if todotask:
             factory = hallpopwnd.decodeTodotaskFactoryByDict(todotask)
             if factory:
                 todotask = factory.newTodoTask(gameId, userId, clientId)
                 TodoTaskHelper.sendTodoTask(gameId, userId, todotask)
                 return
     TodoTaskHelper.sendTodoTask(gameId, userId, showInfo)
示例#27
0
 def _handleSigninException(cls, room, ex, uid, mo):
     msg = runcmd.getMsgPack()
     ddzver = msg.getParam('ddzver', 0) if msg else 0
     if ddzver < 3.772:
         infoTodotask = TodoTaskShowInfo(ex.message)
         mo = TodoTaskHelper.makeTodoTaskMsg(room.gameId, uid, infoTodotask)
         router.sendToUser(mo, uid)
     else:
         cls.sendDizhuFailureMsg(room.gameId, uid, '报名失败', ex.message, None)
示例#28
0
 def _handleSigninException(self, ex, userId, mp):
     msg = runcmd.getMsgPack()
     ddzver = msg.getParam('ddzver', 0) if msg else 0
     if ddzver < 3.772:
         infoTodotask = TodoTaskShowInfo(ex.message)
         mp = TodoTaskHelper.makeTodoTaskMsg(self.gameId, userId, infoTodotask)
         router.sendToUser(mp, userId)
     else:
         self.sendDizhuFailureMsg(self.gameId, userId, '报名失败', ex.message, None)
示例#29
0
def handleLotteryRequest(userId, gameId, clientId, msg):
    action = msg.getParam('action')
    ftlog.debug('handleLotteryRequest action=', action, 'userId=', userId,
                'gameId=', gameId, 'clientId=', clientId)
    if action == 'lottery_card':
        #减少抽奖卡,抽奖
        timestamp = pktimestamp.getCurrentTimestamp()
        userAssets = hallitem.itemSystem.loadUserAssets(userId)
        _, consumeCount, _final = userAssets.consumeAsset(
            gameId, hallitem.ASSET_ITEM_LOTTERY_CARD_ID, 1, timestamp,
            'HALL_LOTTERY', 0)
        if consumeCount < 1:
            #金币抽奖
            result = {}
            result["type"] = "chip"
            result["coinNum"] = 1000
            return result
        datachangenotify.sendDataChangeNotify(gameId, userId, 'item')
        result = {}
        result = doLottery(gameId, clientId, userId)
        if result:
            userAssets = hallitem.itemSystem.loadUserAssets(userId)
            timestamp = pktimestamp.getCurrentTimestamp()
            result["card"] = userAssets.balance(
                gameId, hallitem.ASSET_ITEM_LOTTERY_CARD_ID, timestamp)
        return result
    elif action == 'lottery_chip':
        #减少金币,抽奖
        chipNow = userchip.getChip(userId)
        if chipNow < 20000:
            #去商城
            ret = TodoTaskShowInfo('您的金币不足两万,请去商城购买', True)
            ret.setSubCmd(TodoTaskGotoShop('coin'))
            result = {}
            result["todotask"] = ret.toDict()
            return result
        else:
            #金币抽
            coinDel = -1000
            userchip.incrChip(userId, gameId, coinDel,
                              daoconst.CHIP_NOT_ENOUGH_OP_MODE_CLEAR_ZERO,
                              'HALL_LOTTERY', 0, clientId)
            datachangenotify.sendDataChangeNotify(gameId, userId, 'chip')
            return doLottery(gameId, clientId, userId)
示例#30
0
def notifyUserGameWillShutDown(userId, clientId, isNeedPopShutDownGameWnd):
    #过期不弹窗
    nowStamp = int(time.time())
    if nowStamp >= 1524326400:
        return
    if not isNeedPopShutDownGameWnd:
        return
    from hall.entity.todotask import TodoTaskHelper
    from hall.entity.todotask import TodoTaskShowInfo
    TodoTaskHelper.sendTodoTask(9999, userId, TodoTaskShowInfo('因运营需要,4月19日起暂停发财扑克(含天地麻将)等功能模块,恢复时间请关注官网,感谢理解!', True))
示例#31
0
 def _sendTodoTaskToUserWithTip(cls, userId, tip):
     t = TodoTaskShowInfo(tip, True)
     try:
         if cls._useSelfPopWnd(userId):
             Alert.sendNormalAlert(DIZHU_GAMEID, userId, '提示', tip, None, '确定')
             return
     except:
         ftlog.error('DizhuQuickStart _sendTodoTaskToUserWithTip userId = ', userId,
                     'tip = ', tip)
     msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
     router.sendToUser(msg, userId)
示例#32
0
 def doBuyProduct(self, gameId, userId, prodId):
     try:
         clientId = sessiondata.getClientId(userId)
         orderId = self._makeOrderId(gameId, userId, prodId)
         orderDeliveryResult = hallstore.exchangeProduct(
             gameId, userId, clientId, orderId, prodId, 1)
         mo = StoreHelper.makeProductDeliveryResponse(
             userId, orderDeliveryResult)
         router.sendToUser(mo, userId)
     except TYBizException, e:
         TodoTaskHelper.sendTodoTask(gameId, userId,
                                     TodoTaskShowInfo(e.message))
示例#33
0
    def doFriendCall(self, gameId, userId):
        ftlog.debug('doFriendCall...')

        cmd = runcmd.getMsgPack()
        # router.sendToUser(mo, userId)
        # clientId = runcmd.getClientId(cmd)
        action = cmd.getParam('action')

        if action == 'invite_to_game':
            # 邀请好友牌桌游戏
            enterParams = cmd.getParam('enterParams')
            note = cmd.getParam('note')
            invitees = cmd.getParam('invitees')
            self.processInvitees(enterParams, note, invitees, userId, gameId)
            return
        elif action == 'answer_to_invite':
            # 对好友邀请的应答
            inviter = cmd.getParam('inviter')
            answer = cmd.getParam('answer')
            self.processInviteAnswser(inviter, answer, userId, gameId)
            return
        elif action in [
                'get_friends_rank', 'get_friend_tip_info', 'praise_friend'
        ]:
            from hall.entity import hallvip
            try:
                vip = hallvip.userVipSystem.getUserVip(userId).vipLevel.level
            except:
                vip = 0
            cmd.setParam('vip', vip)
        elif action == 'add_friend':
            if self._isObserver(userId):
                show_info_task = TodoTaskShowInfo("对不起,旁观时不能加好友哦~")
                TodoTaskHelper.sendTodoTask(gameId, userId, show_info_task)
                return

        # if not clientId:
        #     clientId = sessiondata.getClientId(userId)
        params = cmd._ht['params']
        tcp_params = strutil.cloneData(params)
        del tcp_params['authorCode']

        del params['action']
        del params['gameId']
        params['appId'] = gameId
        # params['from_tcp'] = 1

        import json
        params['tcp_params'] = json.dumps(tcp_params)

        url = self.action_urls[action]
        ftlog.debug('handleFriendCall post', url, params)
        sdkclient._requestSdk(url, params, needresponse=False)
 def __init__(self, title, imgUrl, payOrder=None, confirm=0, confirmDesc=None, subText=None):
     super(TodoTaskFirstRecharge, self).__init__('pop_first_recharge')
     self.setParam('title', title)
     self.setParam('imgUrl', imgUrl)
     if subText:
         self.setParam('subText', subText)
         self.setParam('sub_action_text', subText)
     if payOrder:
         subCmd = payOrder
         if isinstance(payOrder, TYProduct):
             subCmd = TodoTaskPayOrder(payOrder)
         if confirm:
             confirmDesc = confirmDesc or ''
             if confirmDesc:
                 confirmDesc = strutil.replaceParams(confirmDesc, {
                                                         'product.displayName':subCmd.getParam('name', ''),
                                                         'product.price':subCmd.getParam('price', '')
                                                     })
             info = TodoTaskShowInfo(confirmDesc, True)
             info.setSubCmd(subCmd)
             subCmd = info
         self.setSubCmd(subCmd)
示例#35
0
 def _sendTodoTaskToUser(self, userId):
     tip = ''
     t = TodoTaskShowInfo(tip, True)
     try:
         if ftlog.is_debug():
             ftlog.debug('DizhuTableCtrMix._sendTodoTaskToUser userId = ',
                         userId, 'roomId=', self.roomId, 'tableId=',
                         self.tableId, 'tip=', tip)
         msg = TodoTaskHelper.makeTodoTaskMsg(DIZHU_GAMEID, userId, t)
         router.sendToUser(msg, userId)
     except:
         ftlog.error('DizhuTableCtrMix._sendTodoTaskToUser userId=', userId,
                     'roomId=', self.roomId, 'tableId=', self.tableId,
                     'tip=', tip)
示例#36
0
 def handleException(self, itemId, gameId, userId, clientId, e):
     if ftlog.is_debug():
         ftlog.debug('ItemTcpHandler.handleException itemId=', itemId,
                     'gameId=', gameId, 'userId=', userId, 'clientId=',
                     clientId, 'e=', e)
     if isinstance(e, TYItemActionConditionNotEnoughException):
         self.handleItemActionConditionException(itemId, gameId, userId,
                                                 clientId, e)
     elif isinstance(e, TYItemBindingsException):
         self.handleItemBindingsException(itemId, gameId, userId, clientId,
                                          e)
     else:
         TodoTaskHelper.sendTodoTask(gameId, userId,
                                     TodoTaskShowInfo(e.message))
示例#37
0
def makeBeforeActivityTodoTasks(gameId, userId, clientId):
    try:
        intClientId = pokerconf.clientIdToNumber(clientId)
        enable = pkconfigure.getGameJson(gameId, 'pop.activity', {},
                                         intClientId).get('enable', 0)
        if not enable:
            return None
        msg = pkconfigure.getGameJson(gameId, 'pop.activity', {},
                                      pkconfigure.DEFAULT_CLIENT_ID)
        if msg:
            return TodoTaskShowInfo(msg)
    except:
        ftlog.exception()
    return None
示例#38
0
def toShop():
    result = {}
    ret = TodoTaskShowInfo('您的钻石不足,请去商城购买', True)
    ret.setSubCmd(TodoTaskGotoShop('diamond'))
    result['todotask'] = ret.toDict()
    return result
示例#39
0
    def doQuickBuyGetInfo(self, gameId, userId):
        clientId = sessiondata.getClientId(userId)
        toStoreTodotask = TodoTaskGotoShop('coin')
        if hallstore.storeSystem.isCloseLastBuy(clientId):
            TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask)
            return

        lastBuyProduct, _lastBuyClientId = hallstore.storeSystem.getLastBuyProduct(gameId, userId)
        if (not lastBuyProduct
            or not lastBuyProduct.recordLastBuy
            or not hallstore.storeSystem.canBuyProduct(gameId, userId, clientId, lastBuyProduct, 1)):
            if hallstore.storeSystem.lastBuyConf.payOrder:
                product, _ = hallstore.findProductByPayOrder(gameId, userId, clientId,
                                                             hallstore.storeSystem.lastBuyConf.payOrder)
                if product:
                    payOrderTodoTask = TodoTaskPayOrder(product)
                    desc = strutil.replaceParams(hallstore.storeSystem.lastBuyConf.desc2,
                                                 {'product.displayName': product.displayName,
                                                  'product.price': product.price})
                    popInfoTodoTask = TodoTaskShowInfo(desc, True)
                    popInfoTodoTask.setSubCmd(payOrderTodoTask)
                    TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask)
                    return
            TodoTaskHelper.sendTodoTask(gameId, userId, toStoreTodotask)
            return

        payOrderTodoTask = TodoTaskPayOrder(lastBuyProduct)
        desc = strutil.replaceParams(hallstore.storeSystem.lastBuyConf.desc,
                                     {'product.displayName': lastBuyProduct.displayName,
                                      'product.price': lastBuyProduct.price})
        popInfoTodoTask = TodoTaskShowInfo(desc, True)
        popInfoTodoTask.setSubCmd(payOrderTodoTask)
        popInfoTodoTask.setSubText(hallstore.storeSystem.lastBuyConf.subText)

        popInfoTodoTask.setSubCmdExt(toStoreTodotask)
        popInfoTodoTask.setSubTextExt(hallstore.storeSystem.lastBuyConf.subTextExt)
        TodoTaskHelper.sendTodoTask(gameId, userId, popInfoTodoTask)