HeroLoginPickLogic.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. -- 英灵传说
  2. local AbsActExcel = require("excel.absAct")
  3. local Lang = require("common.Lang")
  4. local Util = require("common.Util")
  5. local Msg = require("core.Msg")
  6. local Broadcast = require("broadcast.Broadcast")
  7. local Grid = require("bag.Grid")
  8. local BagLogic = require("bag.BagLogic")
  9. local ItemDefine = require("bag.ItemDefine")
  10. local AbsActDefine = require("absAct.AbsActDefine")
  11. local AbsActLogic = require("absAct.AbsActLogic")
  12. local YunYingLogic = require("yunying.YunYingLogic")
  13. local HeroGrid = require("hero.HeroGrid")
  14. local PanelDefine = require("broadcast.PanelDefine")
  15. local HeroDefine = require("hero.HeroDefine")
  16. function query(human, id)
  17. local absConfig = AbsActExcel.absActivity[id]
  18. local config = AbsActExcel.heroLoginPick[absConfig.actId]
  19. if not config then return end
  20. AbsActLogic.checkAbsActClean(human, id)
  21. local absAct = human.db.absAct[id]
  22. local msgRet = Msg.gc.GC_ABS_ACT_HERO_LOGIN_PICK_QUERY
  23. msgRet.openDay = Util.diffDay(absConfig.realStartTime) + 1
  24. local heroCnt = 0
  25. for k, v in ipairs(config.items) do
  26. Grid.makeItem(msgRet.items[k], v[1], v[2])
  27. if HeroDefine.isHero(v[1]) then
  28. heroCnt = heroCnt + 1
  29. HeroGrid.makeHeroSimpleByID(msgRet.heroSimple[heroCnt], v[1])
  30. end
  31. end
  32. msgRet.itemGet = absAct.itemGet and 1 or 0
  33. msgRet.get[0] = 0
  34. for k, v in ipairs(config.loginReward) do
  35. Grid.makeItem(msgRet.login[k], v[1], v[2])
  36. if absAct[k] then
  37. msgRet.get[0] = msgRet.get[0] + 1
  38. msgRet.get[msgRet.get[0]] = k
  39. end
  40. end
  41. msgRet.heroSimple[0] = heroCnt
  42. msgRet.items[0] = #config.items
  43. msgRet.login[0] = #config.loginReward
  44. Msg.send(msgRet,human.fd)
  45. end
  46. function get(human, type, id, param)
  47. local state= AbsActLogic.isStarted(human, id)
  48. if not state then return end
  49. AbsActLogic.checkAbsActClean(human, id)
  50. local absAct = human.db.absAct[id]
  51. local absConfig = AbsActExcel.absActivity[id]
  52. local config = AbsActExcel.heroLoginPick[absConfig.actId]
  53. if not config then return end
  54. local day = Util.diffDay(absConfig.realStartTime) + 1
  55. if type == 0 then
  56. day = day > #config.loginReward and #config.loginReward or day
  57. BagLogic.cleanMomentItemList()
  58. local len = 0
  59. for i = 1, day do
  60. if not absAct[i] then
  61. absAct[i] = 1
  62. len = len + 1
  63. BagLogic.updateMomentItem(BagLogic.ADDITEM_TYPE_1, config.loginReward[i][1], config.loginReward[i][2])
  64. end
  65. end
  66. if len > 0 then
  67. BagLogic.addMomentItemList(human, "abs_loginpick")
  68. end
  69. else
  70. if day < #config.loginReward then
  71. return
  72. end
  73. if absAct.itemGet then return end
  74. absAct.itemGet = 1
  75. BagLogic.cleanMomentItemList()
  76. BagLogic.updateMomentItem(BagLogic.ADDITEM_TYPE_1, config.items[param][1], config.items[param][2])
  77. BagLogic.addMomentItemList(human, "abs_loginpick")
  78. end
  79. query(human, id)
  80. YunYingLogic.sendBanner(human)
  81. YunYingLogic.updateIcon(YYInfo[id], human)
  82. YunYingLogic.sendGroupUpdate(YYInfo[id], human, PanelDefine.PANEL_ID_3708)
  83. end
  84. function isRed(human, YYInfo, funcConfig)
  85. local state = AbsActLogic.isStarted(human, funcConfig.funcID)
  86. if not state then return end
  87. local absConfig = AbsActExcel.absActivity[funcConfig.funcID]
  88. local config = AbsActExcel.heroLoginPick[absConfig.actId]
  89. local absAct = human.db.absAct[funcConfig.funcID]
  90. if not absAct then return true end
  91. local day = Util.diffDay(absConfig.realStartTime) + 1
  92. day = day > #config.loginReward and #config.loginReward or day
  93. for i = 1, day do
  94. if not absAct[i] then
  95. return true
  96. end
  97. end
  98. if day >= #config.loginReward then
  99. if not absAct.itemGet then
  100. return true
  101. end
  102. end
  103. end
  104. function isActive(human, YYInfo, funcConfig)
  105. return not isOpen(human, YYInfo, funcConfig)
  106. end
  107. function isOpen(human, YYInfo, funcConfig)
  108. return AbsActLogic.isStarted(human, funcConfig.funcID)
  109. end