jjcNewLadderMiddle.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. --------------------------------
  2. -- 文件名 : jjcNewLadderMiddle.lua
  3. -- 文件说明 : 天梯赛-跨服相关
  4. -- 创建时间 : 2025/05/21
  5. -- 创建人 : FC
  6. --------------------------------
  7. local Util = require("common.Util")
  8. local WarZoneConf = require("excel.WarZone")
  9. local MiddleConnect = require("middle.MiddleConnect")
  10. local MiddleManager = require("middle.MiddleManager")
  11. local InnerMsg = require("core.InnerMsg")
  12. local Config = require("Config")
  13. local CommonDB = require("common.CommonDB")
  14. local Timer = require("core.Timer")
  15. local Log = require("common.Log")
  16. local JjcNewLogic = require("jjcnewladder.jjcNewLadderLogic")
  17. -- local JjcNewLadderDB = require("jjcnewladder.jjcNewLadderDB")
  18. local CommonDefine = require("common.CommonDefine")
  19. ----------------------------------- 内部操作 ---------------------------
  20. -- 判断是否是战区第一个服
  21. local function JjcNewLadderMiddle_CheckIsFirstWarServer(nServerID)
  22. local nConfServerID = nServerID - CommonDefine.COMMON_SERVER_OFFSET
  23. local tWarZoneConf = WarZoneConf.group
  24. for _, v in pairs(tWarZoneConf) do
  25. if v.nMinServerID == nConfServerID then
  26. return true
  27. end
  28. end
  29. return false
  30. end
  31. --------------------------- 跨服请求 ------------------------------
  32. -- 普通服请求报名参加
  33. function JjcNewLadderMiddle_JoinLadder(human)
  34. if JjcNewLadderMiddle_CheckIsFirstWarServer(Config.SVR_INDEX) then
  35. local tMsgData = {
  36. uuid = human.db._id,
  37. name = human.db.name,
  38. nSrcServerID = Config.SVR_INDEX,
  39. head = human.db.head,
  40. headFrame = human.db.headFrame,
  41. szServerName = "寻宝"..Config.NEW_SVR_INDEX.."区",
  42. zhandouli = human.db.zhandouli
  43. }
  44. JjcNewLogic.JjcNewLadderLogic_JoinHuman(tMsgData)
  45. else
  46. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_JOINLADDER_O2C
  47. tMsgData.uuid = human.db._id
  48. tMsgData.name = human.db.name
  49. tMsgData.nSrcServerID = Config.SVR_INDEX
  50. tMsgData.head = human.db.head
  51. tMsgData.headFrame = human.db.headFrame
  52. tMsgData.szServerName = "寻宝"..Config.NEW_SVR_INDEX.."区"
  53. -- tMsgData.zhandouli = human.db.zhandouli
  54. InnerMsg.sendMsg(0, tMsgData)
  55. end
  56. end
  57. -- 数据服回复中心服报名数据
  58. function JjcNewLadderMiddle_JoinLadder_D2C(uuid, nSrcServerID, nRank, tRivalData)
  59. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_JOINLADDER_D2C
  60. tMsgData.uuid = uuid
  61. tMsgData.nSrcServerID = nSrcServerID
  62. tMsgData.nRank = nRank
  63. tMsgData.tEnemy = tRivalData
  64. InnerMsg.sendMsg(0, tMsgData)
  65. end
  66. -- 普通服请求刷新对手
  67. function JjcNewLadderMiddle_RefreshEnemy(human)
  68. local tMsgData = InnerMsg.LW.LW_JJC_NEWLADDER_REFRESH_O2C
  69. tMsgData.uuid = human.db._id
  70. tMsgData.nSrcServerID = Config.SVR_INDEX
  71. InnerMsg.sendMsg(0, tMsgData)
  72. end
  73. -- 数据服回复中心服刷新对战列表
  74. function JjcNewLadderMiddle_RefreshEnemy_D2C(uuid, nSrcServerID, tRivalData)
  75. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_REFRESH_D2C
  76. tMsgData.uuid = uuid
  77. tMsgData.nSrcServerID = nSrcServerID
  78. tMsgData.tEnemy = tRivalData
  79. InnerMsg.sendMsg(0, tMsgData)
  80. end
  81. -- 请求上一轮前3名玩家信息
  82. function JjcNewLadderMiddle_QueryLastRank()
  83. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_LAST3RANK_O2C
  84. tMsgData.nSrcServerID = Config.SVR_INDEX
  85. InnerMsg.sendMsg(0, tMsgData)
  86. end
  87. -- 点赞对应玩家(发起人, 被点赞人, 被点赞人服务器ID)
  88. function JjcNewLadderMiddle_SendWorShip(uuidSrc, uuidDes, nDesServerID)
  89. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_WORSHIP_O2C
  90. tMsgData.uuidSrc = uuidSrc
  91. tMsgData.uuidDes = uuidDes
  92. tMsgData.nSrcServerID = Config.SVR_INDEX
  93. tMsgData.nDesServerID = nDesServerID
  94. InnerMsg.sendMsg(0, tMsgData)
  95. end
  96. -- 回复点赞数据
  97. function JjcNewLadderMiddle_AddWorShip_D2C(tData, nWorShipNum)
  98. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_WORSHIP_D2C
  99. tMsgData.uuidSrc = tData.uuidSrc
  100. tMsgData.nSrcServerID = tData.nSrcServerID
  101. tMsgData.uuidDes = tData.uuidDes
  102. tMsgData.nNowWorShip = nWorShipNum
  103. InnerMsg.sendMsg(0, tMsgData)
  104. end
  105. -- 请求排行榜数据
  106. function JjcNewLadderMiddle_QueryRankInfo()
  107. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_RANK_O2C
  108. tMsgData.nSrcServerID = Config.SVR_INDEX
  109. InnerMsg.sendMsg(0, tMsgData)
  110. end
  111. -- 回复排行榜数据给中心服
  112. function JjcNewLadderMiddle_QueryRankInfo_D2C(tRankData, nFinish, nServerID, nFirst)
  113. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_RANK_D2C
  114. tMsgData.nSrcServerID = nServerID
  115. tMsgData.nIsEnd = nFinish
  116. tMsgData.nFirst = nFirst
  117. tMsgData.tRankInfo = tRankData
  118. InnerMsg.sendMsg(0, tMsgData)
  119. end
  120. -- 请求检测能否进入战斗
  121. function JjcNewLadderMiddle_CheckCanFightBegin(human, uuidEnemy)
  122. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_CAN_FIGHT_O2C
  123. tMsgData.uuid = human.db._id
  124. tMsgData.uuidDes = uuidEnemy
  125. tMsgData.nSrcServerID = Config.SVR_INDEX
  126. InnerMsg.sendMsg(0, tMsgData)
  127. end
  128. -- 数据服回复检测战斗完成
  129. function JjcNewLadderMiddle_ReplyCheckFight(tData, nCanFight)
  130. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_QUERY_CAN_FIGHT_D2C
  131. tMsgData.uuid = tData.uuid
  132. tMsgData.uuidDes = tData.uuidDes
  133. tMsgData.nSrcServerID = tData.nSrcServerID
  134. tMsgData.nIsFight = nCanFight
  135. InnerMsg.sendMsg(0, tMsgData)
  136. end
  137. -- 通知中心服战斗结果
  138. function JjcNewLadderMiddle_FightEndO2C(uuid, uuidDes, nResult, tEnemyUid)
  139. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_CANCEL_FIGHT_END_O2C
  140. tMsgData.uuid = uuid
  141. tMsgData.uuidDes = uuidDes
  142. tMsgData.nResult = nResult
  143. tMsgData.nSrcServerID = Config.SVR_INDEX
  144. tMsgData.tEnemyUid = tEnemyUid
  145. InnerMsg.sendMsg(0, tMsgData)
  146. end
  147. -- 回复中心服战斗后最新的排名等数据
  148. function JjcNewLadderMiddle_ReplyFightD2C(uuid, uuidDes, nSrcServerID, nNewRank, nNewPoint, tOldEnemyData, tNewOneEnemy)
  149. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_CANCEL_FIGHT_END_D2C
  150. tMsgData.uuid = uuid
  151. tMsgData.uuidDes = uuidDes
  152. tMsgData.nSrcServerID = nSrcServerID
  153. tMsgData.nNewRank = nNewRank
  154. tMsgData.nNewPoint = nNewPoint
  155. tMsgData.tOldEnemyData = tOldEnemyData
  156. tMsgData.tNewOneEnemy = tNewOneEnemy
  157. InnerMsg.sendMsg(0, tMsgData)
  158. end
  159. -- 发送战败邮件
  160. function JjcNewLadderMiddle_SendFailMail(uuidDes, nServerID, SrcServerName, SrcName, nNewRank)
  161. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_MAIL_D2C
  162. tMsgData.uuidDes = uuidDes
  163. tMsgData.nDesServerID = nServerID
  164. tMsgData.szServerName = SrcServerName
  165. tMsgData.szName = SrcName
  166. tMsgData.nNewRank = nNewRank
  167. InnerMsg.sendMsg(0, tMsgData)
  168. end
  169. -- 发送奖励邮件
  170. function JjcNewLadderMiddle_SendPrizeMail(uuid, nServerID, nRank)
  171. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_SEND_RANK_PRIZE_D2C
  172. tMsgData.uuid = uuid
  173. tMsgData.nServerID = nServerID
  174. tMsgData.nRank = nRank
  175. InnerMsg.sendMsg(0, tMsgData)
  176. end
  177. --------------------------- 收到跨服请求-----------------------------
  178. -- 收到其他服报名请求
  179. function WL_JJC_NEWLADDER_JOINLADDER_C2D(fd, msg)
  180. JjcNewLogic.JjcNewLadderLogic_JoinHuman(msg)
  181. end
  182. -- 收到报名回包
  183. function WL_JJC_NEWLADDER_JOINLADDER_C2O(fd, msg)
  184. JjcNewLogic.JjcNewLadderLogic_JoinHumanOk(msg)
  185. end
  186. -- 数据服收到刷新对战列表
  187. function WL_JJC_NEWLADDER_REFRESH_C2D(fd, msg)
  188. JjcNewLogic.JjcNewLadderLogic_RefeshEnemy(msg)
  189. end
  190. -- 请求刷新对战列表(中心-普通)
  191. function WL_JJC_NEWLADDER_REFRESH_C2O(fd, msg)
  192. JjcNewLogic.JjcNewLadderLogic_RefeshEnemyOK(msg)
  193. end
  194. -- 请求上一轮前3玩家信息(中心->数据)
  195. function WL_JJC_NEWLADDER_LAST3RANK_C2D(msg)
  196. local tMsgData = InnerMsg.LW_JJC_NEWLADDER_LAST3RANK_D2O
  197. tMsgData.nSrcServerID = msg.nSrcServerID
  198. local tLast3RankInfo = CommonDB.GetJjcLadderLast3RankInfo()
  199. if not tLast3RankInfo then
  200. tMsgData.nExist = 0
  201. tMsgData.tLastRankInfo = {}
  202. else
  203. tMsgData.nExist = 1
  204. tMsgData.tLastRankInfo = tLast3RankInfo
  205. end
  206. InnerMsg.sendMsg(0, tMsgData)
  207. end
  208. -- 请求上一轮前3玩家信息(中心->普通)
  209. function WL_JJC_NEWLADDER_LAST3RANK_C2O(msg)
  210. JjcNewLogic.JjcNewLadderLogic_GetLast3RankOK(msg)
  211. end
  212. -- 进行点赞(中心->数据(被点赞玩家所在服))
  213. function WL_JJC_NEWLADDER_SEND_WORSHIP_C2D(msg)
  214. JjcNewLogic.JjcNewLadderLogic_AddWorShip(msg)
  215. end
  216. -- 进行点赞回复(中心->普通)
  217. function WL_JJC_NEWLADDER_SEND_WORSHIP_C2O(msg)
  218. JjcNewLogic.JjcNewLadderLogic_AddWorShipOK(msg)
  219. end
  220. -- 改变战区数据服记录的点赞数量
  221. function WL_JJC_NEWLADDER_WORSHIP_CHANGE_C2D(msg)
  222. local tLast3RankInfo = CommonDB.GetJjcLadderLast3RankInfo()
  223. local uuid, nAddNum = msg.uuidDes, msg.nAddNum
  224. local nNowWorShip
  225. for _, v in pairs(tLast3RankInfo) do
  226. if v.uuid == uuid then
  227. v.worshipCnt = v.worshipCnt + nAddNum
  228. nNowWorShip = v.worshipCnt + 1
  229. break
  230. end
  231. end
  232. if not nNowWorShip then
  233. print("[WL_JJC_NEWLADDER_WORSHIP_CHANGE_C2D] 获取不到对应的点赞数据")
  234. return
  235. end
  236. CommonDB.SetJjcLadderLast3RankInfo(tLast3RankInfo)
  237. local tMsgData = InnerMsg.lw.LW_JJC_NEWLADDER_WORSHIP_CHANGE_D2C
  238. tMsgData.uuidDes = uuid
  239. tMsgData.nNowWorShip = nNowWorShip
  240. InnerMsg.sendMsg(0, tMsgData)
  241. end
  242. -- 通知对应战区所属服务器更新最新的点赞数
  243. function WL_JJC_NEWLADDER_WORSHIP_UPDATE_D2C(msg)
  244. JjcNewLogic.JjcNewLadderLogic_UpdateWorShip(msg)
  245. end
  246. -- 请求天梯赛排行榜数据(中心->战区数据服)
  247. function WL_JJC_NEWLADDER_QUERY_RANK_C2D(msg)
  248. JjcNewLogic.JjcNewLadderLogic_GetRankInfo(msg)
  249. end
  250. -- 获取到天梯赛排行榜数据(中心->普通)
  251. function WL_JJC_NEWLADDER_QUERY_RANK_C2O(msg)
  252. JjcNewLogic.JjcNewLadderLogic_GetRankInfoOK(msg)
  253. end
  254. -- 查询是否能够战斗(中心->战区数据服)
  255. function WL_JJC_NEWLADDER_QUERY_CAN_FIGHT_C2D(msg)
  256. JjcNewLogic.JjcNewLadderLogic_CheckCanFight(msg)
  257. end
  258. -- 查询是否能够战斗(中心->普通)
  259. function WL_JJC_NEWLADDER_QUERY_CAN_FIGHT_C2O(msg)
  260. JjcNewLogic.JjcNewLadderLogic_CheckCanFightOK(msg)
  261. end
  262. -- 战斗结束(中心->战区数据服)
  263. function WL_JJC_NEWLADDER_CANCEL_FIGHT_END_C2D(msg)
  264. JjcNewLogic.JjcNewLadderLogic_FightEnd(msg)
  265. end
  266. -- 战斗结束(中心 -> 普通)
  267. function WL_JJC_NEWLADDER_CANCEL_FIGHT_END_C2O(msg)
  268. JjcNewLogic.JjcNewLadderLogic_FightEndOK(msg)
  269. end
  270. function WL_JJC_NEWLADDER_SEND_MAIL_C2O(msg)
  271. JjcNewLogic.JjcNewLadderLogic_SendFailMailOK(msg)
  272. end
  273. function WL_JJC_NEWLADDER_SEND_RANK_PRIZE_C2O(msg)
  274. JjcNewLogic.JjcNewLadderLogic_SendPrizeMail(msg)
  275. end