Exemple #1
0
 def doStoreBuy(self, request):
     mo = MsgPack()
     mi = self.checkStoreBuy.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         clientId = tysessiondata.getClientId(mi.userId)
         orderId = ftstr.uuid()
         params = {
             'appId': tyglobal.gameId(),
             'realGameId': tyglobal.gameId(),
             'clientId': clientId,
             'userId': mi.userId,
             'prodId': mi.productId,
             'prodCount': mi.count,
             'prodOrderId': orderId,
             '_test_': 1,
         }
         url = tyglobal.httpGame(
         ) + '/api/hall5/store/consume/transaction?' + ftstr.toHttpStr(
             params)
         _, ret = fthttp.queryHttp('GET', url, None, None, 5)
         if ret != 'ok':
             mo.setError(1, ret)
         else:
             mo.setResult('ok', 1)
     return mo
Exemple #2
0
    def doStoreSuccess(self, request):
        mo = MsgPack()
        mi = self.checkStoreAction.check(request)
        if mi.error:
            mo.setError(1, mi.error)
        else:
            clientId = tysessiondata.getClientId(mi.userId)
            if mi.buyType == '1':  # 钻石
                chargedRmbs = 0
                chargedDiamonds = 0
                consumeCoin = mi.price
            else:
                chargedRmbs = mi.price
                chargedDiamonds = mi.count * mi.prodDiamond
                consumeCoin = 0

            params = {
                'userId': mi.userId,
                'appId': tyglobal.gameId(),
                'realGameId': tyglobal.gameId(),
                'clientId': clientId,
                'prodOrderId': mi.orderId,
                'prodId': mi.productId,
                'prodCount': 1,
                'chargeType': 'tester',
                'chargedRmbs': chargedRmbs,
                'chargedDiamonds': chargedDiamonds,
                'consumeCoin': consumeCoin,
                '_test_': 1,
            }
            url = tyglobal.httpGame(
            ) + '/api/hall5/store/consume/delivery?' + ftstr.toHttpStr(params)
            _, ret = fthttp.queryHttp('GET', url, None, None, 5)
            if ret != 'success':
                mo.setError(1, ret)
            else:
                mo.setResult('ok', 1)

            if chargedRmbs > 0 or chargedDiamonds > 0:
                params = {
                    'appId': tyglobal.gameId(),
                    'clientId': clientId,
                    'userId': mi.userId,
                    'realGameId': tyglobal.gameId(),
                    'prodId': mi.productId,
                    'chargedRmbs': chargedRmbs,
                    'chargedDiamonds': chargedDiamonds,
                    '_test_': 1,
                }
                url = tyglobal.httpGame(
                ) + '/api/hall5/store/consume/notify?' + ftstr.toHttpStr(
                    params)
                ret = fthttp.queryHttp('GET', url, None, None, 5)

        return mo
def createNewTable(userId_A, userId_B):
    for roomId, roomIns in tyglobal.rooms().items():
        if _DEBUG:
            debug("In createNewTable @@@@ roomId = ", roomId, " roomIns = ",
                  roomIns, " userId_A = ", userId_A, " userId_B = ", userId_B)
        global tableId
        if not roomIns.maptable:
            baseid = roomId * 10000 + 1
            tableId = baseid
        if tableId >= roomId * 10000 + 9999:
            tableId = roomId * 10000 + 1
        tableId += 1
        tblIns = TYTable(roomIns, tableId)
        roomIns.maptable[tableId] = tblIns
        table_Info = {}
        for userId in [userId_A, userId_B]:
            name, purl, sex, addr, citycode = _rpc_user_info.getUserBaseInfo(
                userId)
            table_Info[userId] = (name, purl, sex, addr, citycode)

        tblIns.playersInfo = table_Info

        time_seed = fttime.getCurrentTimestamp()

        mo = MsgPack()
        mo.setCmd('start_game')
        mo.setResult('gameId', tyglobal.gameId())
        mo.setResult('roomId', tblIns.roomId)
        mo.setResult('tableId', tblIns.tableId)
        mo.setResult('seatId', 1)
        mo.setResult('time_seed', time_seed)
        mo.setResult('table_info', table_Info)
        if _DEBUG:
            debug("OUT createNewTable  @@@ table_info = ", table_Info)
        tyrpcconn.sendToUser(userId_A, mo)

        mo = MsgPack()
        mo.setCmd('start_game')
        mo.setResult('gameId', tyglobal.gameId())
        mo.setResult('roomId', tblIns.roomId)
        mo.setResult('tableId', tblIns.tableId)
        mo.setResult('seatId', 2)
        mo.setResult('time_seed', time_seed)
        mo.setResult('table_info', table_Info)
        if _DEBUG:
            debug("OUT createNewTable  @@@ table_info = ", table_Info)
        tyrpcconn.sendToUser(userId_B, mo)
        break
Exemple #4
0
class DaoMjGameData(DataSchemaHashAttrs):
    DBNAME = 'user'
    MAINKEY = 'gamedata:%s:%s' % (tyglobal.gameId(), '%s')
    ATTS = MajangKeys

    @classmethod
    def getMainKey(cls, cIndex, _mainKeyExt=None):
        return cls.MAINKEY % (cIndex)

    @classmethod
    def checkAndInit(cls, userId):
        '''
        若数据字段小于3项,认为没有数据或丢失,重新建立数据
        '''
        if cls.HLEN(userId) < 4:
            attDataDict = {}
            ct = fttime.formatTimeMs()
            attDataDict[MajangKeys.ATT_CREATE_TIME] = ct
            attDataDict[MajangKeys.ATT_AUTHOR_TIME] = ct
            attDataDict[MajangKeys.ATT_OFFLINE_TIME] = ct
            attDataDict[MajangKeys.ATT_ALIVE_TIME] = ct
            attDataDict[MajangKeys.ATT_DATA_VERSION] = 5.1
            cls.HMSET(userId, attDataDict)
            return True
        return False
def sendLoginReward(HallPluginDay1st, userId, gameId, clientId):
    # _DB_KEY_GAME_TEMPLATE_GCSC = 'game5:%s:%s:tc'  # 各个游戏的业务模板数据,由console进行自动生成
    # confKey = _DB_KEY_GAME_TEMPLATE_GCSC % (gameId, 'loginreward')
    # conf = _config3._getCacheGameData(confKey, None, None, None)
    conf = HallPluginDay1st.configLoginreward.getTcConfig()
    debug('hall_login_reward.sendLoginReward userId:', userId, ' gameId:',
          gameId, ' clientId:', clientId, ' conf : ', conf)
    supplement = conf.get('supplement', None)
    if supplement != None:
        changed = []
        userAssets = itemsys.itemSystem.loadUserAssets(userId)
        items = supplement["items"]
        for item in items:
            maxCount = item["count"]
            itemId = item["itemId"]
            balance = userAssets.balance(itemId, fttime.getCurrentTimestamp())
            if (maxCount - balance) > 0:

                assetKind, _addCount, _final = userAssets.addAsset(
                    gameId, itemId, maxCount - balance,
                    fttime.getCurrentTimestamp(), 'LOGIN_REWARD', 0)
                if assetKind.keyForChangeNotify:
                    changed.append(assetKind.keyForChangeNotify)

        pluginCross.halldatanotify.sendDataChangeNotify(
            userId, tyglobal.gameId(), changed)
Exemple #6
0
    def endCLientGame(self, msg):
        if _DEBUG:
            debug("In synClientInfo @@@ msg = ", msg)
        mi = self.checker1.check(msg)
        if mi.error:
            ftlog.error('endCLientGame the msg params error !', mi.error)
        else:
            #todo 1: add loc 2:客户端上行的第一条end_game消息作为判断依据,对双方结算
            room = tyglobal.rooms()[mi.roomId]
            if room.maptable.has_key(mi.tableId):
                table = room.maptable.pop(mi.tableId)
                for userid in table.playersInfo.keys():
                    mo = MsgPack()
                    mo.setCmd('end_game')
                    mo.setResult('result', 'ok')
                    mo.setResult('gameResult', msg.getParamStr('gameResult'))
                    if _DEBUG:
                        debug("OUT endCLientGame  @@@ table_info = ", msg)
                    tyrpcconn.sendToUser(userid, mo)

                rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE)
                rpcproxy.srvgame.doReportGameResult(msg.getParamStr('gameResult'), tyglobal.gameId())
            else:
                pass
                # mo = MsgPack()
                # mo.setCmd('end_game')
                # mo.setResult('result', 'has finished')
                # mo.setResult('msg', msg)
                # if _DEBUG:
                #     debug("OUT endCLientGame  @@@ table_info = ", msg)
                # tyrpcconn.sendToUser(mi.userid, mo)
        return 1
Exemple #7
0
 def decodeFromDict(self, d):
     super(TYItemActionConditionCanOpenFlag, self).decodeFromDict(d)
     self.gameId = self.params.get('gameId', tyglobal.gameId())
     if not isinstance(self.gameId, int) or self.gameId <= 0:
         raise TYBizConfException(
             self.params,
             'TYItemActionConditionCanOpenFlag.params.gameId must = 0')
     return self
Exemple #8
0
 def _onTaskFinished(self, userTask, timestamp):
     pluginSafeCross.hallredpoint.setItemUnRead(
         userTask.userTaskUnit.userId, 'happybag5', [userTask.taskId])
     userId = userTask.userTaskUnit.userId
     clientId = tysessiondata.getClientIdInt(userId)
     tybireport.reportGameSimpleEvent('HAPPY_BAG_TASK', userId,
                                      tyglobal.gameId(), clientId,
                                      userTask.taskId, userTask.kindId,
                                      userTask.status)
Exemple #9
0
def doGameTimestemp(userId):
    if _DEBUG:
        debug('doGameTimestemp->', userId)
    mo = MsgPack()
    mo.setCmd('user')
    mo.setResult('action', 'mj_timestamp')
    mo.setResult('gameId', tyglobal.gameId())
    mo.setResult('userId', userId)
    mo.setResult('current_ts', fttime.getCurrentTimestamp())
    tyrpcconn.sendToUser(userId, mo)
Exemple #10
0
def doGameLeave(userId, clientId):
    if _DEBUG:
        debug('doGameLeave->', userId, clientId)
    mo = MsgPack()
    mo.setCmd('game')
    mo.setResult('action', 'leave')
    mo.setResult('gameId', tyglobal.gameId())
    mo.setResult('userId', userId)
    mo.setResult('ok', 1)
    tyrpcconn.sendToUser(userId, mo)
Exemple #11
0
    def _onTimeout(self, lostUserId):
        if _DEBUG:
            debug("In MiniMatchProcess @@@@ onTimeOut, lostUserId = ",
                  lostUserId)

        room = tyglobal.rooms()[self._roomId]
        if room.maptable.has_key(self.tableId):
            table = room.maptable.pop(self.tableId)
            self.table_msgId = table.tableMsgId

        if lostUserId == self.userId_a:
            self.winnerId = self.userId_b

            mo = MsgPack()
            mo.setCmd('end_game')
            mo.setResult('winnerId', self.winnerId)
            mo.setResult('userId_a', self.userId_a)
            mo.setResult('userId_b', self.userId_b)
            mo.setResult('table_msgId', self.table_msgId)

            if _DEBUG:
                debug("OUT end_game  @@@ winnerId = ", self.winnerId)
            tyrpcconn.sendToUser(self.winnerId, mo)

            rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE)
            rpcproxy.srvgame.doReportGameResult(mo, tyglobal.gameId())

        else:
            self.winnerId = self.userId_a

            mo = MsgPack()
            mo.setCmd('end_game')
            mo.setResult('winnerId', self.winnerId)
            mo.setResult('userId_a', self.userId_a)
            mo.setResult('userId_b', self.userId_b)
            mo.setResult('table_msgId', self.table_msgId)
            if _DEBUG:
                debug("OUT end_game  @@@ self.winnerId = ", self.winnerId)
            tyrpcconn.sendToUser(self.winnerId, mo)

            rpcproxy = getRpcProxy(9993, RPC_CALL_SAFE, RPC_TARGET_MOD_ONE)
            rpcproxy.srvgame.doReportGameResult(mo, tyglobal.gameId())
Exemple #12
0
    def _conform(self, gameId, userId, clientId, item, timestamp, params):

        flagName = 'item.open.flag:%s' % (item.kindId)
        if gameId == tyglobal.gameId():
            value = pluginCross.halldata.getHallDataList(userId, flagName)
        else:
            value = _getSubGameDataVal(gameId, userId, flagName)

        if ftstr.parseInts(value) == 1:
            return True
        return False
Exemple #13
0
class Daohall5share2(tydao.DataSchemaHashAttrs):
    """
    用户自定义hall5share2的存储实现.
    MAINKEY,数据键值
    user,决定数据存储的库
    """
    MAINKEY = 'share2.status:{}:%s'.format(tyglobal.gameId())
    DBNAME = 'user'

    @classmethod
    def getMainKey(cls, cIndex, mainKeyExt=None):
        return cls.MAINKEY
Exemple #14
0
    def do_consume_chip(self, request):
        if _DEBUG:
            ftlog.info("_PopStarHttp : do_consume_chip : request = ", request)
        userId = int(request.getParamStr('userId'))
        dec_chip = abs(int(request.getParamStr('chipNum')))

        #dec user chip
        hallRpcOne.halldata.incrChip(userId, tyglobal.gameId(), -dec_chip,
                                     ChipNotEnoughOpMode.NOOP,
                                     'POPSTAR_GAME_CONSUME_CHIP', 0)

        return {request.path: 'ok'}
Exemple #15
0
    def doUserAccountUpgrade(self, request):
        '''
        SDK 通知玩家绑定了手机或绑定微信等第三方账号
        成功返回: success
        '''
        ftlog.info('doUserAccountUpgrade IN->', request.getDict())
        mi = self.checkAccountUp.check(request)
        if mi.error:
            ret = 'error,' + str(mi.error)
        else:
            event = None
            if mi.bindType == 'wx':
                event = tygame.AccountBindWeiXinEvent(mi.userId,
                                                      tyglobal.gameId())
            elif mi.bindType == 'mobile':
                event = tygame.AccountBindPhoneEvent(mi.userId,
                                                     tyglobal.gameId())

            if event:
                tyrpchall.sendEventToHallHU(event)

            ret = 'success'
        ftlog.info('doUserAccountUpgrade OUT->', ret)
        return ret
Exemple #16
0
    def doStoreCancel(self, request):
        mo = MsgPack()
        mi = self.checkStoreActionTerm.check(request)
        if mi.error:
            mo.setError(1, mi.error)
        else:
            params = {
                'userId': mi.userId,
                'appId': tyglobal.gameId(),
                'realGameId': tyglobal.gameId(),
                'errinfo': 'test error',
                'prodOrderId': mi.orderId,
                'prodId': mi.productId,
                '_test_': 1,
            }
            url = tyglobal.httpGame(
            ) + '/api/hall5/store/pay/cancel?' + ftstr.toHttpStr(params)
            _, ret = fthttp.queryHttp('GET', url, None, None, 5)
            if ret != 'success':
                mo.setError(1, ret)
            else:
                mo.setResult('ok', 1)

        return mo
Exemple #17
0
def doGameEnter(userId, clientId):
    if _DEBUG:
        debug('doGameEnter->', userId, clientId)
    gameId = tyglobal.gameId()
    isNewUser = pluginCross.mj2dao.createGameData(userId, clientId, gameId)
    # 确认是否是今日第一次登录
    isdayfirst = False
    datas = pluginCross.mj2weakdata.getDay1stDatas(userId)
    if 'daylogin' not in datas:
        isdayfirst = True
        datas['daylogin'] = 1
        datas['iscreate'] = 1
    else:
        datas['daylogin'] += 1
        datas['iscreate'] = 0
    pluginCross.mj2weakdata.setDay1stDatas(userId, datas)

    # 游戏登录次数加1,每次bind_user都会加1,包括断线重连
    loginsum = pluginCross.mj2dao.loginGame(userId, gameId, clientId,
                                            isNewUser, isdayfirst)
    if _DEBUG:
        debug('doGameEnter->userId=', userId, 'isNewUser='******'loginsum=', loginsum, 'isdayfirst=', isdayfirst)

    gdata = pluginCross.mj2dao.getGameInfo(userId, clientId, tyglobal.gameId())
    mo = MsgPack()
    mo.setCmd('game_data')
    mo.setResult('gameId', gameId)
    mo.setResult('userId', userId)
    mo.setResult('gdata', gdata)
    tyrpcconn.sendToUser(userId, mo)

    # BI日志统计
    tybireport.userGameEnter(tyglobal.gameId(), userId, clientId)
    tybireport.reportGameEvent('BIND_GAME', userId, gameId, 0, 0, 0, 0, 0, 0,
                               [], clientId, isNewUser)
Exemple #18
0
def _sendTaskReward(userId, task, clientId, timestamp, **kwargs):
    assetList = []
    content = task.taskKind.rewardContent
    if content:
        if isinstance(content, tycontent.TYChoiceContent):
            itemId = kwargs['itemId']
            itemList = content.getItems(itemId)
            if not itemList:
                raise Exception(
                    'the param itemId = [%s] error ! userId=%s  taskId=%s kwargs=%s'
                    % (itemId, userId, task.taskId, str(kwargs)))
        else:
            itemList = content.getItems()
        assetList = pluginCross.hallitem.sendContentItemList(
            tyglobal.gameId(), userId, itemList, 1, True, timestamp,
            'HAPPY_BAG_TASK', task.kindId)
        tybireport.reportGameSimpleEvent('HAPPY_BAG_TASK', userId,
                                         tyglobal.gameId(), clientId,
                                         task.taskId, task.kindId, task.status)
    if not assetList:
        raise Exception(
            'sendContentItemList return empty list error ! userId=%s taskId=%s kwargs=%s'
            % (userId, task.taskId, str(kwargs)))
    return assetList
Exemple #19
0
def reloadConfig():
    if _DEBUG:
        debug('hallexchange.reloadConfig in')
    mainconf = TyCachedConfig('exchange', tyglobal.gameId())
    extabs = mainconf.getScConfig().get('extabs', {})
    if _DEBUG:
        debug('hallexchange.reloadConfig mainconf=', mainconf)
    names = set()
    for _, tab in extabs.iteritems():
        names.add(tab['name'])
    subconfs = {}
    product_map = {}
    for name in names:
        subconfs[name] = TyCachedConfig('exchange:%s' % (name), tyglobal.gameId())

        #add product_map info added by lixi
        if subconfs[name]:
            confs = subconfs[name].getScConfig().get('exitems', {})
            for key, conf in confs.items():
                if key:
                    product_map[key] = confs[key]['productId']
                    if _DEBUG:
                        debug('hallexchange _private _conf reloadConfig %s', conf)
                else:
                    if _DEBUG:
                        debug('hallexchange _private _conf reloadConfig %s', conf)
    
    global MAINCONF, SUBCONFS, PRODUCT_MAP
    MAINCONF = mainconf
    SUBCONFS = subconfs
    PRODUCT_MAP = product_map
    # 清理缓存
    getExchangeQueryUiTabs.clear()
    _getExchangeQueryUiItems.clear()
    if _DEBUG:
        debug('hallexchange.reloadConfig out')
Exemple #20
0
 def doClientHallInfo(self, msg):
     '''
     老版本兼容 获取大厅列表信息
     '''
     if _DEBUG:
         debug('doClientHallInfo->', msg)
     mi = self.checker.check(msg)
     if mi.error:
         ftlog.error('doClientHallInfo the msg params error !', mi.error)
     else:
         mo = MsgPack()
         mo.setCmd('hall_info')
         mo.setResult('gameId', tyglobal.gameId())
         mo.setResult('userId', mi.userId)
         mo.setResult('sessions', None)
         tyrpcconn.sendToUser(mi.userId, mo)
     return 1
Exemple #21
0
def _updateBiggestHallVersion(userId, gameId, clientId):
    '''
        记录更新该用户最高的版本号
        '''
    if gameId != tyglobal.gameId():
        return
    clientId_str = tyconfig.numberToClientId(clientId)
    _, clientVer, _ = tyconfig.parseClientId(clientId_str)
    if not clientVer:
        return
    bVer = 1.0
    biggestClientIdStr = pluginCross.halldata.getBiggestHallVersion(userId)
    if biggestClientIdStr:
        bVer = float(biggestClientIdStr)

    if clientVer > bVer:
        pluginCross.halldata.setBiggestHallVersion(userId, str(clientVer))
        ftlog.debug('update user biggest hallVersion:', clientVer)
Exemple #22
0
 def doExchangeExchange(self, request):
     mo = MsgPack()
     mi = self.checkExchange.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         clientId = tysessiondata.getClientId(mi.userId)
         msg = MsgPack()
         msg.setKey('apiVersion', 5.0)
         msg.setCmdAction('exchange5', 'exchange')
         msg.setParam('phone', request.getParamStr('phone'))
         msg.setParam('uName', request.getParamStr('uName'))
         msg.setParam('uAddres', request.getParamStr('uAddres'))
         msg.setParam('gameId', tyglobal.gameId())
         msg.setParam('itemId', mi.itemId)
         msg.setParam('userId', mi.userId)
         msg.setParam('extabName', request.getParamStr('extabName'))
         msg.setParam('clientId', clientId)
         msg.setParam('wxappid',
                      hallconf.getWeiXinAppId(mi.userId, clientId))
         msg.setParam('proviceId', request.getParamStr('proviceId'))
         msg.setParam('cityId', request.getParamStr('cityId'))
         msg.setParam('countyId', request.getParamStr('countyId'))
         msg.setParam('townId', request.getParamStr('townId'))
         msg.setParam('proviceName', request.getParamStr('proviceName'))
         msg.setParam('cityName', request.getParamStr('cityName'))
         msg.setParam('countyName', request.getParamStr('countyName'))
         msg.setParam('townName', request.getParamStr('townName'))
         msg = msg.getDict()
         try:
             ret = hallRpcOne.hallexchange.doExchangeRequest(mi.userId, msg)
             datas = ret.getResult()
             if datas:
                 exchangeId, errMsg = datas[0], datas[1]
                 if exchangeId:
                     mo.setResult('exchangeId', exchangeId)
                     mo.setResult('info', errMsg)
                 else:
                     mo.setError(1, errMsg)
             else:
                 mo.setError(1, 'doExchangeRequest return is None')
         except Exception, e:
             mo.setError(1, str(e))
Exemple #23
0
    def _checkUserTasksWhenLoad(self, userId, userTaskUnit, clientId):
        '''
        当用户的任务列表加载后,进行任务列表的整体检查,
        判定是否要进行任务的发放、删除或整理
        '''
        if _DEBUG:
            debug(
                'HallPluginTaskHappyBag->_checkUserTasksWhenLoad IN clientId=',
                clientId, 'userId=', userId, 'userTaskUnit=', userTaskUnit)

        if userTaskUnit is None or len(userTaskUnit.taskIdMap) == 0:
            if clientId:
                # 没有任何任务,重新分配, 只有当有客户端消息触发时才进行分配,事件触发不进行分配,避免检查过多
                taskUnitId = tyconfig.getCacheTemplateName(
                    'task_happybag', clientId, tyglobal.gameId())
                if _DEBUG:
                    debug(
                        'HallPluginTaskHappyBag->_checkUserTasksWhenLoad clientId=',
                        clientId, 'userId=', userId, 'taskUnitId=', taskUnitId,
                        self.taskUnits.keys())
                taskUnit = self.taskUnits.get(taskUnitId)
                if taskUnit:
                    # 分配最初的任务列表
                    userTaskUnit = _taskunits._initUserFirstTaskList(
                        userId, taskUnit)
                    # 清理缓存,下次在调用时,重新装载,使用缓存
                    self.removeUserTaskUnitCache(userId)
                else:
                    # 如果未配置对应clientId的任务列表,则不分配任务
                    pass
        else:
            # 检查任务的新增情况,注:删除功能已在 loadUserTaskUnit 中删除
            _taskunits._checkIfNeedAddNewTask(userTaskUnit)

        # 检查任务关联状态, 补充检查,避免事件丢失或异常而导致状态不能转换
        _taskunits._checkAllTaskStatus(userTaskUnit)

        if _DEBUG:
            debug(
                'HallPluginTaskHappyBag->_checkUserTasksWhenLoad OUT clientId=',
                clientId, 'userId=', userId, 'userTaskUnit=', userTaskUnit)

        return userTaskUnit
Exemple #24
0
class HallPluginTodoTask(TyPluginTodoTask):
    def __init__(self):
        super(HallPluginTodoTask, self).__init__()

    def destoryPlugin(self):
        super(HallPluginTodoTask, self).destoryPlugin()

    @typlugin.markPluginEntry(initBeforeConfig=[
        tyglobal.SRV_TYPE_HALL_UTIL, tyglobal.SRV_TYPE_HALL_SINGLETON
    ])
    def initPluginBefore(self):
        super(HallPluginTodoTask, self).initPluginBefore()

    @typlugin.markPluginEntry(
        confKeys=['game5:{}:todotask:tc'.format(tyglobal.gameId())],
        srvType=[
            tyglobal.SRV_TYPE_HALL_UTIL, tyglobal.SRV_TYPE_HALL_SINGLETON
        ])
    def onConfChanged(self, confKeys, changedKeys):
        super(HallPluginTodoTask, self).onConfChanged(confKeys, changedKeys)

    @typlugin.markPluginEntry(export=1)
    def sendTodoTaskStartChip(self, gameId, userId, startChip, totalChip, pic,
                              tip):
        '''
        发送启动资金的弹窗
        '''
        t = self.baseUnit.TodoTaskIssueStartChip(startChip, totalChip, pic,
                                                 tip)
        self.sendTodoTask(gameId, userId, t)
        return 1

    @typlugin.markPluginEntry(export=1)
    def sendNoticeLoginPopWnd(self, gameId, userId, noticeid):
        '''
        发送用户登录时的弹窗
        '''
        t = self.baseUnit.TodoTaskNoticeLoginPopWnd(noticeid)
        self.sendTodoTask(gameId, userId, t)
        return 1
Exemple #25
0
def saveUtilMatchInfo(userId_A, userId_B):
    global match_count
    match_count += 1
    util_match_map[match_count] = {userId_A: 0, userId_B: 0}

    mo = MsgPack()
    mo.setCmd('bind_game')
    mo.setResult('gameId', tyglobal.gameId())
    mo.setResult('match_count', match_count)

    time_seed = fttime.getCurrentTimestamp()
    mo.setResult('time_seed', time_seed)

    table_Info = {}
    for userId in [userId_A, userId_B]:
        name, purl, sex, addr, citycode = _rpc_user_info.getUserBaseInfo(userId)
        table_Info[userId] = (name, purl, sex, addr, citycode)

    mo.setResult('table_info', table_Info)

    tyrpcconn.sendToUser(userId_A, mo)
    tyrpcconn.sendToUser(userId_B, mo)
Exemple #26
0
 def doAudit(self, request, result):
     mo = MsgPack()
     mi = self.checkExchange.check(request)
     if mi.error:
         mo.setError(1, mi.error)
     else:
         params = {
             'userId': mi.userId,
             'result': result,
             'realGameId': tyglobal.gameId(),
             'exchangeId': mi.exchangeId,
             'extOrderId': 'dummy_jd_num_audit',
             '_test_': 1,
         }
         url = tyglobal.httpGame(
         ) + '/api/hall5/exchange/auditCallback?' + ftstr.toHttpStr(params)
         _, ret = fthttp.queryHttp('GET', url, None, None, 5)
         if ret and ret[0] == '{':
             mo.updateResult(ftstr.loads(ret))
         else:
             mo.setError(1, ret)
     return mo
Exemple #27
0
class HallPluginCondition(TyPluginCondition):
    def destoryPlugin(self):
        super(HallPluginCondition, self).destoryPlugin()
        from hall5.plugins.condition import _userconditions
        self.unRegisterConditionModule(_userconditions)
        from hall5.plugins.condition import _storeconditions
        self.unRegisterConditionModule(_storeconditions)
        from hall5.plugins.condition import _itemconditions
        self.unRegisterConditionModule(_itemconditions)

    @typlugin.markPluginEntry(initBeforeConfig=[tyglobal.SRV_TYPE_HALL_UTIL])
    def initPluginBefore(self):
        super(HallPluginCondition, self).initPluginBefore()
        from hall5.plugins.condition import _userconditions
        self.registerConditionModule(_userconditions, True)
        from hall5.plugins.condition import _storeconditions
        self.registerConditionModule(_storeconditions, True)
        from hall5.plugins.condition import _itemconditions
        self.registerConditionModule(_itemconditions, True)

    @typlugin.markPluginEntry(
        initBeforeConfig=[tyglobal.SRV_TYPE_HALL_SINGLETON])
    def initSingletonPluginBefore(self):
        super(HallPluginCondition, self).initPluginBefore()

    @typlugin.markPluginEntry(
        confKeys=['game5:{}:condition:tc'.format(tyglobal.gameId())],
        srvType=[
            tyglobal.SRV_TYPE_HALL_UTIL, tyglobal.SRV_TYPE_HALL_SINGLETON
        ])
    def onConfChanged(self, confKeys, changedKeys):
        super(HallPluginCondition, self).onConfChanged(confKeys, changedKeys)

    @typlugin.markPluginEntry(rpc=tyglobal.SRV_TYPE_HALL_UTIL)
    def remoteCheckCondition(self, userId, gameId, intClientId, conditionId,
                             kwargs):
        kwargs['__rpc'] = True  # 死循环保护
        return self.checkCondition(gameId, userId, intClientId, conditionId,
                                   **kwargs)
Exemple #28
0
def check__sdkSignCode(request, result, name):
    if tyglobal.enableTestHtml() and '_test_' in request.args:
        return 0, None

    public_conf = tyconfig.getCacheGameTcData('public', tyglobal.gameId())
    appKey = public_conf.get('appkeys', '')

    args = request.args
    rparam = {}
    for k, v in args.iteritems():
        rparam[k] = v[0]
    code = rparam.pop('code')

    sk = rparam.keys()
    sk.sort()
    ret = ""
    for k in sk:
        ret = ret + str(k) + '=' + str(rparam[k]) + '&'
    signStr = ret[:-1]

    md5code = ftstr.md5digest(str(appKey) + signStr + str(appKey))
    if md5code == code:
        return 1, None
    return None, 'check_sdkSignCode error !'
Exemple #29
0
class DaoMjTableRecordData(DataSchemaString):

    DBNAME = 'replay'
    MAINKEY = 'dummy-DaoMjTableRecordData'
    RECORDKEY = '{}:gamedata:record:replay:%s%s'.format(tyglobal.gameId())
    SUBVALDEF = DataAttrObjDict('dummy-DaoMjTableRecordData', {}, 512)

    @classmethod
    def getMainKey(cls, cIndex, _mainKeyExt=None):
        return cIndex

    @classmethod
    def setReplayRecord(cls, userId, playerRecordInfo):
        recordContentKey = cls.RECORDKEY % (userId, int(time.time()))
        cls.SET(recordContentKey, recordContentKey, playerRecordInfo)
        return recordContentKey

    @classmethod
    def getReplayRecord(cls, recordContentKey):
        return cls.GET(recordContentKey)

    @classmethod
    def removeReplayRecord(cls, recordContentKey):
        return cls.DEL(recordContentKey)
Exemple #30
0
class DaoUserItem(tydao.DataSchemaHashSameKeys):
    DBNAME = 'user'
    MAINKEY = 'item2:{}:%s'.format(tyglobal.gameId())
    SUBVALDEF = tydao.DataAttrBinary('item', '', 64)  # 实际目前长度只有30左右
    MAX_DATA_LENGTH = 0  # 这个不好办了,道具会越来越多,最多会存多少种道具?