コード例 #1
0
 def setup(self, interval, action, msgPackParams, cancelLastTimer=True):
     '''
     启动计时器
     interval 倒计时的时间, 单位: 秒
     action table_call命令下(params中)的action值
     msgPackParams 传递的其他的参数数据集合dict, 可以在doTableCall中的msg中使用msg.getParam(key)来取得其中的参数
     '''
     if self._fttimer and cancelLastTimer:
         self._fttimer.cancel()
     self._interval = interval
     userId = msgPackParams.get('userId', 0)
     clientId = msgPackParams.get('clientId', None)
     assert(isinstance(userId, int))
     assert(isinstance(action, (unicode, str)))
     if clientId != None:
         assert(isinstance(clientId, (unicode, str)))
     msg = MsgPack()
     msg.updateParam(msgPackParams)
     msg.setCmdAction('table_call', action)
     msg.setParam('gameId', self._table.gameId)
     msg.setParam('roomId', self._table.roomId)
     msg.setParam('tableId', self._table.tableId)
     msg.setParam('userId', userId)
     msg.setParam('clientId', clientId)
     self._fttimer = ftcore.runOnceDelay(interval, self._onTimeOut, msg)
コード例 #2
0
ファイル: exchange.py プロジェクト: zhaozw/freetime5
    def doAction(self, gameId, clientId, userAssets, item, timestamp, params):
        assert (isinstance(item, TYExchangeItem))
        if item.isDied(timestamp):
            if item.itemKind.units.isTiming():
                return items.TYItemActionResult(None, None, -30, '道具已经过期',
                                                None)
            else:
                return items.TYItemActionResult(None, None, -31, '道具数量不足',
                                                None)

        if item.state != TYExchangeItem.STATE_NORMAL:
            return items.TYItemActionResult(None, None, -32, '道具审核中', None)

        wechat_red_pack = self.isWechatRedPack()  # 微信红包,无需手机号、地址
        msg = MsgPack()
        msg.setKey('apiVersion', 5.0)
        msg.setCmdAction('exchange5', 'exchange')
        msg.updateParam(self.auditParams)
        msg.setParam(
            'phone',
            str(
                params.get('phoneNumber'
                           ) if not wechat_red_pack else '11111111111'))
        msg.setParam('uName', params.get('uName', ''))
        msg.setParam('bindPhone', params.get('bindPhone', ''))
        msg.setParam('phoneNumber', params.get('phoneNumber', ''))
        msg.setParam('uAddres', params.get('uAddres', ''))
        msg.setParam('gameId', gameId)
        msg.setParam('itemId', item.itemId)
        msg.setParam('userId', userAssets.userId)
        msg.setParam('extabName', '_item_')
        msg.setParam('clientId', clientId)
        msg.setParam('wxappid',
                     hallconf.getWeiXinAppId(userAssets.userId, clientId))
        msg.setParam('proviceId', params.get('proviceId', ''))
        msg.setParam('cityId', params.get('cityId', ''))
        msg.setParam('countyId', params.get('countyId', ''))
        msg.setParam('townId', params.get('townId', ''))
        msg.setParam('proviceName', params.get('proviceName', ''))
        msg.setParam('cityName', params.get('cityName', ''))
        msg.setParam('countyName', params.get('countyName', ''))
        msg.setParam('townName', params.get('townName', ''))

        ftlog.info('TYItemActionExchange->doAction', msg)
        exchangeId, errMsg = pluginCross.hallexchange.doExchangeRequest(
            userAssets.userId, msg)
        if not exchangeId or errMsg:
            return items.TYItemActionResult(None, None, -33, errMsg, None)

        # 兑换开始,成功,转换道具状态
        item.state = TYExchangeItem.STATE_AUDIT
        item.original = 0
        userAssets.getUserBag().updateItem(item, timestamp)

        replaceParams = {'item': item.itemKind.displayName}
        _mail, message, _changed = _action._handleMailAndMessageAndChanged(
            gameId, userAssets, self, None, replaceParams)
        # TGHall.getEventBus().publishEventent(TYItemExchangeEvent(gameId, userAssets.userId, item))
        return TYItemActionExchangeResult(self, item, message, exchangeId)
コード例 #3
0
ファイル: room_mixin.py プロジェクト: zhaozw/freetime5
 def makeTableManageReq(cls,
                        userId,
                        shadowRoomId,
                        tableId,
                        clientId,
                        action,
                        params=None):
     mpReq = MsgPack()
     mpReq.setCmd("table_manage")
     mpReq.setParam("action", action)
     mpReq.setParam("userId", userId)
     mpReq.setParam("gameId", tyconfig.getRoomGameId(shadowRoomId))
     mpReq.setParam("roomId", shadowRoomId)
     mpReq.setParam("tableId", tableId)
     mpReq.setParam("clientId", clientId)
     if params:
         mpReq.updateParam(params)
     return mpReq