コード例 #1
0
def broadcastQuickResult(iRightOption):
	'''广播抢答答案
	'''
	msg = answer_pb2.quickResult()
	msg.iOption = iRightOption
	sSerialized = endPoint.makePacket('rpcAnswerQuickResult', msg)
	mainService.getChatEP().rpcBroadcastAnswerQuick(sSerialized)
コード例 #2
0
def rpcB2CCollectDelEvent(ctrlr,reqMsg):
	iRoleId = reqMsg.iRoleId
	iEventId = reqMsg.iEventId
	iEventType = reqMsg.iEventType
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
	result = False
	resMsg = center_collect_pb2.eventOperResponse()
	if iEventType == MARKER_EVENT:	#标记
		result,iEventNo = roleInfoObj.removeMarkerEvent(iEventId)
		if result:
			mainOutCollectObj = collect.getMainCollectObj()
			resMsg.sTips = "取消对#C04{}#n的标记".format(mainOutCollectObj.getEventName(iEventNo))
	elif iEventType == COMPLETE_EVENT:#完成
		result = roleInfoObj.removeCompleteEvent(iEventId)
		if result:
			resMsg.sTips = "删除成功"
	elif iEventType == TRIGGER_EVENT:#触发
		result = roleInfoObj.removeTriggerInfo(iEventId)
		if result:
			resMsg.sTips = "删除成功"
	if result:
		msg = collect_pb2.delEventInfo()
		msg.iEventId = iEventId
		msg.iEventType = iEventType
		resMsg.sSerialized = endPoint.makePacket('rpcCollectDelEventResponse', msg)
	return resMsg
コード例 #3
0
def broadcastQuickProblem(iProblemNo, duration):
	'''广播抢答题目
	'''
	msg = answer_pb2.quickProblem()
	msg.iProblemNo = iProblemNo
	msg.duration = duration
	sSerialized = endPoint.makePacket('rpcAnswerQuickProblem', msg)
	mainService.getChatEP().rpcBroadcastAnswerQuick(sSerialized)
コード例 #4
0
def broadcastAll(senderObj, msgObj, channelId):
	'''广播给所有角色
	'''
	packetData = endPoint.makePacket("rpcChatDown", msgObj)
	for targetSender in chatService.getAllRoleSenderList():
		ep = targetSender.endPoint
		if not ep: # 链接断开时,ep判断为False
			continue
		if targetSender.isChannelBaned(channelId, senderObj.id):
			continue
		ep.send(packetData)
コード例 #5
0
ファイル: service.py プロジェクト: hw233/GameServer-Python
def rpcTeamBoxRequest(teamObj, func, title, content, timeOut):
	'''弹出队伍确认框
	'''
	teamObj.confirmResponse = func
	confirmTimeOut = getattr(teamObj, "confirmTimeOut", 0)
	if (confirmTimeOut + 120) < getSecond():
		teamObj.confirmList = {}
	teamObj.confirmTimeOut = getSecond()
	msgObj = packTeamConfirmBoxReq(teamObj, title, content, timeOut)
	packetMsg = endPoint.makePacket("rpcTeamConfirmBoxRequest", msgObj)
	for pid in teamObj.getInTeamList():
		roleObj = getRole(pid)
		if roleObj:
			roleObj.endPoint.send(packetMsg)
コード例 #6
0
def rpcB2CCollectSeeTrigger(ctrlr, reqMsg):
	'''查看触发
	'''
	iRoleId = reqMsg.iRoleId
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
	lRoleInfo = roleInfoObj.getTriggerRoleInfo()
	lEventMsg = []
	for dRoleInfo in lRoleInfo:
		lEventMsg.append(packetRoleInfo(dRoleInfo))
	
	msg = collect_pb2.eventList()
	msg.eventType = TRIGGER_EVENT
	msg.lEventList.extend(lEventMsg)
	return endPoint.makePacket('rpcCollectEventList', msg)
コード例 #7
0
def rpcB2CCollectSelfTrigger(ctrlr, reqMsg):
	'''查看完成
	'''
	iRoleId = reqMsg.iRoleId
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
	lComEvent = roleInfoObj.getCompleteEvent()
	lEventMsg = []
	for dEventInfo in lComEvent:
		lEventMsg.append(packetComEvent(dEventInfo))

	msg = collect_pb2.eventList()
	msg.eventType = COMPLETE_EVENT
	msg.lEventList.extend(lEventMsg)
	return endPoint.makePacket('rpcCollectEventList', msg)
コード例 #8
0
def rpcB2CCollectSeeMarker(ctrlr, reqMsg):
	'''查看标记事件
	'''
	iRoleId = reqMsg.iRoleId
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
	lMarkerEvent = roleInfoObj.getMarkerEvent()
	lEventMsg = []
	for dEventInfo in lMarkerEvent:
		lEventMsg.append(packetMarkerEvent(dEventInfo))

	msg = collect_pb2.eventList()
	msg.eventType = MARKER_EVENT
	msg.lEventList.extend(lEventMsg)
	return endPoint.makePacket('rpcCollectEventList', msg)
コード例 #9
0
def broadcastByRoleIds(senderObj, msgObj, channelId, roleIdList):
	'''根据角色id进行组播
	'''
	packetData = endPoint.makePacket("rpcChatDown", msgObj)
	for roleId in roleIdList:
		targetSender = chatService.getSender(roleId)
		if not targetSender:
			continue
		ep = targetSender.endPoint
		if not ep: # 链接断开时,ep判断为False
			continue
		if targetSender.isChannelBaned(channelId, senderObj.id):
			continue
		ep.send(packetData)
コード例 #10
0
def rpcC2BCollectDelEvent(iZoneNo, iRoleId, iEventId, iEventType):
	'''删除事件
	'''
	iZoneNo = roleInfoObj.iServerId
	oCenterEP = getCenterEP(iZoneNo)
	if not oCenterEP:
		return
	msg = center_collect_pb2.passiveEventInfo()
	msg.iRoleId = iRoleId

	delmsg = collect_pb2.delEventInfo()
	delmsg.iEventId = iEventId
	delmsg.iEventType = iEventType

	msg.sSerialized = endPoint.makePacket("rpcCollectDelEventResponse", delmsg)

	oCenterEP.rpcC2BCollectDelEvent(msg)
コード例 #11
0
def rpcB2CCollectAround(ctrlr, reqMsg):
	lAroundRoleId = collect.gRoleInfoMngObj.getAroundRole(reqMsg.iRoleId, reqMsg.iServerId, float(reqMsg.fPosX), float(reqMsg.fPosY))
	msg = center_collect_pb2.aroundRoleResponse()
	roleListMsg = collect_pb2.roleList()
	if not lAroundRoleId:
		msg.sFailReason = "很遗憾,本地区还有玩家未开启定位功能"
		# msg.sAroundRole = ""
	else:
		msg.sFailReason = ""
		lRoleMsg = []
		for iRoleId in lAroundRoleId:
			roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
			if not roleInfoObj:
				continue
			lRoleMsg.append(packetAroundRoleInfo(roleInfoObj))
		roleListMsg.lRoleList.extend(lRoleMsg)
	msg.sAroundRole = endPoint.makePacket('rpcAroundRoleInfo', roleListMsg)
	return msg
コード例 #12
0
def rpcB2CCollectSearch(ctrlr, reqMsg):
	'''搜索
	'''
	# collect.CollectLog("rpcB2CCollectSearch id={}".format(reqMsg.iRoleId))
	iRoleId = reqMsg.iRoleId
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)
	gCenterCollectObj = collect.getCenterCollectObj()
	lEventList = roleInfoObj.getSpecialEvent()
	if not lEventList:
		lEventList = gCenterCollectObj.searchEvent(reqMsg)
	lEventMsg = []
	
	for iEventId in lEventList:
		eventInfoObj = gCenterCollectObj.getEventInfoObj(iEventId)
		if not eventInfoObj:
			continue
		lEventMsg.append(packetEvent(iEventId, eventInfoObj))
	msg = collect_pb2.eventList()
	msg.eventType = SEARCH_EVENT
	msg.lEventList.extend(lEventMsg)
	return endPoint.makePacket('rpcCollectEventList', msg)
コード例 #13
0
def rpcC2BCollectAddEvent(iEventType, eventObj, proRoleInfoObj, roleInfoObj=None):
	'''增加事件
	'''
	iZoneNo = proRoleInfoObj.iServerId
	oCenterEP = getCenterEP(iZoneNo)
	if not oCenterEP:
		return

	msg = center_collect_pb2.passiveEventInfo()
	msg.iRoleId = proRoleInfoObj.iRoleId

	addmsg = collect_pb2.eventList()
	addmsg.eventType = iEventType

	if iEventType == MARKER_EVENT:	#标记
		addmsg.lEventList.extend([packetMarkerEvent(eventObj.packetData())])
	elif iEventType == COMPLETE_EVENT:#完成
		addmsg.lEventList.extend([packetComEvent(eventObj.packetData())])
	elif iEventType == TRIGGER_EVENT:#触发
		addmsg.lEventList.extend([packetRoleInfo(roleInfoObj.packetData())])

	msg.sSerialized = endPoint.makePacket("rpcCollectAddEvent", addmsg)
	oCenterEP.rpcC2BCollectAddEvent(msg)
コード例 #14
0
ファイル: svcRank.py プロジェクト: hw233/GameServer-Python
def rpcRankDisplayReq(self, ep, who, reqMsg):
    iType = reqMsg.iValue
    iRoleId = who.id
    oRank, sRankName = getRankAndNameByType(iType)
    rankList = oRank.rank() if iType == RANK_LEAGUE else oRank.ranking(
    )[:oRank.iDisplaySize]
    if iRoleId not in rankList:
        ep.rpcTips('你的排名未上榜,还不能进行炫耀')
        return
    iCurStamp = timeU.getStamp()
    if iCurStamp - getattr(who, 'iLastShowStamp', 0) <= 10:
        ep.rpcTips('你炫耀的过于频繁了,稍后再试试吧')
        return
    bFail, uMsg = ep.rpcConfirmBox(sTitle='炫耀一下',
                                   sContent='炫耀一次需要消耗一个喇叭,是否炫耀?',
                                   sSelect='Q_确定Q_取消')
    if bFail or uMsg.iValue != 0:
        return
    who = role.gKeeper.getObj(iRoleId)
    if not who:
        return
    oTrumpet = who.propsCtn.getTrumpet()
    if not oTrumpet:
        ep.rpcTips('你的喇叭数量不足')
        return
    who.propsCtn.addStack(oTrumpet, -1)  #扣除喇叭
    iCurStamp = timeU.getStamp()
    who.iLastShowStamp = iCurStamp  #设置炫耀时间
    sContent = getShowContent(iType, who, oRank, sRankName)
    oMsg = chatRoom_pb2.chatSysDown(
        iChannel=1,
        sContent=sContent,
    )
    sPacket = endPoint.makePacket('rpcAnnounce', oMsg)
    for iUid, ep in mainService.gRoleIdMapEndPoint.getAll().iteritems():
        ep.send(sPacket)
コード例 #15
0
def rpcB2CCollectMarker(ctrlr,reqMsg):
	'''标记事件
	'''
	iRoleId = reqMsg.iRoleId
	iEventId = reqMsg.iEventId
	roleInfoObj = collect.gRoleInfoMngObj.getRoleInfoObj(iRoleId)

	resMsg = center_collect_pb2.eventOperResponse()

	gCenterCollectObj = collect.getCenterCollectObj()
	eventObj = gCenterCollectObj.getEventInfoObj(iEventId)
	if not eventObj or not eventObj.isValid():
		resMsg.sTips = "标志消失,事件已消失"
	elif roleInfoObj.isMarkerEvent(iEventId):
		resMsg.sTips = "事件已标记"
	else:
		resMsg.sTips = "成功标记事件#C04{}#n".format(eventObj.eventName())
		dEventInfo = roleInfoObj.markerEvent(eventObj)
		msg = collect_pb2.eventList()
		msg.eventType = MARKER_EVENT
		msg.lEventList.extend([packetMarkerEvent(dEventInfo)])
		resMsg.sSerialized = endPoint.makePacket("rpcCollectAddEvent", msg)
	
	return resMsg