BattleDataNS.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. -- 用于普通服收到跨服通知上传战斗数据的处理
  2. local InnerMsg = require("core.InnerMsg")
  3. local CombatDefine = require("combat.CombatDefine")
  4. local CombatLogic = require("combat.CombatLogic")
  5. local MiddleDefine = require("middle.MiddleDefine")
  6. local CombatPosLogic = require("combat.CombatPosLogic")
  7. function CreateBattleData(fd, msg)
  8. local tMsgData = InnerMsg.lw.LW_COMBAT_DATA
  9. tMsgData.moduleTag = msg.moduleTag
  10. tMsgData.extraArgs = msg.extraArgs
  11. local playerUuid = msg.playerUuid
  12. local nCombatType = msg.nCombatType or CombatDefine.COMBAT_TYPE1
  13. local fakeHuman = CombatLogic.createCombatFakeHuman(playerUuid)
  14. if not fakeHuman then
  15. tMsgData.errCode = MiddleDefine.MIDDLE_GET_COMBAT_ERR_ONE
  16. print("[BattleDataNS] 没有获取到对应玩家")
  17. InnerMsg.sendMsg(0, tMsgData)
  18. return
  19. end
  20. -- local combatHero = CombatPosLogic.getCombatHeros(fakeHuman, CombatDefine.COMBAT_TYPE1, nil, true)
  21. local combatHero = CombatPosLogic.getCombatHeros(fakeHuman, nCombatType, nil, true)
  22. if not combatHero or not next(combatHero) then
  23. print("[BattleDataNS] 没有获取到对应玩家的英雄列表, 取默认战斗列表")
  24. combatHero = CombatPosLogic.getCombatHeros(fakeHuman, CombatDefine.COMBAT_TYPE1, nil, true)
  25. if not combatHero or not next(combatHero) then
  26. print("[BattleDataNS] 取默认战斗列表还是没有获取到英雄列表")
  27. tMsgData.errCode = MiddleDefine.MIDDLE_GET_COMBAT_ERR_TWO
  28. InnerMsg.sendMsg(0, tMsgData)
  29. return
  30. end
  31. end
  32. local moduleFn = CombatLogic.getModule(msg.combatType)
  33. if not moduleFn or not moduleFn.getCombatObjList then
  34. print("[BattleDataNS] 未实现的获取战斗对象函数")
  35. tMsgData.errCode = MiddleDefine.MIDDLE_GET_COMBAT_ERR_THREE
  36. InnerMsg.sendMsg(0, tMsgData)
  37. return
  38. else
  39. local args = {
  40. [1] = playerUuid
  41. }
  42. local objList, helpList, rolebase, formation,jiban, elfList = moduleFn.getCombatObjList(nil, CombatDefine.DEFEND_SIDE, args, msg.combatType)
  43. if objList then
  44. tMsgData.errCode = MiddleDefine.MIDDLE_GET_COMBAT_OK
  45. tMsgData.objList = objList
  46. tMsgData.helpList = helpList
  47. tMsgData.roleBase = rolebase
  48. tMsgData.formation = formation
  49. tMsgData.jiBan = jiban
  50. tMsgData.elfList = elfList or {}
  51. InnerMsg.sendMsg(0, tMsgData)
  52. else
  53. print("[BattleDataNS] 获取对战英雄列表失败")
  54. tMsgData.errCode = MiddleDefine.MIDDLE_GET_COMBAT_ERR_FOUR
  55. InnerMsg.sendMsg(0, tMsgData)
  56. return
  57. end
  58. end
  59. end