Пример #1
0
    def onMsgTableBegin(self):
        roomTypeName = self.getRoomConfKey('typeName')
        ftlog.debug('RobotUser.onMsgTableBegin roomId=', self.roomId,
                    'roomTypeName=', roomTypeName)
        if roomTypeName in (rooms.tyRoomConst.ROOM_TYPE_NAME_BIG_MATCH,
                            rooms.tyRoomConst.ROOM_TYPE_NAME_ARENA_MATCH,
                            rooms.tyRoomConst.ROOM_TYPE_NAME_GROUP_MATCH,
                            rooms.tyRoomConst.ROOM_TYPE_NAME_ERDAYI_MATCH,
                            'dizhu_group_match', 'dizhu_arena_match',
                            'dizhu_erdayi_match'):
            ftlog.debug('send enter and sign in match !!!')
            moEnterMatch = MsgPack()
            moEnterMatch.setCmdAction('room', 'enter')
            moEnterMatch.setParam('userId', self.userId)
            moEnterMatch.setParam('gameId', self.gameId)
            moEnterMatch.setParam('clientId', self.clientId)
            moEnterMatch.setParam('roomId', self.roomId)
            self.writeMsg(moEnterMatch)

            moSigninMatch = MsgPack()
            moSigninMatch.setCmdAction('room', 'signin')
            moSigninMatch.setParam('userId', self.userId)
            moSigninMatch.setParam('gameId', self.gameId)
            moSigninMatch.setParam('clientId', self.clientId)
            moSigninMatch.setParam('roomId', self.roomId)
            self.writeMsg(moSigninMatch)
        elif roomTypeName in ('dizhu_custom_match', ):
            moSigninMatch = MsgPack()
            moSigninMatch.setCmdAction('custom_match', 'signin')
            moSigninMatch.setParam('userId', self.userId)
            moSigninMatch.setParam('gameId', self.gameId)
            moSigninMatch.setParam('clientId', self.clientId)
            moSigninMatch.setParam('matchId', self.matchId)
            self.writeMsg(moSigninMatch)
        else:
            self.adjustChip()
            mo = MsgPack()
            mo.setCmdAction('game', 'quick_start')
            mo.setParam('userId', self.userId)
            mo.setParam('gameId', self.gameId)
            mo.setParam('clientId', self.clientId)
            mo.setParam('roomId', self.roomId)
            mo.setParam('tableId', self.tableId)
            ctrlRoomId = gdata.roomIdDefineMap()[
                self.roomId].parentId or self.roomId
            if gdata.roomIdDefineMap()[ctrlRoomId].configure.get('isMix'):
                mixId = gdata.roomIdDefineMap()[ctrlRoomId].configure.get(
                    'mixConf')[0].get('mixId')
                mo.setParam('mixId', mixId)
            ftlog.debug('send quick Start !!!', 'userId=', self.userId,
                        'gameId=', self.gameId, 'clientId=', self.clientId,
                        'roomId=', self.roomId, 'tableId=', self.tableId,
                        'mixId=', mo.getParam('mixId', ''))
            self.writeMsg(mo)
        return
Пример #2
0
def __getRoomIdByTableId(msgpack):
    """
    部分游戏(例如德州、三顺)老版本牌桌周边功能需要使用bigRoomId,发送给GT的协议里roomId也是bigRoomId
    """
    if isinstance(msgpack, MsgPack):
        tableId = msgpack.getParam("tableId", 0)
        shadowRoomId = tableId / 10000
        msgpack.setParam("roomId", shadowRoomId)
        return msgpack, shadowRoomId
    else:
        newMsgPack = MsgPack()
        try:
            newMsgPack.unpack(msgpack)
        except:
            raise Exception('the json data error 4 !! [' + repr(msgpack) + ']')

        tableId = newMsgPack.getParam("tableId", 0)
        shadowRoomId = tableId / 10000
        newMsgPack.setParam("roomId", shadowRoomId)
        return newMsgPack, shadowRoomId
Пример #3
0
def __getRoomIdByTableId(msgpack):
    """
    部分游戏(例如德州、三顺)老版本牌桌周边功能需要使用bigRoomId,发送给GT的协议里roomId也是bigRoomId
    """
    if isinstance(msgpack, MsgPack):
        tableId = msgpack.getParam("tableId", 0)
        shadowRoomId = tableId / 10000
        msgpack.setParam("roomId", shadowRoomId)
        return msgpack, shadowRoomId
    else:
        newMsgPack = MsgPack()
        try:
            newMsgPack.unpack(msgpack)
        except:
            raise Exception('the json data error 4 !! [' + repr(msgpack) + ']')

        tableId = newMsgPack.getParam("tableId", 0)
        shadowRoomId = tableId / 10000
        newMsgPack.setParam("roomId", shadowRoomId)
        return newMsgPack, shadowRoomId
Пример #4
0
def doOldRemoteCallNew(userId, msgline):
    '''
    必须要返回dict的实例
    '''
    try:
        ftlog.debug('doOldRemoteCallNew->msgline=', msgline)

        msg = MsgPack()
        msg.unpack(msgline)
        action = msg.getAction()
        gameId = msg.getParam('gameId', -1)
        userId = msg.getParam('userId', -1)
        userBag = hallitem.itemSystem.loadUserAssets(userId).getUserBag()
        clientId = sessiondata.getClientId(userId)
        if pkgamedata.setnxGameAttr(userId, HALL_GAMEID, 'flag.item.trans', 1) == 1:
            hallitem._tranformItems(gameId, userId, clientId, userBag)

        mo = MsgPack()
        mo.setResult('action', action)
        if action == 'getUserItem':
            kindId = msg.getParam('itemId', -1)
            val = getUserItem(userId, gameId, kindId, userBag)
            mo.setResult('item', val)

        elif action == 'getUserItemList':
            result = getUserItemList(userId, gameId, userBag)
            mo.setResult('item', result)

        elif action == 'addUserItem':
            kindId = msg.getParam('itemId', -1)
            count = msg.getParam('count', -1)
            eventId = msg.getParam('eventId', -1)
            eventId = eventIdToString(eventId)
            ftlog.debug('addUserItem itemId=', kindId, 'count=', count, 'eventId=', eventId)
            val = addUserItem(userId, gameId, kindId, count, eventId, userBag)
            mo.setResult('item', val)

        elif action == 'addUserItems':
            pass
        elif action == 'consumeUserItem':
            kindId = msg.getParam('itemId', -1)
            count = msg.getParam('count', -1)
            eventId = msg.getParam('eventId', -1)
            eventId = eventIdToString(eventId)
            ftlog.debug('consumeUserItem itemId=', kindId, 'count=', count, 'eventId=', eventId)
            val = consumeUserItem(userId, gameId, kindId, count, eventId, userBag)
            mo.setResult('item', val)
        elif action == 'useUserItem':
            kindId = msg.getParam('itemId', -1)
            val = useUserItem(userId, gameId, kindId, userBag)
            mo.setResult('item', val)
        elif action == 'updateTimingUserItems':
            isDayFirst = msg.getParam('isDayFirst', False)
            val = updateTimingUserItems(userId, gameId, isDayFirst, userBag)
            mo.setResult('item', val)
        elif action == 'loadUserDecroation':
            val = loadUserDecroation(userId, gameId, userBag)
            mo.setResult('item', val)
        else:
            ftlog.error('doOldRemoteCallNew unknown rpc action action=', action, 'gameId=', gameId, 'userId=', userId)

        ftlog.debug('doOldRemoteCallNew->mo=', mo._ht)
        mo.setResult('code', 0)
        return mo._ht
    except TYItemException:
        mo = MsgPack()
        mo.setResult('code', -1)
        return mo._ht
    except:
        ftlog.error()
        mo = MsgPack()
        mo.setResult('code', -1)
        return mo._ht