HeroMiddleLogic.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. --------------------------------
  2. -- 文件名 : HeroMiddleLogic.lua
  3. -- 文件说明 : 中心服获取玩家信息, 处理其他服务器获取跨服玩家信息
  4. -- 创建时间 : 2025/02/18
  5. -- 创建人 : FC
  6. --------------------------------
  7. local Util = require("common.Util")
  8. local ObjHuman = require("core.ObjHuman")
  9. local InnerMsg = require("core.InnerMsg")
  10. local ChatHandler = require("chat.Handler")
  11. local Config = require("Config")
  12. local Msg = require("core.Msg")
  13. local HeroLogic = require("hero.HeroLogic")
  14. local JjcLogic = require("jjc.JjcLogic")
  15. -- 请求聊天分享的英雄数据
  16. function HeroMiddleLogic_QueryHeroData_LW(human, uuid, heroIndex, nChatType, nServerIndex)
  17. if ChatHandler.CHAT_TYPE_MIDDLE ~= nChatType and ChatHandler.CHAT_TYPE_WARZONE ~= nChatType then
  18. return
  19. end
  20. local lwMsgRet = InnerMsg.lw.LW_MIDDLE_CHAT_GET_HERO_DATA
  21. lwMsgRet.nSrcServerID = Config.SVR_INDEX
  22. lwMsgRet.nDesServerID = nServerIndex
  23. lwMsgRet.nSrcUID = human.db._id
  24. lwMsgRet.nDesUID = uuid
  25. lwMsgRet.nHeroIndex = heroIndex
  26. lwMsgRet.nChatType = nChatType
  27. print("[HeroMiddleLogic_QueryHeroData_LW] 发送数据到中心服 nSrcServerID = "..lwMsgRet.nSrcServerID.." nDesServerID = "..lwMsgRet.nDesServerID)
  28. InnerMsg.sendMsg(0, lwMsgRet)
  29. end
  30. -- 获取玩家分享的英雄数据
  31. function HeroMiddleLogic_QueryHeroData_WL(fd, tMsgData)
  32. local sFindUID = tMsgData.nDesUID
  33. local nHeroIndex = tMsgData.nHeroIndex
  34. local tHeroData = Msg.gc.GC_HERO_SHARE_DATA
  35. local heroGrid, bagIndex, fakeHuman = HeroLogic.getHeroShareGrid(sFindUID, nHeroIndex)
  36. if heroGrid then
  37. if not HeroLogic.makeHeroShare(tHeroData.data, heroGrid, bagIndex, fakeHuman) then
  38. print("[HeroMiddleLogic_QueryHeroData_WL] 获取玩家数据失败")
  39. return
  40. end
  41. else
  42. local monsterID, mosnterLv = JjcLogic.getHeroShareMonster(sFindUID, nHeroIndex)
  43. if not monsterID then return end
  44. HeroLogic.makeHeroShareMonster(tHeroData.data, monsterID, mosnterLv)
  45. end
  46. local lwMsgRet = InnerMsg.lw.LW_MIDDLE_CHAT_GET_HERO_DATA
  47. lwMsgRet.nSrcUID = tMsgData.nSrcUID
  48. lwMsgRet.nSrcServerID = tMsgData.nSrcServerID
  49. lwMsgRet.tHeroData = tHeroData
  50. print("[HeroMiddleLogic_QueryHeroData_WL] 发送数据到中心服 nSrcServerID = "..lwMsgRet.nSrcServerID)
  51. InnerMsg.sendMsg(0, lwMsgRet)
  52. end
  53. function HeroMiddleLogic_GetHeroData_WL(fd, tMsgData)
  54. local nSrcUID = tMsgData.nSrcUID
  55. local human = ObjHuman.onlineUuid[nSrcUID]
  56. if not human then
  57. print("[HeroMiddleLogic_GetHeroData_WL] 玩家不在线直接返回")
  58. return
  59. end
  60. print("[HeroMiddleLogic_GetHeroData_WL] 获取到数据 nSrcServerID = ")
  61. table.print_lua_table(tMsgData)
  62. print("\n")
  63. local msgRet = Msg.gc.GC_HERO_SHARE_DATA
  64. msgRet.data = tMsgData.tHeroData.data
  65. if nil == _G.next(tMsgData.tHeroData.data.equips) then
  66. msgRet.data.equips[0] = 0
  67. end
  68. if nil == _G.next(tMsgData.tHeroData.data.fuWens) then
  69. msgRet.data.fuWens[0] = 0
  70. end
  71. if nil == _G.next(tMsgData.tHeroData.data.heroSimple.gemData) then
  72. msgRet.data.heroSimple.gemData[0] = 0
  73. end
  74. Msg.send(msgRet, human.fd)
  75. end