DoubleChargeLogic.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. --[[
  2. human.db.absAct[id] = {
  3. [buyID] = cnt buyID 对应限购次数
  4. }
  5. ]]
  6. local AbsActLogic = require("absAct.AbsActLogic")
  7. local AbsActExcel = require("excel.absAct")
  8. local BuyExcel = require("excel.buy")
  9. local BuyLogic = require("topup.BuyLogic")
  10. local SpecialCustomLogic = require("absAct.SpecialCustomLogic")
  11. local SevenDayLogic = require("absAct.SevenDayLogic")
  12. local DrumBlastingLogic = require("absAct.DrumBlastingLogic")
  13. function isOpen(human, YYInfo, funcConfig)
  14. local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  15. if not state then return end
  16. local absAct = human.db.absAct[funcConfig.funcID]
  17. if absAct and absAct.dayCnt and absAct.dayCnt <= 0 and #absAct.item <= 0 then
  18. return false
  19. end
  20. return true, endTime, startTime
  21. end
  22. function isActive(human, YYInfo, funcConfig)
  23. return not isOpen(human, YYInfo, funcConfig)
  24. end
  25. -- 获得剩余双倍次数
  26. function getDoubleCnt(human, funcID, buyID)
  27. local config = AbsActExcel.absActivity[funcID]
  28. if not config then return 0 end
  29. local doubleConfig = AbsActExcel.doubleCharge[config.actId]
  30. if not doubleConfig then return 0 end
  31. if not doubleConfig.buyId[buyID] then return 0 end
  32. AbsActLogic.checkAbsActClean(human, funcID)
  33. local absAct = human.db.absAct[funcID]
  34. if not absAct then
  35. return 0
  36. end
  37. local buyItemConfig = BuyExcel.buy[buyID]
  38. -- 不是充值,则返回
  39. if buyItemConfig.cmd ~= "topup" then
  40. return 0
  41. end
  42. absAct.buyID = absAct.buyID or {}
  43. absAct.buyID[buyID] = absAct.buyID[buyID] or 2
  44. return absAct.buyID[buyID]
  45. end
  46. -- 0点重置
  47. function updateDaily(human, funcID)
  48. local state, endTime, starTime = AbsActLogic.isStarted(human, funcID)
  49. if not state then return end
  50. local config = AbsActExcel.absActivity[funcID]
  51. if not config then return end
  52. local doubleConfig = AbsActExcel.doubleCharge[config.actId]
  53. if not doubleConfig then return 0 end
  54. -- 过0点则设置为2次双倍
  55. AbsActLogic.checkAbsActClean(human, funcID)
  56. local absAct = human.db.absAct[funcID]
  57. for buyID,_ in pairs(doubleConfig.buyId) do
  58. absAct.buyID = {}
  59. absAct.buyID[buyID] = 2
  60. end
  61. end
  62. -- 回调
  63. -- 从yunyinglogic 里面调用,故无需判断活动是否开起
  64. --
  65. function buyCall(human,id,buyID)
  66. local absAct = human.db.absAct[id]
  67. absAct.buyID = absAct.buyID or {}
  68. absAct.buyID[buyID] = absAct.buyID[buyID] or 2
  69. absAct.buyID[buyID] = absAct.buyID[buyID] - 1
  70. end