| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- --------------------------------
- -- 文件名 : jjcNewLadderMiddle.lua
- -- 文件说明 : 天梯赛-跨服相关
- -- 创建时间 : 2025/05/21
- -- 创建人 : FC
- --------------------------------
- local Util = require("common.Util")
- local WarZoneConf = require("excel.WarZone")
- local MiddleConnect = require("middle.MiddleConnect")
- local MiddleManager = require("middle.MiddleManager")
- local InnerMsg = require("core.InnerMsg")
- local Config = require("Config")
- local CommonDB = require("common.CommonDB")
- local Timer = require("core.Timer")
- local Log = require("common.Log")
- local JjcNewLogic = require("jjcnewladder.jjcNewLadderLogic")
- -- local JjcNewLadderDB = require("jjcnewladder.jjcNewLadderDB")
- local CommonDefine = require("common.CommonDefine")
- ----------------------------------- 内部操作 ---------------------------
- -- 判断是否是战区第一个服
- local function JjcNewLadderMiddle_CheckIsFirstWarServer(nServerID)
- local nConfServerID = nServerID - CommonDefine.COMMON_SERVER_OFFSET
- local tWarZoneConf = WarZoneConf.group
- for _, v in pairs(tWarZoneConf) do
- if v.nMinServerID == nConfServerID then
- return true
- end
- end
- return false
- end
- --------------------------- 跨服请求 ------------------------------
- -- 普通服请求报名参加
- function JjcNewLadderMiddle_JoinLadder(human)
- if JjcNewLadderMiddle_CheckIsFirstWarServer(Config.SVR_INDEX) then
- local tMsgData = {
- uuid = human.db._id,
- name = human.db.name,
- nSrcServerID = Config.SVR_INDEX,
- head = human.db.head,
- headFrame = human.db.headFrame,
- szServerName = "寻宝"..Config.NEW_SVR_INDEX.."区",
- zhandouli = human.db.zhandouli
- }
- JjcNewLogic.JjcNewLadderLogic_JoinHuman(tMsgData)
- else
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_JOINLADDER_O2C
- tMsgData.uuid = human.db._id
- tMsgData.name = human.db.name
- tMsgData.nSrcServerID = Config.SVR_INDEX
- tMsgData.head = human.db.head
- tMsgData.headFrame = human.db.headFrame
- tMsgData.szServerName = "寻宝"..Config.NEW_SVR_INDEX.."区"
- -- tMsgData.zhandouli = human.db.zhandouli
-
- InnerMsg.sendMsg(0, tMsgData)
- end
- end
- -- 数据服回复中心服报名数据
- function JjcNewLadderMiddle_JoinLadder_D2C(uuid, nSrcServerID, nRank, tRivalData)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_JOINLADDER_D2C
- tMsgData.uuid = uuid
- tMsgData.nSrcServerID = nSrcServerID
- tMsgData.nRank = nRank
- tMsgData.tEnemy = tRivalData
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 普通服请求刷新对手
- function JjcNewLadderMiddle_RefreshEnemy(human)
- local tMsgData = InnerMsg.LW.LW_JJC_NEWLADDER_REFRESH_O2C
- tMsgData.uuid = human.db._id
- tMsgData.nSrcServerID = Config.SVR_INDEX
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 数据服回复中心服刷新对战列表
- function JjcNewLadderMiddle_RefreshEnemy_D2C(uuid, nSrcServerID, tRivalData)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_REFRESH_D2C
- tMsgData.uuid = uuid
- tMsgData.nSrcServerID = nSrcServerID
- tMsgData.tEnemy = tRivalData
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 请求上一轮前3名玩家信息
- function JjcNewLadderMiddle_QueryLastRank()
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_LAST3RANK_O2C
- tMsgData.nSrcServerID = Config.SVR_INDEX
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 点赞对应玩家(发起人, 被点赞人, 被点赞人服务器ID)
- function JjcNewLadderMiddle_SendWorShip(uuidSrc, uuidDes, nDesServerID)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_WORSHIP_O2C
- tMsgData.uuidSrc = uuidSrc
- tMsgData.uuidDes = uuidDes
- tMsgData.nSrcServerID = Config.SVR_INDEX
- tMsgData.nDesServerID = nDesServerID
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 回复点赞数据
- function JjcNewLadderMiddle_AddWorShip_D2C(tData, nWorShipNum)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_WORSHIP_D2C
- tMsgData.uuidSrc = tData.uuidSrc
- tMsgData.nSrcServerID = tData.nSrcServerID
- tMsgData.uuidDes = tData.uuidDes
- tMsgData.nNowWorShip = nWorShipNum
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 请求排行榜数据
- function JjcNewLadderMiddle_QueryRankInfo()
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_RANK_O2C
- tMsgData.nSrcServerID = Config.SVR_INDEX
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 回复排行榜数据给中心服
- function JjcNewLadderMiddle_QueryRankInfo_D2C(tRankData, nFinish, nServerID, nFirst)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_RANK_D2C
- tMsgData.nSrcServerID = nServerID
- tMsgData.nIsEnd = nFinish
- tMsgData.nFirst = nFirst
- tMsgData.tRankInfo = tRankData
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 请求检测能否进入战斗
- function JjcNewLadderMiddle_CheckCanFightBegin(human, uuidEnemy)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_CAN_FIGHT_O2C
- tMsgData.uuid = human.db._id
- tMsgData.uuidDes = uuidEnemy
- tMsgData.nSrcServerID = Config.SVR_INDEX
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 数据服回复检测战斗完成
- function JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_CAN_FIGHT_D2C
- tMsgData.uuid = tData.uuid
- tMsgData.uuidDes = tData.uuidDes
- tMsgData.nSrcServerID = tData.nSrcServerID
- tMsgData.nIsFight = nCanFight
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 通知中心服战斗结果
- function JjcNewLadderMiddle_FightEndO2C(uuid, uuidDes, nResult, tEnemyUid)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_CANCEL_FIGHT_END_O2C
- tMsgData.uuid = uuid
- tMsgData.uuidDes = uuidDes
- tMsgData.nResult = nResult
- tMsgData.nSrcServerID = Config.SVR_INDEX
- tMsgData.tEnemyUid = tEnemyUid
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 回复中心服战斗后最新的排名等数据
- function JjcNewLadderMiddle_ReplyFightD2C(uuid, uuidDes, nSrcServerID, nNewRank, nNewPoint, tOldEnemyData, tNewOneEnemy)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_CANCEL_FIGHT_END_D2C
- tMsgData.uuid = uuid
- tMsgData.uuidDes = uuidDes
- tMsgData.nSrcServerID = nSrcServerID
- tMsgData.nNewRank = nNewRank
- tMsgData.nNewPoint = nNewPoint
- tMsgData.tOldEnemyData = tOldEnemyData
- tMsgData.tNewOneEnemy = tNewOneEnemy
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 发送战败邮件
- function JjcNewLadderMiddle_SendFailMail(uuidDes, nServerID, SrcServerName, SrcName, nNewRank)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_MAIL_D2C
- tMsgData.uuidDes = uuidDes
- tMsgData.nDesServerID = nServerID
- tMsgData.szServerName = SrcServerName
- tMsgData.szName = SrcName
- tMsgData.nNewRank = nNewRank
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 发送奖励邮件
- function JjcNewLadderMiddle_SendPrizeMail(uuid, nServerID, nRank)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_RANK_PRIZE_D2C
- tMsgData.uuid = uuid
- tMsgData.nServerID = nServerID
- tMsgData.nRank = nRank
- InnerMsg.sendMsg(0, tMsgData)
- end
- --------------------------- 收到跨服请求-----------------------------
- -- 收到其他服报名请求
- function WL_JJC_NEWLADDER_JOINLADDER_C2D(fd, msg)
- JjcNewLogic.JjcNewLadderLogic_JoinHuman(msg)
- end
- -- 收到报名回包
- function WL_JJC_NEWLADDER_JOINLADDER_C2O(fd, msg)
- JjcNewLogic.JjcNewLadderLogic_JoinHumanOk(msg)
- end
- -- 数据服收到刷新对战列表
- function WL_JJC_NEWLADDER_REFRESH_C2D(fd, msg)
- JjcNewLogic.JjcNewLadderLogic_RefeshEnemy(msg)
- end
- -- 请求刷新对战列表(中心-普通)
- function WL_JJC_NEWLADDER_REFRESH_C2O(fd, msg)
- JjcNewLogic.JjcNewLadderLogic_RefeshEnemyOK(msg)
- end
- -- 请求上一轮前3玩家信息(中心->数据)
- function WL_JJC_NEWLADDER_LAST3RANK_C2D(msg)
- local tMsgData = InnerMsg.LW_JJC_NEWLADDER_LAST3RANK_D2O
- tMsgData.nSrcServerID = msg.nSrcServerID
- local tLast3RankInfo = CommonDB.GetJjcLadderLast3RankInfo()
- if not tLast3RankInfo then
- tMsgData.nExist = 0
- tMsgData.tLastRankInfo = {}
- else
- tMsgData.nExist = 1
- tMsgData.tLastRankInfo = tLast3RankInfo
- end
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 请求上一轮前3玩家信息(中心->普通)
- function WL_JJC_NEWLADDER_LAST3RANK_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_GetLast3RankOK(msg)
- end
- -- 进行点赞(中心->数据(被点赞玩家所在服))
- function WL_JJC_NEWLADDER_SEND_WORSHIP_C2D(msg)
- JjcNewLogic.JjcNewLadderLogic_AddWorShip(msg)
- end
- -- 进行点赞回复(中心->普通)
- function WL_JJC_NEWLADDER_SEND_WORSHIP_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_AddWorShipOK(msg)
- end
- -- 改变战区数据服记录的点赞数量
- function WL_JJC_NEWLADDER_WORSHIP_CHANGE_C2D(msg)
- local tLast3RankInfo = CommonDB.GetJjcLadderLast3RankInfo()
- local uuid, nAddNum = msg.uuidDes, msg.nAddNum
- local nNowWorShip
- for _, v in pairs(tLast3RankInfo) do
- if v.uuid == uuid then
- v.worshipCnt = v.worshipCnt + nAddNum
- nNowWorShip = v.worshipCnt + 1
- break
- end
- end
- if not nNowWorShip then
- print("[WL_JJC_NEWLADDER_WORSHIP_CHANGE_C2D] 获取不到对应的点赞数据")
- return
- end
- CommonDB.SetJjcLadderLast3RankInfo(tLast3RankInfo)
- local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_WORSHIP_CHANGE_D2C
- tMsgData.uuidDes = uuid
- tMsgData.nNowWorShip = nNowWorShip
- InnerMsg.sendMsg(0, tMsgData)
- end
- -- 通知对应战区所属服务器更新最新的点赞数
- function WL_JJC_NEWLADDER_WORSHIP_UPDATE_D2C(msg)
- JjcNewLogic.JjcNewLadderLogic_UpdateWorShip(msg)
- end
- -- 请求天梯赛排行榜数据(中心->战区数据服)
- function WL_JJC_NEWLADDER_QUERY_RANK_C2D(msg)
- JjcNewLogic.JjcNewLadderLogic_GetRankInfo(msg)
- end
- -- 获取到天梯赛排行榜数据(中心->普通)
- function WL_JJC_NEWLADDER_QUERY_RANK_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_GetRankInfoOK(msg)
- end
- -- 查询是否能够战斗(中心->战区数据服)
- function WL_JJC_NEWLADDER_QUERY_CAN_FIGHT_C2D(msg)
- JjcNewLogic.JjcNewLadderLogic_CheckCanFight(msg)
- end
- -- 查询是否能够战斗(中心->普通)
- function WL_JJC_NEWLADDER_QUERY_CAN_FIGHT_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_CheckCanFightOK(msg)
- end
- -- 战斗结束(中心->战区数据服)
- function WL_JJC_NEWLADDER_CANCEL_FIGHT_END_C2D(msg)
- JjcNewLogic.JjcNewLadderLogic_FightEnd(msg)
- end
- -- 战斗结束(中心 -> 普通)
- function WL_JJC_NEWLADDER_CANCEL_FIGHT_END_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_FightEndOK(msg)
- end
- function WL_JJC_NEWLADDER_SEND_MAIL_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_SendFailMailOK(msg)
- end
- function WL_JJC_NEWLADDER_SEND_RANK_PRIZE_C2O(msg)
- JjcNewLogic.JjcNewLadderLogic_SendPrizeMail(msg)
- end
|