AbsActMoShouXiLian.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. local Config = require("Config")
  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 AbsActDefine = require("absAct.AbsActDefine")
  7. local ObjHuman = require("core.ObjHuman")
  8. local MoshouLogic = require("moshou.MoshouLogic")
  9. local AbsActLogic = require("absAct.AbsActLogic")
  10. local function initDB(human, funcID)
  11. local actDB = human.db.absAct[funcID]
  12. if not actDB then return end
  13. local config = AbsActExcel.absMoShouXiLian
  14. if not config then return end
  15. for k, v in ipairs(config) do
  16. actDB[v.buyid] = actDB[v.buyid] or {}
  17. actDB[v.buyid].cnt = actDB[v.buyid].cnt or v.number
  18. actDB[v.buyid].max = actDB[v.buyid].max or v.number
  19. end
  20. end
  21. --
  22. function isOpen(human, YYInfo, funcConfig)
  23. local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  24. if not state then return end
  25. local xilianOpen = MoshouLogic.xilianIsOpen(human)
  26. if xilianOpen == 1 then
  27. return true, endTime, startTime
  28. end
  29. end
  30. --
  31. function isRed(human, YYInfo, funcConfig)
  32. local config = AbsActExcel.absMoShouXiLian
  33. if not config then return end
  34. local actDB = human.db.absAct[funcConfig.funcID]
  35. if not actDB then return end
  36. for k, v in ipairs(config) do
  37. if actDB[v.buyid] and actDB[v.buyid].cnt and actDB[v.buyid].cnt > 0 then
  38. return true
  39. end
  40. end
  41. end
  42. --
  43. function isActive(human, YYInfo, funcConfig)
  44. return not isOpen(human, YYInfo, funcConfig)
  45. end
  46. --
  47. function onBuyLongXue(human, funcID, buyId)
  48. local absAct = human.db.absAct[funcID]
  49. if not absAct then return end
  50. -- 活动过期 没有双倍
  51. local state, endTime, startTime = AbsActLogic.isStarted(human, funcID)
  52. if not state then return end
  53. AbsActLogic.checkAbsActClean(human, funcID)
  54. initDB(human, funcID)
  55. if not absAct[buyId] then return end
  56. if absAct[buyId].cnt <= 0 then
  57. return
  58. end
  59. absAct[buyId].cnt = absAct[buyId].cnt - 1
  60. return true
  61. end
  62. --
  63. function onQueryLongXue(human, funcID, parameter)
  64. AbsActLogic.checkAbsActClean(human, funcID)
  65. initDB(human, funcID)
  66. return human.db.absAct[funcID]
  67. end
  68. --
  69. function updateDaily(human, funcID)
  70. local state, endTime, starTime = AbsActLogic.isStarted(human, funcID)
  71. if not state then return end
  72. local config = AbsActExcel.absActivity[funcID]
  73. if not config then return end
  74. local config = AbsActExcel.absMoShouXiLian
  75. if not config then return end
  76. AbsActLogic.checkAbsActClean(human, funcID)
  77. local actDB = human.db.absAct[funcID]
  78. for k, v in ipairs(config) do
  79. actDB[v.buyid] = nil
  80. end
  81. end