CopyManage.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. --副本列表
  2. local Lang = require("common.Lang")
  3. local Msg = require("core.Msg")
  4. local ObjHuman = require("core.ObjHuman")
  5. local FubenExcel = require("excel.copy").fuben
  6. local Grid = require("bag.Grid")
  7. local Broadcast = require("broadcast.Broadcast")
  8. local Util = require("common.Util")
  9. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  10. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  11. ID2COPYINFO = ID2COPYINFO or {} -- 对应副本id配置
  12. COPY_STATE_NORMAL = 0 -- 不显示倒计时
  13. COPY_STATE_OPEN = 1 -- 进行中,显示结束倒计时
  14. COPY_STATE_READY = 2 -- 准备中,显示开启倒计时
  15. function isOpen(CopyInfo, human)
  16. if not CopyInfo then
  17. return false
  18. end
  19. local systemID = CopyInfo.config.systemID
  20. if not RoleSystemLogic.isOpen(human, systemID) then
  21. return false, RoleSystemLogic.getOpenDesc(systemID)
  22. end
  23. return true
  24. end
  25. local function isRed(CopyInfo,human)
  26. if not isOpen(CopyInfo,human) then return end
  27. if not CopyInfo then return end
  28. if not CopyInfo.module then return end
  29. if not CopyInfo.module.isDot then return end
  30. return CopyInfo.module.isDot(human, CopyInfo)
  31. end
  32. local function getStartLeftTime(CopyInfo, human)
  33. if not CopyInfo then return end
  34. if not CopyInfo.module then return end
  35. if not CopyInfo.module.getStartLeftTime then return end
  36. return CopyInfo.module.getStartLeftTime(human)
  37. end
  38. local function getCopyState(CopyInfo, human)
  39. if not CopyInfo then return end
  40. if not CopyInfo.module then return end
  41. if not CopyInfo.module.getCopyState then return end
  42. return CopyInfo.module.getCopyState(human)
  43. end
  44. local function makeCopyList(human,copyID,CopyInfo,net)
  45. local config = CopyInfo.config
  46. net.id = copyID
  47. net.panelID = config.panelID
  48. net.bg = config.bg
  49. net.desc = config.desc
  50. net.lv = RoleSystemLogic.getOpenLv(config.systemID)
  51. net.showReward[0] = #config.showReward
  52. for i = 1, net.showReward[0] do
  53. local itemID = config.showReward[i][1]
  54. local itemCnt = config.showReward[i][2]
  55. Grid.makeItem(net.showReward[i], itemID, itemCnt)
  56. end
  57. net.isRed = isRed(CopyInfo, human) and 1 or 0
  58. net.startLefTime = getStartLeftTime(CopyInfo, human) or 0
  59. net.state = getCopyState(CopyInfo, human) or COPY_STATE_NORMAL
  60. end
  61. function CG_COPY_LIST_QUERY(human)
  62. local msgRet = Msg.gc.GC_COPY_LIST_QUERY
  63. msgRet.list[0] = 0
  64. local maxLen = #msgRet.list
  65. for copyID, CopyInfo in pairs(ID2COPYINFO) do
  66. if msgRet.list[0] >= maxLen then
  67. break
  68. end
  69. msgRet.list[0] = msgRet.list[0] + 1
  70. makeCopyList(human,copyID,CopyInfo,msgRet.list[msgRet.list[0]])
  71. end
  72. --Msg.trace(msgRet)
  73. Msg.send(msgRet,human.fd)
  74. end
  75. function initCopyInfo(copyID, config)
  76. local moduleFn = nil
  77. if config.moduleFn ~= "" then
  78. moduleFn = load("return require(\""..config.moduleFn.."\")")()
  79. end
  80. local CopyInfo = {}
  81. CopyInfo.copyID = copyID
  82. CopyInfo.module = moduleFn
  83. CopyInfo.config = config
  84. ID2COPYINFO[copyID] = CopyInfo
  85. if moduleFn then
  86. moduleFn.CopyInfo = CopyInfo -- 子模块默认变量
  87. end
  88. return CopyInfo
  89. end
  90. -- 初始化
  91. function init()
  92. ID2COPYINFO = {}
  93. for copyID, config in pairs(FubenExcel) do
  94. initCopyInfo(copyID, config)
  95. end
  96. end
  97. function isDot(human,config)
  98. for k, CopyInfo in pairs(ID2COPYINFO) do
  99. if config.id == RoleSystemDefine.ROLE_SYS_ID_1201 or config.id == RoleSystemDefine.ROLE_SYS_ID_1202 then
  100. if (config.id == RoleSystemDefine.ROLE_SYS_ID_1201 and CopyInfo.config.tier == 1) or
  101. (config.id == RoleSystemDefine.ROLE_SYS_ID_1202 and CopyInfo.config.tier == 2) then
  102. if isRed(CopyInfo, human) then
  103. return true
  104. end
  105. end
  106. else
  107. if isRed(CopyInfo, human) then
  108. return true
  109. end
  110. end
  111. end
  112. end
  113. ROLE_SYS_ID_1201 = 1201 -- 冒险界面-下层
  114. ROLE_SYS_ID_1202 = 1202 -- 冒险界面-上层