DailyFixedTaskLogic.lua 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. --[[
  2. absact = {
  3. task[id] = {
  4. state = 1
  5. cnt = 0
  6. }
  7. }
  8. ]]
  9. local AbsActLogic = require("absAct.AbsActLogic")
  10. local AbsActExcel = require("excel.absAct")
  11. local BuyExcel = require("excel.buy")
  12. local Util = require("common.Util")
  13. local Msg = require("core.Msg")
  14. local Grid = require("bag.Grid")
  15. local BagLogic = require("bag.BagLogic")
  16. local BuyLogic = require("topup.BuyLogic")
  17. local ObjHuman = require("core.ObjHuman")
  18. local Lang = require("common.Lang")
  19. local Broadcast = require("broadcast.Broadcast")
  20. local MailManager = require("mail.MailManager")
  21. local MailExcel = require("excel.mail")
  22. local YunYingLogic = require("yunying.YunYingLogic")
  23. local CycleActivityLogic = require("yunying.CycleActivity")
  24. function isOpen(human, YYInfo, funcConfig)
  25. -- local state, endTime, startTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  26. local state, endTime, startTime = CycleActivityLogic.isStarted(human, funcConfig.funcID)
  27. if not state then return end
  28. --[[
  29. local absAct = human.db.absAct[funcConfig.funcID]
  30. if not absAct then
  31. return
  32. end
  33. ]]
  34. return true, endTime, startTime
  35. end
  36. function isActive(human, YYInfo, funcConfig)
  37. return not isOpen(human, YYInfo, funcConfig)
  38. end
  39. function fontDailyFixedTask(db,config,net,id)
  40. net.state = db.task and (db.task[id] and db.task[id].state or 0) or 0
  41. net.nowCnt = db.task and (db.task[id] and db.task[id].cnt or 0) or 0
  42. net.needCnt = config.needCnt
  43. net.desc = config.desc
  44. net.day = config.day
  45. net.giftId = id
  46. local len = #config.item
  47. for i = 1,len do
  48. Grid.makeItem(net.item[i],config.item[i][1],config.item[i][2])
  49. end
  50. net.item[0] = len
  51. end
  52. function getAndSendMsg(human,id)
  53. -- 判断活动是否开启
  54. -- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  55. local state, endTime, starTime = CycleActivityLogic.isStarted(human, id)
  56. if not state then return end
  57. local absConfig = AbsActExcel.absActivity[id]
  58. if not absConfig then return end
  59. local absAct = human.db.absAct[id]
  60. if not absAct then
  61. return
  62. end
  63. local nowDay = Util.diffDay(starTime) + 1
  64. local config = AbsActExcel.dailyFixedTask
  65. local msgRet = Msg.gc.GC_ABS_DAILY_FIXED_TASK_QUERY
  66. local len = #config
  67. local count = 0
  68. for i = 1,len do
  69. if config[i].day == nowDay and config[i].actId == absConfig.actId then
  70. count = count + 1
  71. local net = msgRet.netList[count]
  72. fontDailyFixedTask(absAct,config[i],net,i)
  73. end
  74. end
  75. msgRet.netList[0] = count
  76. Msg.send(msgRet,human.fd)
  77. end
  78. function getItem(human,id,giftId)
  79. -- 判断活动是否开启
  80. -- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  81. local state, endTime, starTime = CycleActivityLogic.isStarted(human, id)
  82. if not state then return end
  83. local absConfig = AbsActExcel.absActivity[id]
  84. if not absConfig then return end
  85. local absAct = human.db.absAct[id]
  86. if not absAct then
  87. return
  88. end
  89. local nowDay = Util.diffDay(starTime) + 1
  90. local config = AbsActExcel.dailyFixedTask[giftId]
  91. if not config or config.day ~= nowDay or config.actId ~= absConfig.actId then
  92. return
  93. end
  94. if absAct.task and absAct.task[giftId] and absAct.task[giftId].state == 2 then
  95. return
  96. end
  97. absAct.task = absAct.task or {}
  98. absAct.task[giftId] = absAct.task[giftId] or {}
  99. absAct.task[giftId].state = 2
  100. BagLogic.addItemList(human, config.item, "dailyFixedTask")
  101. getAndSendMsg(human,id)
  102. YunYingLogic.sendBanner(human)
  103. YunYingLogic.updateIcon(YYInfo[id], human)
  104. YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
  105. end
  106. function onLogin(human,funcID)
  107. taskActive(human, 1, funcID,1)
  108. --特殊处理下活动没开前充值、完成了活跃度任务,任务开启后没玩法完成
  109. local nowHuoYue = human.db.dailyTask.nowHuoYue or 0
  110. if nowHuoYue > 0 then
  111. specailFunc(human, 2, funcID, nowHuoYue)
  112. end
  113. local topupAcountDaily = human.db.topupAcountDaily
  114. if topupAcountDaily and topupAcountDaily > 0 then
  115. specailFunc(human, 3, funcID, topupAcountDaily)
  116. end
  117. end
  118. function onCharge(human,parameter,funcID)
  119. taskActive(human, 3, funcID,parameter)
  120. end
  121. function onDailyTask(human,funcID, parameter)
  122. taskActive(human, 2, funcID,parameter)
  123. end
  124. function onZhanBuBuyCard(human, funcID, parameter)
  125. taskActive(human, 4, funcID, parameter)
  126. end
  127. --特殊处理下活动没开前充值、完成了活跃度任务,任务开启后没玩法完成
  128. function specailFunc(human, type, id, cnt)
  129. -- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  130. local state, endTime, starTime = CycleActivityLogic.isStarted(human, id)
  131. if not state then return end
  132. local absConfig = AbsActExcel.absActivity[id]
  133. if not absConfig then return end
  134. -- AbsActLogic.checkAbsActClean(human, id)
  135. local absAct = human.db.absAct[id]
  136. if not absAct then
  137. return
  138. end
  139. absAct.task = absAct.task or {}
  140. local nowDay = Util.diffDay(starTime) + 1
  141. local config = AbsActExcel.dailyFixedTask
  142. local len = #config
  143. for i = 1,len do
  144. if config[i].day == nowDay and config[i].actId == absConfig.actId and type == config[i].type then
  145. absAct.task[i] = absAct.task[i] or {}
  146. absAct.task[i].cnt = absAct.task[i].cnt or 0
  147. if absAct.task[i].state and absAct.task[i].cnt > 0 then --只处理一次
  148. break
  149. end
  150. absAct.task[i].cnt = cnt
  151. --absAct.task[i].cnt = absAct.task[i].cnt + cnt
  152. if absAct.task[i].cnt >= config[i].needCnt then
  153. absAct.task[i].state = 1
  154. break
  155. end
  156. end
  157. end
  158. YunYingLogic.sendBanner(human)
  159. YunYingLogic.updateIcon(YYInfo[id], human)
  160. YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
  161. end
  162. -- 每日任务激活
  163. function taskActive(human, type, id, cnt)
  164. -- local state, endTime, starTime = AbsActLogic.isStarted(human, id)
  165. local state, endTime, starTime = CycleActivityLogic.isStarted(human, id)
  166. if not state then return end
  167. local absConfig = AbsActExcel.absActivity[id]
  168. if not absConfig then return end
  169. -- AbsActLogic.checkAbsActClean(human, id)
  170. local absAct = human.db.absAct[id]
  171. if not absAct then
  172. return
  173. end
  174. absAct.task = absAct.task or {}
  175. local nowDay = Util.diffDay(starTime) + 1
  176. local config = AbsActExcel.dailyFixedTask
  177. local len = #config
  178. for i = 1,len do
  179. if config[i].day == nowDay and config[i].actId == absConfig.actId and type == config[i].type then
  180. absAct.task[i] = absAct.task[i] or {}
  181. absAct.task[i].cnt = absAct.task[i].cnt or 0
  182. if absAct.task[i].state then
  183. break
  184. end
  185. absAct.task[i].cnt = absAct.task[i].cnt + cnt
  186. if absAct.task[i].cnt >= config[i].needCnt then
  187. absAct.task[i].state = 1
  188. break
  189. end
  190. end
  191. end
  192. YunYingLogic.sendBanner(human)
  193. YunYingLogic.updateIcon(YYInfo[id], human)
  194. YunYingLogic.sendGroupUpdate(YYInfo[id], human, absConfig.panelID)
  195. end
  196. function isRed(human, YYInfo, funcConfig)
  197. -- local state,endTime,starTime = AbsActLogic.isStarted(human, funcConfig.funcID)
  198. local state,endTime,starTime = CycleActivityLogic.isStarted(human, funcConfig.funcID)
  199. if not state then return end
  200. local absConfig = AbsActExcel.absActivity[funcConfig.funcID]
  201. local absAct = human.db.absAct[funcConfig.funcID]
  202. if not absAct then return end
  203. if not absAct.task then
  204. return
  205. end
  206. local config = AbsActExcel.dailyFixedTask
  207. local nowDay = Util.diffDay(starTime) + 1
  208. for k,v in pairs(absAct.task) do
  209. if v.state == 1 and config[k].actId == absConfig.actId and config[k].day == nowDay then
  210. return true
  211. end
  212. end
  213. return false
  214. end