MonthHecJuex.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. -- 月度活动 合成与觉醒 百炼成神
  2. -- human.db.actMonthTask.hecheng
  3. local Util = require("common.Util")
  4. local Msg = require("core.Msg")
  5. local ObjHuman = require("core.ObjHuman")
  6. local MonthactExcel = require("excel.monthAct")
  7. local MailExcel = require("excel.mail")
  8. local HeroExcel = require("excel.hero").hero
  9. local Grid = require("bag.Grid")
  10. local MonthActFill = require("monthAct.MonthDataFill")
  11. local MonthActLogic = require("monthAct.MonthActLogic")
  12. local MailManager = require("mail.MailManager")
  13. local YunYingLogic = require("yunying.YunYingLogic")
  14. MONTHACT_HCJX_TYPE_1 = 1 -- 合成任务
  15. MONTHACT_HCJX_TYPE_2 = 2 -- 觉醒任务
  16. local function getNowValue(human, id)
  17. if not human.db.actMonthTask or
  18. not human.db.actMonthTask.hecheng then
  19. return 0
  20. end
  21. return human.db.actMonthTask.hecheng[id] or 0
  22. end
  23. local function setNowValue(human, id, value)
  24. human.db.actMonthTask = human.db.actMonthTask or {}
  25. human.db.actMonthTask.hecheng = human.db.actMonthTask.hecheng or {}
  26. human.db.actMonthTask.hecheng[id] = value
  27. end
  28. function query(human)
  29. local msgRet = Msg.gc.GC_MONTHACT_HCJX_QUERY
  30. msgRet.leftTime = MonthActLogic.getActLeftTime(human)
  31. msgRet.list[0] = #MonthactExcel.hecheng
  32. for id, cf in ipairs(MonthactExcel.hecheng) do
  33. MonthActFill.makeMonthTaskData(msgRet.list[id], cf, id)
  34. msgRet.list[id].cur = getNowValue(human, id)
  35. end
  36. --Msg.trace(msgRet)
  37. Msg.send(msgRet, human.fd)
  38. end
  39. --合成觉醒活动 计数入口 Ex 之前
  40. function addMonthHecheJuexCntEx(human, hcType, star, heroID)
  41. -- 检查任务类型是否非法
  42. if not hcType then return end
  43. MonthActLogic.checkActEndTime(human)
  44. star = star or 0
  45. for id, cf in ipairs(MonthactExcel.hecheng) do
  46. if cf.type == hcType and star == cf.special then
  47. addMonthHecheJuexCnt(human, id, heroID)
  48. break
  49. end
  50. end
  51. end
  52. function addMonthHecheJuexCnt(human, id, heroID)
  53. --检查id是否非法
  54. local cf = MonthactExcel.hecheng[id]
  55. if not cf then return end
  56. local oldStep = getNowValue(human, id)
  57. -- 已经达到完成上限
  58. if oldStep >= cf.taskCnt then return end
  59. local newStep = oldStep + 1
  60. setNowValue(human, id, newStep)
  61. ObjHuman.save(human)
  62. --完成一次 发放奖励一次
  63. local mailId = 0
  64. if cf.type == MONTHACT_HCJX_TYPE_1 then
  65. mailId = 13
  66. elseif cf.type == MONTHACT_HCJX_TYPE_2 then
  67. mailId = 14
  68. end
  69. if mailId == 0 then return end
  70. local heroConfig = HeroExcel[heroID]
  71. local heroName = heroConfig and heroConfig.name or ""
  72. local title = MailExcel.mail[mailId].title
  73. local content = Util.format(MailExcel.mail[mailId].content, cf.special, heroName)
  74. local senderName = MailExcel.mail[mailId].senderName
  75. MailManager.add(MailManager.SYSTEM, human.db._id, title, content, cf.reward, senderName)
  76. for k, v in pairs(funcID) do
  77. YunYingLogic.updateIcon(YYInfo[k], human)
  78. break
  79. end
  80. end
  81. -- GM
  82. function addCntByGm(human,type,heroId, num)
  83. if not num or not type or not heroId then
  84. return
  85. end
  86. local heroConfig = HeroExcel[heroId]
  87. if not heroConfig then return end
  88. for i= 1,num do
  89. addMonthHecheJuexCntEx(human, type, heroConfig.star , heroId)
  90. end
  91. end
  92. --[[
  93. function isRed(human)
  94. for id, cf in pairs(MonthactExcel.hecheng) do
  95. -- 已经达到完成上限
  96. if getNowValue(human, id) < cf.taskCnt then
  97. return true
  98. end
  99. end
  100. end
  101. --]]