def _getThirdPartyUserInfo(userId): ''' 取得用户的基本账户的信息 玩家昵称 玩家id 钻石数量 金币数量 奖券数量 魅力值 vip等级 ''' userdata.checkUserData(userId) ukeys = [ UserDataSchema.NAME, UserDataSchema.SEX, UserDataSchema.DIAMOND, UserDataSchema.CHIP, UserDataSchema.COUPON, UserDataSchema.CHARM, UserDataSchema.PURL, UserDataSchema.CREATETIME ] udataDb = userdata.getAttrs(userId, ukeys) udata = dict(zip(ukeys, udataDb)) # vip信息 udata['vipInfo'] = hallvip.userVipSystem.getVipInfo(userId) # 游戏信息 clientId = sessiondata.getClientId(userId) gameInfo = hallaccount.getGameInfo(userId, clientId) udata['gameInfo'] = gameInfo.get('dashifen', {}) return udata
def doPromoteCodeCheck(cls, gameId, userId, clientId, action, promoteCode): ''' 验证兑换码ID,有效则获取用户手机绑定信息,若绑定手机,则发送奖励,并更新用户状态。若未绑定手机,则更新用户状态,返回未绑定手机code ''' conf = hallconf.getNeiTuiGuangConf(clientId) if not conf: ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'action=', action) return mo = MsgPack() userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state) if userstate == 2: NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '已经领奖成功', mo) else: promoteCode = cls.intPromoteCode(promoteCode) if promoteCode == -1 or userId == promoteCode: NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo) else: userdata.checkUserData(promoteCode) createTime = userdata.getAttr(promoteCode, 'createTime') if createTime == None: NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo) else: olduser = cls.isOldUser(promoteCode, gameId, createTime, conf) if not olduser: NeiTuiGuangProtocolBuilder.buildBasicInfo(1, action, cls.getprize(gameId, 1, conf), mo) else: gamedata.setGameAttr(userId, gameId, cls.attrname_promotecode, promoteCode) # 记录兑换码 gamedata.setGameAttr(userId, gameId, cls.attrname_state, 1) # 已输入兑换码 bindmobile = userdata.getAttr(userId, 'bindMobile') if cls.bindOk(bindmobile): NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '验证成功', mo) else: NeiTuiGuangProtocolBuilder.buildBasicInfo(2, action, cls.getprize(gameId, 2, conf), mo) return mo
def loginByInvited(userId, shareUserId, isNewPlayer): """ :param userId: 被邀请人 :param shareUserId: 分享者(邀请人) :param isNewPlayer: 是否为新用户 """ isCanInvite = config.getCommonValueByKey("canInvite") isInvite = weakdata.getDayFishData(userId, "isInvited", 0) if not isCanInvite or isInvite: return False userdata.checkUserData(shareUserId) if isNewPlayer: from newfish.game import TGFish from newfish.entity.event import AddInvitedNewUserEvent # 存储邀请人信息 from hall.entity import hallvip from newfish.entity.redis_keys import GameData shareUserVip = int(hallvip.userVipSystem.getUserVip(shareUserId).vipLevel.level) inviterInfo = { "userId": shareUserId, "inviteTime": int(time.time()), "vip": shareUserVip } gamedata.setGameAttr(userId, FISH_GAMEID, GameData.inviterInfo, json.dumps(inviterInfo)) saveKey = "inviteNewPlayers" actionType = NewPlayerAction event = AddInvitedNewUserEvent(shareUserId, FISH_GAMEID, userId) TGFish.getEventBus().publishEvent(event) else: saveKey = "recallPlayers" actionType = RecallPlayerAction user_rpc.addInviteNum(shareUserId, userId, actionType, saveKey, isNewPlayer) return True
def _getThirdPartyUserInfo(userId): ''' 取得用户的基本账户的信息 玩家昵称 玩家id 钻石数量 金币数量 奖券数量 魅力值 vip等级 ''' userdata.checkUserData(userId) ukeys = [UserDataSchema.NAME, UserDataSchema.SEX, UserDataSchema.DIAMOND, UserDataSchema.CHIP, UserDataSchema.COUPON, UserDataSchema.CHARM, UserDataSchema.PURL, UserDataSchema.CREATETIME] udataDb = userdata.getAttrs(userId, ukeys) udata = dict(zip(ukeys, udataDb)) # vip信息 udata['vipInfo'] = hallvip.userVipSystem.getVipInfo(userId) # 游戏信息 clientId = sessiondata.getClientId(userId) gameInfo = hallaccount.getGameInfo(userId, clientId) udata['gameInfo'] = gameInfo.get('dashifen', {}) return udata
def friendInfo(cls, friend, prize, index, clientId): userdata.checkUserData(friend["userId"]) coupon = 0 if (index + 1) % 5 == 0: coupon = prize["COUPON"] result = { "prizeInfo": { "prize": [{ "name": "CHIP", "count": prize["CHIP"] }, { "name": "COUPON", "count": coupon }], "state": friend["state"] } } uds = userdata.getAttrs(friend["userId"], ['purl', 'name', 'chip']) friendInfo = { "userId": friend["userId"], "headUrl": uds[0], "name": uds[1], "chip": uds[2], "dashifen": cls.getDaShiFenPic(friend["userId"], clientId) } result['friendInfo'] = friendInfo return result
def addMember(userId): try: userdata.checkUserData(userId) except: ftlog.error('unsubmember_add.addMember NotFoundUser userId=', userId) return subStatus = hallsubmember.loadSubMemberStatus(userId) if not subStatus.isSub: ftlog.info('unsubmember_add.addMember NotSub userId=', userId, 'subDT=', subStatus.subDT, 'deliveryDT=', subStatus.deliveryDT, 'expiresDT=', subStatus.expiresDT) return if not subStatus.expiresDT: ftlog.info('unsubmember_add.addMember NotExpiresDT userId=', userId, 'subDT=', subStatus.subDT, 'deliveryDT=', subStatus.deliveryDT, 'expiresDT=', subStatus.expiresDT) return timestamp = pktimestamp.getCurrentTimestamp() # 检查用户是否是会员,如果不是会员则补偿用户 userAssets = hallitem.itemSystem.loadUserAssets(userId) balance = userAssets.balance(HALL_GAMEID, hallitem.ASSET_ITEM_MEMBER_NEW_KIND_ID, timestamp) if balance > 0: ftlog.info('unsubmember_add.addMember HaveMemberCard userId=', userId, 'subDT=', subStatus.subDT, 'deliveryDT=', subStatus.deliveryDT, 'expiresDT=', subStatus.expiresDT, 'balance=', balance) return nowDT = datetime.fromtimestamp(timestamp) expiresDT = SubMemberStatus.calcSubExpiresDT(nowDT, nowDT) nDays = (expiresDT.date() - nowDT.date()).days if nDays > 0: # 计算需要补偿30天 _, count, final = userAssets.addAsset( HALL_GAMEID, hallitem.ASSET_ITEM_MEMBER_NEW_KIND_ID, nDays, timestamp, 'GM_ADJUST', 0) ftlog.info('unsubmember_add.addMember OK userId=', userId, 'subDT=', subStatus.subDT, 'oldDeliveryDT=', subStatus.deliveryDT, 'oldExpiresDT=', subStatus.expiresDT, 'deliveryDT=', nowDT, 'balance=', balance, 'nDays=', nDays, 'count=', count, 'final=', final) else: ftlog.info('unsubmember_add.addMember EmptyNdays userId=', userId, 'subDT=', subStatus.subDT, 'oldDeliveryDT=', subStatus.deliveryDT, 'oldExpiresDT=', subStatus.expiresDT, 'deliveryDT=', nowDT, 'balance=', balance, 'nDays=', nDays, 'count=', count, 'final=', final) subStatus.expiresDT = expiresDT subStatus.deliveryDT = nowDT subStatus.subDT = nowDT hallsubmember._saveSubMemberStatus(userId, subStatus)
def getRankRewardList(self, userId): ''' 获取奖励排行榜 ''' ret = [] for rankReward in self.rankRewards: nickname, purl, count = '', '', 0 startRankUserIdList = getRankList( self.actId, calculateCurrentIssue(self.settleDayOrWeek), rankReward.startRank - 1, rankReward.startRank - 1) if startRankUserIdList: startRankUserId = startRankUserIdList[0] userdata.checkUserData(startRankUserId) nickname, purl = userdata.getAttrs(startRankUserId, ['name', 'purl']) issue = calculateCurrentIssue(self.settleDayOrWeek) userData = UserShareCharmData(startRankUserId).loadUserData( self.actId) issueData = userData.getIssueData(issue) count = issueData.count if issueData else 0 ret.append({ 'startRank': rankReward.startRank, 'endRank': rankReward.endRank, 'rewardDesc': rankReward.rewardDesc, 'rewardPic': rankReward.rewardPic, 'userInfo': { 'name': nickname, 'purl': purl, 'count': count } }) currentIssue = calculateCurrentIssue(self.settleDayOrWeek) lastIssue = calculateLastIssue(self.settleDayOrWeek) rank = getUserRealRank(userId, self.actId, currentIssue) count = UserShareCharmData(userId).loadUserData( self.actId).getCharmCount(currentIssue) lastRank = getUserRealRank(userId, self.actId, lastIssue) lastCount = UserShareCharmData(userId).loadUserData( self.actId).getCharmCount(lastIssue) retRes = { 'userInfo': { 'rank': rank, 'count': count, 'lastRank': lastRank, 'lastCount': lastCount }, 'rankList': ret, 'startDate': calculateCurrentIssue(self.settleDayOrWeek), 'endDate': calculateEndDayStr(self.settleDayOrWeek) } if ftlog.is_debug(): ftlog.debug('ActivityWxShareCharm.getRankRewardList', 'retRes=', retRes) return retRes
def do_xq_update_old_user(uid, snsId, chessExp, totalNum, winNum, loseNum, drawNum): ret = userdata.checkUserData(uid, PCCLIENTID, 3) ftlog.info('PCXQ_USER load already user data !', uid, snsId, 'ret=', ret) chessExpOld, chessRecordOld = gamedata.getGameAttrs(uid, 3, ['chessExp', 'chessRecord'], False) creat = 0 if chessExpOld == None or chessRecordOld == None : creat = 1 else: try: chessExpOld = int(chessExpOld) except: creat = 1 try: chessRecordOld = json.loads(chessRecordOld) totalNum = totalNum + int(chessRecordOld.get('totalNum')) winNum = winNum + int(chessRecordOld.get('winNum')) loseNum = loseNum + int(chessRecordOld.get('loseNum')) drawNum = drawNum + int(chessRecordOld.get('drawNum')) except: creat = 1 if creat : ftlog.info('PCXQ_USER creat old user XQ gamedata !', uid, snsId, 'chessExpOld=', chessExpOld, 'chessRecordOld=', chessRecordOld) creat_gamedata(uid, chessExp, totalNum, winNum, loseNum, drawNum) else: ftlog.info('PCXQ_USER update old user XQ gamedata !', uid, snsId, 'chessExpOld=', chessExpOld, 'chessRecordOld=', chessRecordOld) chessExp = max(chessExpOld, chessExp) chessRecordOld['totalNum'] = totalNum chessRecordOld['winNum'] = winNum chessRecordOld['loseNum'] = loseNum chessRecordOld['drawNum'] = drawNum gamedata.setGameAttrs(uid, 3, ['chessExp', 'chessRecord'], [chessExp, json.dumps(chessRecordOld)])
def getHelpMsg(cls, helpUserId): ''' 助力信息 ''' seconds = _treasureChestTotalConf.treasureChest.helpShortenSeconds userdata.checkUserData(helpUserId) name, _ = userdata.getAttrs(helpUserId, ['name', 'purl']) if seconds < 60: helpMsg = '感谢您帮助【%s】减少%s秒的开宝箱时间~' % (name, seconds) else: minutes = seconds / 60 leftSecond = seconds % 60 if leftSecond == 0: helpMsg = '感谢您帮助【%s】减少%s分钟的开宝箱时间~' % (name, minutes) else: helpMsg = '感谢您帮助【%s】减少%s分钟%s秒的开宝箱时间~' % (name, minutes, leftSecond) return helpMsg
def _saveUserToRedis(userId, status, behaviourConf): if not userdata.checkUserData(userId): return False if not _checkExpectedUser(userId, behaviourConf): return False todayDate = int(dizhu_util.calcTodayIssueNum()) behaviourInfo = {'type': BEHAVIOUR_TYPE_NONE, 'date': todayDate} try: ret = daobase.executeUserCmd(userId, 'HGET', 'userBehaviour:6:' + str(userId), 'info') if ret: ret = strutil.loads(ret) behaviourType = ret.get('type', BEHAVIOUR_TYPE_NONE) if behaviourType not in [ BEHAVIOUR_TYPE_REWARDED, BEHAVIOUR_TYPE_NOUSEED ]: behaviourInfo['type'] = random.randrange( 1, 3, 1) if status == '0' else BEHAVIOUR_TYPE_NONE return daobase.executeUserCmd(userId, 'HSET', 'userBehaviour:6:' + str(userId), 'info', strutil.dumps(behaviourInfo)) else: behaviourInfo['type'] = random.randrange( 1, 3, 1) if status == '0' else BEHAVIOUR_TYPE_NONE return daobase.executeUserCmd(userId, 'HSET', 'userBehaviour:6:' + str(userId), 'info', strutil.dumps(behaviourInfo)) except Exception, e: ftlog.warn('dizhu_user_behaviour._saveUserToRedis userId=', userId, 'err=', e)
def doExchangeAudit(self, userId, exchangeId, result): mo = MsgPack() mo.setCmd('exchange') mo.setParam('action', 'audit') mo.setParam('userId', userId) mo.setParam('result', result) mo.setParam('exchangeId', exchangeId) mo.setParam('gameId', HALL_GAMEID) mo.setResult('0', 'ok') userdata.clearUserCache(userId) if not userdata.checkUserData(userId): mo.setError(1, 'userId error') mo.setResult('0', 'userId error') return mo try: ec, info = exchange_remote.handleAuditResult( HALL_GAMEID, userId, exchangeId, result) if ec != 0: mo.setError(ec, info) mo.setResult('0', info) except: ftlog.error() mo.setError(1, 'audit fail') mo.setResult('0', 'audit fail') return mo
def doHallExmallShippingResult(self, userId, exchangeId, result, jdOrderId): mo = MsgPack() mo.setCmd('exchange') mo.setParam('action', 'shippingResult') mo.setParam('userId', userId) mo.setParam('result', result) mo.setParam('exchangeId', exchangeId) mo.setParam('gameId', HALL_GAMEID) mo.setResult('0', 'ok') userdata.clearUserCache(userId) if not userdata.checkUserData(userId): mo.setError(1, 'userId error') mo.setResult('0', 'userId error') return mo try: ec, info = hall_exmall_remote.handleShippingResult( HALL_GAMEID, userId, exchangeId, result, jdOrderId) if ec != 0: mo.setError(ec, info) mo.setResult('0', info) except: ftlog.error() mo.setError(1, 'shipping result fail') mo.setResult('0', 'shipping result fail') return mo
def doPromoteCodeCheck(cls, gameId, userId, clientId, action, promoteCode): ''' 验证兑换码ID,有效则获取用户手机绑定信息,若绑定手机,则发送奖励,并更新用户状态。若未绑定手机,则更新用户状态,返回未绑定手机code ''' conf = hallconf.getNeiTuiGuangConf(clientId) if not conf: ftlog.error('neituiguang doGetUserState conf not found gameId=', gameId, 'userId=', userId, 'clientId=', clientId, 'action=', action) return mo = MsgPack() userstate = gamedata.getGameAttr(userId, gameId, cls.attrname_state) if userstate == 2: NeiTuiGuangProtocolBuilder.buildBasicInfo(0, action, '已经领奖成功', mo) else: promoteCode = cls.intPromoteCode(promoteCode) if promoteCode == -1 or userId == promoteCode: NeiTuiGuangProtocolBuilder.buildBasicInfo( 1, action, cls.getprize(gameId, 1, conf), mo) else: userdata.checkUserData(promoteCode) createTime = userdata.getAttr(promoteCode, 'createTime') if createTime == None: NeiTuiGuangProtocolBuilder.buildBasicInfo( 1, action, cls.getprize(gameId, 1, conf), mo) else: olduser = cls.isOldUser(promoteCode, gameId, createTime, conf) if not olduser: NeiTuiGuangProtocolBuilder.buildBasicInfo( 1, action, cls.getprize(gameId, 1, conf), mo) else: gamedata.setGameAttr(userId, gameId, cls.attrname_promotecode, promoteCode) # 记录兑换码 gamedata.setGameAttr(userId, gameId, cls.attrname_state, 1) # 已输入兑换码 bindmobile = userdata.getAttr(userId, 'bindMobile') if cls.bindOk(bindmobile): NeiTuiGuangProtocolBuilder.buildBasicInfo( 0, action, '验证成功', mo) else: NeiTuiGuangProtocolBuilder.buildBasicInfo( 2, action, cls.getprize(gameId, 2, conf), mo) return mo
def canBeInviter(userId, invitee): try: if not userdata.checkUserData(userId): raise BadInviterException('口令错误') timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) neituiguang.ensureCanBeInviter(status, invitee) return 0, None except NeituiguangException, e: return e.errorCode, e.message
def friendInfo(cls, friend, prize, index, clientId): userdata.checkUserData(friend["userId"]) coupon = 0 if (index + 1) % 5 == 0: coupon = prize["COUPON"] result = {"prizeInfo": { "prize": [{"name": "CHIP", "count": prize["CHIP"]}, {"name": "COUPON", "count": coupon}], "state": friend["state"] }} uds = userdata.getAttrs(friend["userId"], ['purl', 'name', 'chip']) friendInfo = { "userId": friend["userId"], "headUrl": uds[0], "name": uds[1], "chip": uds[2], "dashifen": cls.getDaShiFenPic(friend["userId"], clientId) } result['friendInfo'] = friendInfo return result
def doGdssRemoveUserItem(self, userId, itemId, intEventParam): mo = MsgPack() ec, result = self.checkCode() if ec == 0: if userdata.checkUserData(userId): ec, result = item_remote.removeUserItem(HALL_GAMEID, userId, itemId, "GM_ADJUST", intEventParam) else: ec, result = 2, 'userId error !!' if ec != 0: mo.setError(ec, result) return mo
def addInvitee(userId, invitee): try: if not userdata.checkUserData(userId): raise TYBizConfException(-1, 'ID不存在') status = hall_invite.loadUserInviteStatus(userId) if not status.findInvitee(invitee): hall_invite.addInvitee(status, invitee) return 0, None except TYBizException, e: return e.errorCode, e.message
def doGdssQueryStore(self, userId, clientId): mo = MsgPack() ec, result = self.checkCode() if ec != 0: mo.setError(ec, result) else: if userdata.checkUserData(userId): tabs = StoreHelper.getStoreTabs(HALL_GAMEID, userId, clientId) mo.setResult('tabs', tabs) else: mo.setError(2, 'userId error !!') return mo
def onInvitationAccepted(userId, invitee): try: if not userdata.checkUserData(userId): raise BadInviterException('用户不存在') timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) invitation = status.findInvitee(invitee) if invitation: neituiguang.onInvitationAccepted(status, invitation) return 0, None except NeituiguangException, e: return e.errorCode, e.message
def doGdssAddVipExp(self, userId, toAddExp): mo = MsgPack() ec, result = self.checkCode() if ec == 0: if userdata.checkUserData(userId): ec, result = user_remote.addVipExp(HALL_GAMEID, userId, toAddExp, 'GM_ADJUST', 0) else: ec, result = 2, 'userId error !!' if ec != 0: mo.setError(ec, result) else: mo.setResult('vipExp', result) return mo
def addInvitee(userId, invitee, accepted): try: if not userdata.checkUserData(userId): raise BadInviterException('用户不存在') timestamp = pktimestamp.getCurrentTimestamp() status = neituiguang.loadStatus(userId, timestamp) if not status.findInvitee(invitee): if status.inviteeCount: pass neituiguang.addInvitee(status, invitee, accepted) return 0, None except NeituiguangException, e: return e.errorCode, e.message
def doGdssListUserItem(self, userId): mo = MsgPack() ec, result = self.checkCode() if ec == 0: if userdata.checkUserData(userId): ec, result = item_remote.listUserItem(userId) else: ec, result = 2, 'userId error !!' if ec != 0: mo.setError(ec, result) else: mo.setResult('items', result) return mo
def ensureCanAddInviter(status, inviter): ''' 检查用户是否可以成为被推荐人 ''' if not userdata.checkUserData(inviter): raise BadInviterException('推荐人不存在') if status.inviter: raise BadStateException('已经填写了推荐人') if status.userId == inviter: raise BadInviterException('不能推荐自己') return True
def do_gdss_user_msg_send(self, gameId, userId, text): """ 发送站内消息 @param text: 消息文本内容 """ mo = MsgPack() ec, result = self.checkCode() if not ec: if userdata.checkUserData(userId): message_remote.send(gameId, MESSAGE_TYPE_SYSTEM, userId, text) else: mo.setError(2, "userId error !!") else: mo.setError(ec, result) return mo
def doGdssAddUserItem(self, userId, kindId, count, intEventParam): mo = MsgPack() ec, result = self.checkCode() if ec == 0: if count >= 1000: ec = 1 result = 'item count to much !!' else: if userdata.checkUserData(userId): ec, result = item_remote.addUserItem(HALL_GAMEID, userId, kindId, count, "GM_ADJUST", intEventParam) else: ec, result = 2, 'userId error !!' if ec != 0: mo.setError(ec, result) return mo
def sendInviteeReward(userId, invitee, rewardCount): if ftlog.is_debug(): ftlog.debug('hall_invite_remote.sendInviteeReward', 'userId=', userId, 'invitee=', invitee, 'rewardCount=', rewardCount) try: if not userdata.checkUserData(userId): raise TYBizConfException(-1, 'ID不存在') status = hall_invite.loadUserInviteStatus(userId) if status.findInvitee(invitee): hall_invite.sendInviteeReward(status, invitee, rewardCount, pktimestamp.getCurrentTimestamp()) return 0, None except TYBizException, e: return e.errorCode, e.message
def ensureCanBeInviter(status, invitee): if not userdata.checkUserData(invitee): raise BadInviterException('您的账号信息有误') if status.userId == invitee: raise BadInviterException('不能推荐自己') if status.findInvitee(invitee): raise BadInviterException('已推荐此用户') if status.inviteeCount + 1 > MAX_INVITEE: ftlog.info('invite.addInvitee overCountLimit userId=', status.userId, 'invitee=', invitee, 'inviteeCount=', status.inviteeCount, 'MAX_INVITEE=', MAX_INVITEE) raise FullInviteException()
def doGetUserInfo(userId, otherUserId, kindId): """ :param kindId: 赠送的道具ID """ userdata.checkUserData(otherUserId) name = util.getNickname(otherUserId) sex, purl, charm = userdata.getAttrs(otherUserId, ["sex", "purl", "charm"]) vipLv = util.getVipShowLevel(otherUserId) level = util.getUserValidCheckLevel(otherUserId) honors = honor_system.getHonorList(otherUserId) _, leftReceiveCount = _isCanReceiveFromOther(otherUserId, kindId) code = 0 if name is None or name == "" or not level or level == 0: code = 1 if otherUserId in config.getPublic("banGiftList", []): code = 1 name = str(name) if name else "" message = MsgPack() message.setCmd("fishUserInfo") message.setResult("gameId", FISH_GAMEID) message.setResult("userId", userId) if code == 0: userInfos = { "userId": otherUserId, "name": name, "sex": sex, "purl": purl, "level": level, "vipLv": vipLv, "charm": charm, "honors": honors, "leftReceiveCount": leftReceiveCount } message.setResult("userInfos", userInfos) message.setResult("code", code) router.sendToUser(message, userId)
def _callRobotSigninMatch(self, count=1): self._logger.debug("MatchRoom._callRobotSigninMatch", count) for _ in xrange(count): ruid = random.randint(1, 200) # 有机器人直接进榜. if userdata.checkUserData(ruid): rname = userdata.getAttr(ruid, "name") self.addMatchRobotUser(ruid, rname) else: # 没有机器人召唤机器人登录. mo = MsgPack() mo.setCmd("robotmgr") mo.setAction("callmatch") mo.setParam("gameId", self.gameId) mo.setParam("roomId", self.roomId) mo.setParam("robotCount", 1) router.sendRobotServer(mo) self._logger.warn( "_callRobotSigninMatch, add robot failed, ruid =", ruid)
def do_gdss_user_msg_sendasset(self, gameId, userId, text, assets, intEventParam): """ 发送带物品或者货币的站内消息 @param text: 消息文本内容 @param assets: 附件内容,格式必须是:[{'itemId':'item:0011', 'count':1}, ...] @param intEventParam: 发奖事件的附带参数 """ mo = MsgPack() ec, result = self.checkCode() if not ec: if userdata.checkUserData(userId): d = {'eventid': "GM_ADJUST", 'eventparam': intEventParam, 'assets': assets} message_remote.send_asset(gameId, MESSAGE_TYPE_SYSTEM, userId, text, d) else: mo.setError(2, "userId error !!") else: mo.setError(ec, result) return mo
def _isCanReceiveFromOther(otherUserId, kindId): """ 检查是否可以接收他人赠送招财珠 """ from newfish.entity.config import SILVER_BULLET_KINDID, GOLD_BULLET_KINDID if kindId in [SILVER_BULLET_KINDID, GOLD_BULLET_KINDID]: silverBulletKey = WeakData.vipReceiveCount % SILVER_BULLET_KINDID if userdata.checkUserData(otherUserId): vipLevel = util.getVipRealLevel(otherUserId) dayReceiveCount = weakdata.getDayFishData(otherUserId, silverBulletKey, 0) dayLimitCount = config.getVipConf(vipLevel).get(silverBulletKey, 0) leftReceiveCount = dayLimitCount - dayReceiveCount if leftReceiveCount > 0 and not util.isProtectionLimit(otherUserId): if kindId == GOLD_BULLET_KINDID: leftReceiveCount = leftReceiveCount // 5 return 0, leftReceiveCount # 可以接受赠送 else: return 1, 0 # 不可以接受赠送 return 0, 99999
def do_gdss_user_msg_sendtodotask(self, gameId, clientId, userId, text, duration, todotask, todotask_kwarg): """ 发送带查看的站内消息 @param text: 消息文本内容 @param duration: 展示有效期,分钟,<=0就是永久有效 @param todotask: 模板参数,支持两种todotask: 1.hall.entity.hallpopwnd,见各game下popwnd的配置,这种情况只需要一个参数'templateName',但要保证clientid有效 2.不走模板的hall.entity.todotask,配置散落的到处都是。。。,这种情况需要传入详细的模板参数,其中必须含有'typeId' @param todotask_kwarg: 实例化todotask需要的参数,多数情况都不需要 """ mo = MsgPack() ec, result = self.checkCode() if not ec: if userdata.checkUserData(userId): message_remote.send_todotask(gameId, MESSAGE_TYPE_SYSTEM, clientId, userId, text, todotask, duration, None, **todotask_kwarg) else: mo.setError(2, "userId error !!") else: mo.setError(ec, result) return mo
def doGdssAddUserDiamond(self, userId, gameId, deltaCount, intEventParam): mo = MsgPack() mo.setResult('userId', userId) mo.setResult('gameId', gameId) mo.setResult('adjustDelta', deltaCount) mo.setResult('trueDelta', 0) mo.setResult('final', 0) ec, result = self.checkCode() if ec == 0: if deltaCount > 100000: mo.setError(1, 'coupon deltaCount to much !!') else: if userdata.checkUserData(userId): trueDelta, final = userchip.incrDiamond(userId, gameId, deltaCount, daoconst.CHIP_NOT_ENOUGH_OP_MODE_NONE, 'GM_ADJUST', intEventParam, configure.CLIENTID_SYSCMD) mo.setResult('trueDelta', trueDelta) mo.setResult('final', final) else: mo.setError(2, 'userId error !!') if ec != 0: mo.setError(ec, result) return mo
def do_share_click(self, userId, actname): if userId <= 0 or not userdata.checkUserData(userId): return 'user not exsit' return user_remote.activity_share_click(userId, actname)