ChongJiLogic.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. -- 成神之路-冲级奖励
  2. local Util = require("common.Util")
  3. local CommonDB = require("common.CommonDB")
  4. local OpenActExcel = require("excel.openAct")
  5. local Msg = require("core.Msg")
  6. local BagLogic = require("bag.BagLogic")
  7. local Grid = require("bag.Grid")
  8. local OpenAct = require("present.OpenAct")
  9. local YunYingLogic = require("yunying.YunYingLogic")
  10. local PanelDefine = require("broadcast.PanelDefine")
  11. local GuideLogic = require("guide.GuideLogic")
  12. local MSGMAXLEN = 20 -- GC_PRESENT_CHONGJI_QUERY 协议 一次下发数据长度
  13. function getLeftTime()
  14. return 0
  15. end
  16. function isOpen()
  17. return true
  18. end
  19. function query(human)
  20. if isOpen(human) ~= true then
  21. return
  22. end
  23. -- local chongJi = human.db.chongJi or {}
  24. -- local msgRet = Msg.gc.GC_PRESENT_CHONGJI_QUERY
  25. -- msgRet.lv = human.db.lv
  26. -- for i = 1, #OpenActExcel.chongJi do
  27. -- local config = OpenActExcel.chongJi[i]
  28. -- msgRet.list[i].id = i
  29. -- msgRet.list[i].maxLv = config.lv
  30. -- msgRet.list[i].desc = Util.format(config.desc, config.lv)
  31. -- msgRet.list[i].state = 0
  32. -- if chongJi[i] then msgRet.list[i].state = 1 end
  33. -- for j = 1, #config.reward do
  34. -- local itemID = config.reward[j][1]
  35. -- local itemCnt = config.reward[j][2]
  36. -- Grid.makeItem(msgRet.list[i].item[j], itemID, itemCnt)
  37. -- end
  38. -- msgRet.list[i].item[0] = #config.reward
  39. -- end
  40. -- msgRet.list[0] = #OpenActExcel.chongJi
  41. -- Msg.send(msgRet, human.fd)
  42. local allLen = #OpenActExcel.chongJi
  43. local allTimes = math.ceil(allLen / MSGMAXLEN)
  44. local realIndex = 1
  45. local chongJiCfg = OpenActExcel.chongJi
  46. local chongJi = human.db.chongJi or {}
  47. for k=1, allTimes do
  48. local msgRet = Msg.gc.GC_PRESENT_CHONGJI_QUERY
  49. local nowLen = allLen > MSGMAXLEN and MSGMAXLEN or allLen
  50. msgRet.list[0] = nowLen
  51. msgRet.lv = human.db.lv
  52. msgRet.isEnd = k < allTimes and 0 or 1
  53. for i = 1, nowLen do
  54. local config = chongJiCfg[realIndex]
  55. msgRet.list[i].id = realIndex
  56. msgRet.list[i].maxLv = config.lv
  57. msgRet.list[i].desc = Util.format(config.desc, config.lv)
  58. msgRet.list[i].state = 0
  59. if chongJi[realIndex] then
  60. msgRet.list[i].state = 1
  61. end
  62. for j = 1, #config.reward do
  63. local itemID = config.reward[j][1]
  64. local itemCnt = config.reward[j][2]
  65. Grid.makeItem(msgRet.list[i].item[j], itemID, itemCnt)
  66. end
  67. msgRet.list[i].item[0] = #config.reward
  68. realIndex = realIndex + 1
  69. end
  70. Msg.send(msgRet,human.fd)
  71. allLen = allLen - MSGMAXLEN
  72. end
  73. end
  74. function getChongJiReward(human, id)
  75. if isOpen(human) ~= true then
  76. return
  77. end
  78. local config = OpenActExcel.chongJi[id]
  79. if not config then return end
  80. if human.db.lv < config.lv then return end
  81. local chongJi = human.db.chongJi or {}
  82. if chongJi[id] then
  83. return
  84. end
  85. -- 改db
  86. human.db.chongJi = human.db.chongJi or {}
  87. human.db.chongJi[id] = 1
  88. BagLogic.addItemList(human, config.reward, "chongJi")
  89. query(human)
  90. for k, v in pairs(funcID) do
  91. YunYingLogic.updateIcon(YYInfo[k], human)
  92. YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3505)
  93. break
  94. end
  95. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_LEVEL_GIFT)
  96. end
  97. function isRed(human)
  98. local lv = human.db.lv
  99. local chongJi = human.db.chongJi or {}
  100. for i, config in ipairs(OpenActExcel.chongJi) do
  101. if lv >= config.lv and not chongJi[i] then
  102. return true
  103. end
  104. end
  105. end
  106. function onLevelUp(human)
  107. for k, v in pairs(funcID) do
  108. YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3505)
  109. break
  110. end
  111. end