AbsJifenDrawLogic.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. -- ABS 积分召唤活动
  2. local Config = require("Config")
  3. local AbsActExcel = require("excel.absAct")
  4. local Lang = require("common.Lang")
  5. local Util = require("common.Util")
  6. local Msg = require("core.Msg")
  7. local AbsActDefine = require("absAct.AbsActDefine")
  8. local ObjHuman = require("core.ObjHuman")
  9. local Broadcast = require("broadcast.Broadcast")
  10. local MangHeLogic = require("absAct.MangHeLogic")
  11. local MailExcel = require("excel.mail")
  12. local MailManager = require("mail.MailManager")
  13. local CommonDB = require("common.CommonDB")
  14. local AbsActLogic = require("absAct.AbsActLogic")
  15. local HeroGrid = require("hero.HeroGrid")
  16. local DrawCardLogic = require("drawCard.DrawCardLogic")
  17. local Log = require("common.Log")
  18. local HeroBook = require("hero.HeroBook")
  19. local HeroExcel = require("excel.hero")
  20. local HeroLogic = require("hero.HeroLogic")
  21. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  22. function isOpen(human, YYInfo, funcConfig)
  23. return AbsActLogic.isStarted(human, funcConfig.funcID)
  24. end
  25. function isActive(human, YYInfo, funcConfig)
  26. return not isOpen(human, YYInfo, funcConfig)
  27. end
  28. function isRed(human, YYInfo, funcConfig)
  29. return false
  30. end
  31. function getAndSendMsg(human, id, config)
  32. local absAct = human.db.absAct[id]
  33. if not absAct then
  34. print("not found human.db.absAct")
  35. return
  36. end
  37. local actId = config.actId
  38. local msgRet = Msg.gc.GC_ABS_ACT_JIFEN_DRAW_QUERY
  39. local jifenDrawConfig = AbsActExcel.absJifenDraw[actId]
  40. if not jifenDrawConfig then
  41. print("not found jifenDrawConfig",actId)
  42. return
  43. end
  44. local len = 0
  45. for k, config in ipairs(jifenDrawConfig.heroList) do
  46. len = len + 1
  47. if len > #msgRet.list then
  48. break
  49. end
  50. local net = msgRet.list[len]
  51. if net then
  52. net.id = k
  53. net.cur = absAct[k] or 0
  54. net.max = config[3]
  55. net.cost = config[2]
  56. HeroGrid.makeHeroSimpleByID(net.hero, config[1])
  57. end
  58. end
  59. msgRet.list[0] = len
  60. msgRet.randomCost = DrawCardLogic.MAX_JIFEN
  61. msgRet.curJifen = DrawCardLogic.getJifen(human)
  62. Msg.send(msgRet, human.fd)
  63. end
  64. -- 积分购买
  65. function buy(human, id, actID)
  66. local state,endTime, starTime = AbsActLogic.isStarted(human, actID)
  67. if not state then return end
  68. local config = AbsActExcel.absActivity[actID]
  69. if not config then return end
  70. local jifenDrawConfig = AbsActExcel.absJifenDraw[config.actId]
  71. if not jifenDrawConfig then return end
  72. local absAct = human.db.absAct[actID]
  73. if not absAct then
  74. return
  75. end
  76. local heroConfig = jifenDrawConfig.heroList[id]
  77. if not heroConfig then return end
  78. -- 扣除积分
  79. if DrawCardLogic.getJifen(human) < heroConfig[2] then
  80. return Broadcast.sendErr(human, Lang.DRAWCARD_ERR_NOJIFEN)
  81. end
  82. absAct[id] = absAct[id] or 0
  83. if absAct[id] >= heroConfig[3] then
  84. return
  85. end
  86. DrawCardLogic.updateJifen(human, -heroConfig[2])
  87. absAct[id] = absAct[id] + 1
  88. local heroID = heroConfig[1]
  89. local drawConfig = HeroExcel.hero[heroID]
  90. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE4, drawConfig.grade, heroID)
  91. local isNew = not HeroBook.isGet(human, drawConfig.id, drawConfig.star)
  92. local heroIndex, fenjielist = HeroLogic.addHero(human, heroID, nil, 1, "abs_jifenDraw")
  93. Log.write(Log.LOGID_OSS_DRAWCARD, human.db._id, human.db.account, human.db.name, human.db.lv, DrawCardLogic.DRAWCARD_ID4, heroID, 0, 0, 0, DrawCardLogic.getJifen(human))
  94. DrawCardLogic.sendDrawOp(human, DrawCardLogic.DRAWCARD_ID4, 0, {heroID}, fenjielist, {isNew}, {heroIndex}, AbsActDefine.ABS_ACT_TYPE_7)
  95. end