ChongJiLogic.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. function getLeftTime()
  13. return 0
  14. end
  15. function isOpen()
  16. return true
  17. end
  18. function query(human)
  19. if isOpen(human) ~= true then
  20. return
  21. end
  22. local chongJi = human.db.chongJi or {}
  23. local msgRet = Msg.gc.GC_PRESENT_CHONGJI_QUERY
  24. msgRet.lv = human.db.lv
  25. for i = 1, #OpenActExcel.chongJi do
  26. local config = OpenActExcel.chongJi[i]
  27. msgRet.list[i].id = i
  28. msgRet.list[i].maxLv = config.lv
  29. msgRet.list[i].desc = Util.format(config.desc, config.lv)
  30. msgRet.list[i].state = 0
  31. if chongJi[i] then msgRet.list[i].state = 1 end
  32. for j = 1, #config.reward do
  33. local itemID = config.reward[j][1]
  34. local itemCnt = config.reward[j][2]
  35. Grid.makeItem(msgRet.list[i].item[j], itemID, itemCnt)
  36. end
  37. msgRet.list[i].item[0] = #config.reward
  38. end
  39. msgRet.list[0] = #OpenActExcel.chongJi
  40. Msg.send(msgRet, human.fd)
  41. end
  42. function getChongJiReward(human, id)
  43. if isOpen(human) ~= true then
  44. return
  45. end
  46. local config = OpenActExcel.chongJi[id]
  47. if not config then return end
  48. if human.db.lv < config.lv then return end
  49. local chongJi = human.db.chongJi or {}
  50. if chongJi[id] then
  51. return
  52. end
  53. -- 改db
  54. human.db.chongJi = human.db.chongJi or {}
  55. human.db.chongJi[id] = 1
  56. BagLogic.addItemList(human, config.reward, "chongJi")
  57. query(human)
  58. for k, v in pairs(funcID) do
  59. YunYingLogic.updateIcon(YYInfo[k], human)
  60. YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3505)
  61. break
  62. end
  63. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_LEVEL_GIFT)
  64. end
  65. function isRed(human)
  66. local lv = human.db.lv
  67. local chongJi = human.db.chongJi or {}
  68. for i, config in ipairs(OpenActExcel.chongJi) do
  69. if lv >= config.lv and not chongJi[i] then
  70. return true
  71. end
  72. end
  73. end
  74. function onLevelUp(human)
  75. for k, v in pairs(funcID) do
  76. YunYingLogic.sendGroupUpdate(YYInfo[k], human, PanelDefine.PANEL_ID_3505)
  77. break
  78. end
  79. end