DrawCardLogic.lua 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  1. ---------------------------------------------------
  2. -- 召唤法阵
  3. -- drawCard = {jifen=0,list={[1]={},[2]={},[3]={},[4]={}}},--召唤法阵
  4. -- drawInfo = {time,cntHero,cntHero2,chengjiuCnt,isRaward}
  5. ---------------------------------------------------
  6. local ItemExcel = require("excel.item")
  7. local Msg = require("core.Msg")
  8. local ObjHuman = require("core.ObjHuman")
  9. local Util = require("common.Util")
  10. local Log = require("common.Log")
  11. local Grid = require("bag.Grid")
  12. local Broadcast = require("broadcast.Broadcast")
  13. local Lang = require("common.Lang")
  14. local CommonDefine = require("common.CommonDefine")
  15. local HeroDefine = require("hero.HeroDefine")
  16. local ItemDefine = require("bag.ItemDefine")
  17. local HeroLogic = require("hero.HeroLogic")
  18. local BagLogic = require("bag.BagLogic")
  19. local HeroGrid = require("hero.HeroGrid")
  20. local DrawCardExcel = require("excel.drawCard").drawCard
  21. local DrawCardV2Excel = require("excel.drawCard").drawCardV2
  22. local DrawLevelExcel = require("excel.drawCard").drawLevel
  23. local CampWeightExcel = require("excel.drawCard").campWeight
  24. local DrawCardActivityExcel = require("excel.drawCard").activity
  25. local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
  26. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  27. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  28. local HeroExcel = require("excel.hero").hero
  29. local MailExcel = require("excel.mail")
  30. local MailManager = require("mail.MailManager")
  31. local ChatPaoMaLogic = require("chat.ChatPaoMaLogic")
  32. local MonthSummon = require("monthAct.MonthSummon")
  33. local HeroBook = require("hero.HeroBook")
  34. local RoleDefine = require("role.RoleDefine")
  35. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  36. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  37. local GuideLogic = require("guide.GuideLogic")
  38. local RandomLogic = require("common.RandomLogic")
  39. local TuiSongLiBao = require("present.TuiSongLiBao")
  40. local MoshouLogic = require("moshou.MoshouLogic")
  41. local LiLianLogic = require("dailyTask.LiLianLogic")
  42. local ProjectLogic = require("platform.ProjectLogic")
  43. local SysParameter = require("common.SysParameter")
  44. local AbsActLogic = require("absAct.AbsActLogic")
  45. local AbsActDefine = require("absAct.AbsActDefine")
  46. local HeroUpLogic = require("absAct.HeroUpLogic")
  47. local PerpleHeroLogic = require("absAct.PerpleHeroLogic")
  48. local YunYingLogic = require("yunying.YunYingLogic")
  49. local PanelDefine = require("broadcast.PanelDefine")
  50. local VipLogic = require("vip.VipLogic")
  51. local MengxinLogic = require("present.MengxinLogic")
  52. local LimitPerpleHeroLogic = require("present.LimitPerpleHeroLogic")
  53. local HeroComeLogic = require("absAct.HeroComeLogic")
  54. local Log = require("common.Log")
  55. Json = Json or require("common.Json")
  56. DRAWCARD_ID0 = 0 -- 积分召唤
  57. DRAWCARD_ID1 = 1 -- 基础召唤
  58. DRAWCARD_ID2 = 2 -- 高级召唤
  59. DRAWCARD_ID3 = 3 -- 友情召唤
  60. DRAWCARD_ID4 = 4 -- 积分召唤权重
  61. DRAWCARD_ID5 = 5 -- 高级召唤十连抽必出
  62. DRAWCARD_ID6 = 6 -- 高级召唤单抽
  63. DRAWCARD_ID7 = 7 -- 40高抽必出SSR
  64. DRAWCARD_OP_1 = 1 -- 召唤1次
  65. DRAWCARD_OP_2 = 2 -- 召唤10次
  66. DRAWCARD_JIFEN_NEED_VIPLV = 3
  67. DRAWCARD_JIFEN_SHOW_ITEM = 801005
  68. MAX_JIFEN = 3000
  69. DRAWCARD_40 = 40 -- 40连抽,必得SSR
  70. -- 积分
  71. function getJifen(human)
  72. return human.db.drawCard.jifen
  73. end
  74. function updateJifen(human, d)
  75. human.db.drawCard.jifen = human.db.drawCard.jifen or 0
  76. human.db.drawCard.jifen = human.db.drawCard.jifen + d
  77. end
  78. -- 根据抽奖id获取相关信息
  79. function getDrawInfo(human, id)
  80. return human.db.drawCard.list[id]
  81. end
  82. -- 免费CD
  83. function getFreeInfo(human, id)
  84. if id ~= DRAWCARD_ID1 and id ~= DRAWCARD_ID2 then
  85. return 0, 0 --只有普通和高抽可以免费
  86. end
  87. local info = getDrawInfo(human, id)
  88. local config = DrawCardExcel[id]
  89. local leftCnt = 1
  90. local leftTime = 0
  91. if not info.time then
  92. return leftCnt, leftTime
  93. end
  94. leftTime = math.max(info.time - os.time(), 0)
  95. if leftTime > 1 then
  96. leftCnt = 0
  97. end
  98. return leftCnt, leftTime
  99. end
  100. -- 设置免费冷却CD
  101. function setUseFree(human, id)
  102. local info = getDrawInfo(human, id)
  103. if not info then return end
  104. local config = DrawCardExcel[id]
  105. info.time = Util.getDayStartTime(os.time()) + 86400
  106. end
  107. -- 可否买免费
  108. function isFree(human, id, op)
  109. if op ~= DRAWCARD_OP_1 then return end
  110. local leftCnt, leftTime = getFreeInfo(human, id)
  111. if leftCnt > 0 and leftTime < 1 then
  112. return true
  113. end
  114. end
  115. -- 10连次数
  116. function getDraw2Cnt(human, id)
  117. local info = getDrawInfo(human, id)
  118. if not info then return 0 end
  119. return info.cntHero2 or 0
  120. end
  121. function addDraw2Cnt(human, id, cnt)
  122. local info = getDrawInfo(human, id)
  123. if not info then return end
  124. info.cntHero2 = (info.cntHero2 or 0) + cnt
  125. end
  126. -- 单抽次数
  127. function getDrawCnt(human, id)
  128. local info = getDrawInfo(human, id)
  129. if not info then return 0 end
  130. return info.cntHero or 0
  131. end
  132. function addDrawCnt(human, id, cnt)
  133. local info = getDrawInfo(human, id)
  134. if not info then return end
  135. info.cntHero = (info.cntHero or 0) + cnt
  136. end
  137. function getDrawLv(human, id)
  138. local info = getDrawInfo(human, id)
  139. if not info then return 0 end
  140. return info.drawLV or 0
  141. end
  142. function getDrawV2Cnt(human, id)
  143. local info = getDrawInfo(human, id)
  144. if not info then return 0 end
  145. return info.cntHero3 or 0
  146. end
  147. function addDrawLv(human, id, cnt)
  148. local info = getDrawInfo(human, id)
  149. if not info then return end
  150. info.drawLV = info.drawLV or 0
  151. info.cntHero3 = (info.cntHero3 or 0) + cnt
  152. local drawLevel = DrawLevelExcel
  153. if not info then return end
  154. for lv, val in ipairs(drawLevel) do
  155. if info.cntHero3 >= val.need then
  156. info.drawLV = lv
  157. end
  158. end
  159. end
  160. function setSkip(human, id, skip)
  161. human.db.drawCard.skip = skip or 0
  162. end
  163. -- 连续1-4英雄次数
  164. function getDrawNoGoodCnt(human, id)
  165. local info = getDrawInfo(human, id)
  166. if not info then return 0 end
  167. return info.chengjiuCnt or 0
  168. end
  169. function addDrawNoGoodCnt(human, id, cnt)
  170. local info = getDrawInfo(human, id)
  171. if not info then return end
  172. info.chengjiuCnt = (info.chengjiuCnt or 0) + cnt
  173. end
  174. function getDrawNoSSRCnt(human, id)
  175. local info = getDrawInfo(human, id)
  176. if not info then return 0 end
  177. return info.leftSSRCnt or 0
  178. end
  179. function addDrawNoSSRCnt(human, id, cnt)
  180. local info = getDrawInfo(human, id, cnt)
  181. if not info then return end
  182. info.leftSSRCnt = (info.leftSSRCnt or 0) + cnt
  183. end
  184. function clearDrawNoSSRCnt(human, id)
  185. local info = getDrawInfo(human, id)
  186. if not info then return end
  187. info.leftSSRCnt = nil
  188. end
  189. function clearDrawNoGoodCnt(human, id)
  190. local info = getDrawInfo(human, id)
  191. if not info then return end
  192. info.chengjiuCnt = nil
  193. end
  194. -- 友情点
  195. function getFriendHeart(human)
  196. return human.db.friendHeart
  197. end
  198. function fontDrawCardNet(net, id, human)
  199. local config = DrawCardExcel[id]
  200. local leftCnt, leftTime = getFreeInfo(human, id)
  201. net.id = id
  202. net.leftFreeTime = leftTime
  203. net.leftFreeCnt = leftCnt
  204. net.items[0] = 0
  205. if config.item1[1] and config.item1[2] then
  206. net.items[0] = net.items[0] + 1
  207. Grid.makeItem(net.items[net.items[0]], config.item1[1], config.item1[2])
  208. end
  209. local vipArg = 100
  210. if id == DRAWCARD_ID2 then
  211. vipArg = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER21)
  212. end
  213. if config.item2[1] and config.item2[2] then
  214. net.items[0] = net.items[0] + 1
  215. Grid.makeItem(net.items[net.items[0]], config.item2[1], math.floor(config.item2[2] * vipArg / 100))
  216. end
  217. vipArg = 0
  218. if id == DRAWCARD_ID2 then
  219. vipArg = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER22)
  220. end
  221. net.zuanshi[0] = 2
  222. net.zuanshi[1] = config.zuanshi1
  223. net.zuanshi[2] = config.zuanshi2 + vipArg
  224. net.isFirst = (getDraw2Cnt(human, id) < 1) and 1 or 0
  225. net.canBuy = ItemExcel.buy[config.item1[1]] and 1 or 0
  226. end
  227. -- 三个抽奖列表
  228. function query(human)
  229. local msgRet = Msg.gc.GC_DRAWCARD_QUERY
  230. msgRet.jifen = getJifen(human)
  231. msgRet.left = getDrawNoSSRCnt(human, DRAWCARD_ID2)
  232. msgRet.leftNoSRRCnt = DRAWCARD_40 - getDrawNoSSRCnt(human, DRAWCARD_ID2)
  233. msgRet.list[0] = 0
  234. for id = DRAWCARD_ID1, DRAWCARD_ID3 do
  235. msgRet.list[0] = msgRet.list[0] + 1
  236. local net = msgRet.list[msgRet.list[0]]
  237. fontDrawCardNet(net, id, human)
  238. end
  239. local needItemID = ItemDefine.ITEM_XIANZHI_BAOZHU_ID
  240. Grid.makeItem(msgRet.qiyuan, needItemID, 1)
  241. msgRet.skip = human.db.drawCard.skip or 0
  242. -- 高级召唤v2需要返回
  243. msgRet.drawCnt = getDraw2Cnt(human,DRAWCARD_ID2)
  244. msgRet.drawLv = getDrawLv(human,DRAWCARD_ID2)
  245. Msg.send(msgRet, human.fd)
  246. end
  247. -- 抽奖结果
  248. function sendDrawOp(human, id, op, heroList, items, heroNewList, heroIndexList, isAct)
  249. local msgRet = Msg.gc.GC_DRAWCARD_OP
  250. msgRet.isAct = isAct or 0
  251. msgRet.leftNoSRRCnt = DRAWCARD_40 - getDrawNoSSRCnt(human, DRAWCARD_ID2)
  252. local dataNet = msgRet.data
  253. dataNet.jifen = getJifen(human)
  254. dataNet.id = id
  255. dataNet.op = op
  256. dataNet.heros[0] = heroList and #heroList or 0
  257. for i = 1, dataNet.heros[0] do
  258. local heroID = heroList[i]
  259. local isNew = heroNewList and heroNewList[i]
  260. local index = heroIndexList and heroIndexList[i]
  261. HeroGrid.makeHeroNice(dataNet.heros[i], heroID, nil, isNew, index)
  262. end
  263. dataNet.items[0] = 0
  264. if items and type(items) == "table" then
  265. for itemID, itemCnt in pairs(items) do
  266. dataNet.items[0] = dataNet.items[0] + 1
  267. Grid.makeItem(dataNet.items[dataNet.items[0]], itemID, itemCnt)
  268. end
  269. end
  270. fontDrawCardNet(msgRet.drawData, id, human)
  271. Msg.send(msgRet, human.fd)
  272. end
  273. -- 积分召唤
  274. local function jifenDraw(human, isAct)
  275. local config = DrawCardExcel[DRAWCARD_ID4]
  276. if not config then return end
  277. local db = human.db.drawCard
  278. if getJifen(human) < MAX_JIFEN then
  279. return Broadcast.sendErr(human, Lang.DRAWCARD_ERR_NOJIFEN)
  280. end
  281. if HeroLogic.getEmptyCnt(human) < 1 then
  282. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  283. end
  284. local heroID = randHeroID(human, DRAWCARD_ID4, DRAWCARD_OP_1, config)
  285. updateJifen(human, -MAX_JIFEN)
  286. local heroConfig = HeroExcel[heroID]
  287. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE4, heroConfig.grade, heroID)
  288. local isNew = not HeroBook.isGet(human, heroConfig.id, heroConfig.star)
  289. local heroIndex, fenjielist = HeroLogic.addHero(human, heroID, nil, 1, "draw_card")
  290. Log.write(Log.LOGID_OSS_DRAWCARD, human.db._id, human.db.account, human.db.name, human.db.lv, DRAWCARD_ID4, heroID, 0,
  291. 0, 0, db.jifen)
  292. sendDrawOp(human, DRAWCARD_ID4, 0, { heroID }, fenjielist, { isNew }, { heroIndex }, isAct)
  293. end
  294. -- 检查道具+扣道具
  295. function checkUseItem(human, id, op, config, isAct)
  296. local item = config["item" .. op]
  297. local zuanshi = config["zuanshi" .. op]
  298. if not item or not zuanshi then return end
  299. local itemID = item[1]
  300. local itemCnt = item[2]
  301. if id == DRAWCARD_ID2 and op == DRAWCARD_OP_2 then
  302. local vipArg = 100
  303. vipArg = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER21)
  304. print(" checkUseItem vipArg ", vipArg, " , old : ", itemCnt, " , new : ",
  305. math.floor(itemCnt * vipArg / 100))
  306. itemCnt = math.floor(itemCnt * vipArg / 100)
  307. end
  308. print(" checkUseItem itemID itemCnt ", itemID, itemCnt)
  309. -- 活动只扣道具
  310. if isAct == AbsActDefine.ABS_ACT_TYPE_4 then
  311. local state, id = AbsActLogic.isStartedByType(human, AbsActDefine.ABS_ACT_TYPE_4)
  312. if not state then
  313. return
  314. end
  315. local config = PerpleHeroLogic.getConfigByActID(id)
  316. itemID = config["item" .. op][1]
  317. itemCnt = config["item" .. op][2]
  318. if BagLogic.getItemCnt(human, itemID) >= itemCnt then -- 扣道具
  319. BagLogic.delItem(human, itemID, itemCnt, "draw_card")
  320. return true
  321. else
  322. return
  323. end
  324. elseif isAct == AbsActDefine.ABS_ACT_TYPE_19 then
  325. local state, id = AbsActLogic.isStartedByType(human, AbsActDefine.ABS_ACT_TYPE_19)
  326. if not state then
  327. return
  328. end
  329. local config = HeroComeLogic.getConfigByActID(id)
  330. itemID = config["item" .. op][1]
  331. itemCnt = config["item" .. op][2]
  332. if BagLogic.getItemCnt(human, itemID) >= itemCnt then -- 扣道具
  333. BagLogic.delItem(human, itemID, itemCnt, "draw_card")
  334. return true
  335. else
  336. return
  337. end
  338. elseif isAct == AbsActDefine.OA_ACT_TYPE_501 then
  339. local limitState = LimitPerpleHeroLogic.checkOpen()
  340. if not limitState then
  341. return
  342. end
  343. local config = LimitPerpleHeroLogic.getConfigByActID()
  344. itemID = config["item" .. op][1]
  345. itemCnt = config["item" .. op][2]
  346. if BagLogic.getItemCnt(human, itemID) >= itemCnt then -- 扣道具
  347. BagLogic.delItem(human, itemID, itemCnt, "draw_card")
  348. return true
  349. else
  350. return
  351. end
  352. end
  353. if isFree(human, id, op) then -- 免费
  354. setUseFree(human, id)
  355. return true
  356. elseif BagLogic.getItemCnt(human, itemID) >= itemCnt then -- 扣道具
  357. BagLogic.delItem(human, itemID, itemCnt, "draw_card")
  358. return true
  359. elseif zuanshi > 0 then -- 扣钻石
  360. -- 抵扣道具
  361. local haveCnt = BagLogic.getItemCnt(human, itemID)
  362. local vipArg = 0
  363. if id == DRAWCARD_ID2 and op == DRAWCARD_OP_2 then
  364. vipArg = VipLogic.getPowerArgs(human, VipLogic.VIP_POWER22)
  365. end
  366. zuanshi = zuanshi + vipArg
  367. if haveCnt > 0 then
  368. zuanshi = zuanshi - math.floor(zuanshi * haveCnt / itemCnt)
  369. zuanshi = zuanshi > 0 and zuanshi or 0
  370. end
  371. if not ObjHuman.checkRMB(human, zuanshi) then
  372. return
  373. end
  374. if haveCnt > 0 then
  375. BagLogic.delItem(human, itemID, haveCnt, "draw_card")
  376. end
  377. ObjHuman.decZuanshi(human, -zuanshi, "draw_card")
  378. return true
  379. end
  380. if zuanshi <= 0 then
  381. Broadcast.sendErr(human, Util.format(Lang.DRAWCARD_ERR_NOITEM, ItemDefine.getValue(itemID, "name")))
  382. end
  383. end
  384. --
  385. function randHeroID(human, id, op, config, actConfig, randomIndex, isAct)
  386. if isAct == 0 then
  387. if id == DRAWCARD_ID1 and op == DRAWCARD_OP_1 and getDrawCnt(human, id) == 0 then
  388. -- 首次普通单抽
  389. return SysParameter.getSysParameter(SysParameter.PARAMETER_6)
  390. elseif id == DRAWCARD_ID2 and op == DRAWCARD_OP_1 and getDrawCnt(human, id) == 0 then
  391. return SysParameter.getSysParameter(SysParameter.PARAMETER_7)
  392. end
  393. end
  394. if randomIndex and isAct == 0 then
  395. if id == DRAWCARD_ID2 and op == DRAWCARD_OP_2 then
  396. local sysHeroList = nil
  397. local draw2Cnt = getDraw2Cnt(human, id)
  398. draw2Cnt = math.floor(draw2Cnt / 10)
  399. if draw2Cnt == 0 then
  400. sysHeroList = SysParameter.getSysParameterTb(SysParameter.PARAMETER_11)
  401. elseif draw2Cnt == 1 then
  402. sysHeroList = SysParameter.getSysParameterTb(SysParameter.PARAMETER_12)
  403. elseif draw2Cnt == 2 then
  404. sysHeroList = SysParameter.getSysParameterTb(SysParameter.PARAMETER_13)
  405. end
  406. if sysHeroList then
  407. local totoalWeight = 0
  408. for i = 1, #sysHeroList do
  409. totoalWeight = totoalWeight + sysHeroList[i][2]
  410. end
  411. local r = math.random(1, totoalWeight)
  412. for i = 1, #sysHeroList do
  413. if r <= sysHeroList[i][2] then
  414. return sysHeroList[i][1]
  415. end
  416. r = r - sysHeroList[i][2]
  417. end
  418. end
  419. end
  420. end
  421. local heroID = nil
  422. local rindex = RandomLogic.getRandom1(config.weight, nil, 2)
  423. local rconf = config.weight[rindex]
  424. local weightLv = rconf[1]
  425. if weightLv >= 8 and actConfig then
  426. local rindex2 = RandomLogic.getRandom3(actConfig)
  427. local rconf2 = rindex2 and actConfig[rindex2]
  428. if rconf2 then
  429. return rconf2.heroID
  430. end
  431. end
  432. heroID = heroID or HeroDefine.getRandHeroByWeightLv(weightLv)
  433. local actHeroID = AbsActLogic.getLuckDraw(human, luckDraw, randomIndex, isAct, op)
  434. if actHeroID then
  435. heroID = actHeroID
  436. end
  437. return heroID
  438. end
  439. function randHeroIDV2(human, id, op, config, isAct)
  440. if isAct == 0 then
  441. if id == DRAWCARD_ID2 and op == DRAWCARD_OP_1 and getDrawCnt(human, id) == 0 then
  442. return SysParameter.getSysParameter(SysParameter.PARAMETER_7)
  443. end
  444. end
  445. local heroID = nil
  446. local rindex = RandomLogic.getRandom1(config.weight, nil, 2)
  447. local rconf = config.weight[rindex]
  448. local grade = rconf[1]
  449. local campWeightConfig = CampWeightExcel[id]
  450. if not campWeightConfig then return end
  451. local rindex2 = RandomLogic.getRandom1(campWeightConfig.weight, nil, 2)
  452. local rconf2 = campWeightConfig.weight[rindex2]
  453. local camp = rconf2[1]
  454. if grade < 0 or camp < 0 then
  455. return heroID
  456. end
  457. heroID = heroID or HeroDefine.getRandHeroByGradeAndCamp(grade, camp)
  458. return heroID
  459. end
  460. -- 基础,高级,友情召唤,活动召唤
  461. local function draw(human, id, op, actConfig, skip, isAct)
  462. if isAct == AbsActDefine.ABS_ACT_TYPE_4 then
  463. PerpleHeroLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  464. return
  465. elseif isAct == AbsActDefine.OA_ACT_TYPE_501 then
  466. LimitPerpleHeroLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  467. return
  468. elseif isAct == AbsActDefine.ABS_ACT_TYPE_19 then
  469. HeroComeLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  470. return
  471. end
  472. local config = DrawCardExcel[id]
  473. if not config then return end
  474. local heroCnt = nil
  475. if op == DRAWCARD_OP_1 then
  476. heroCnt = 1
  477. elseif op == DRAWCARD_OP_2 then
  478. heroCnt = 10
  479. else
  480. return
  481. end
  482. if HeroLogic.getEmptyCnt(human) < heroCnt then
  483. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  484. end
  485. if not checkUseItem(human, id, op, config, isAct) then
  486. return
  487. end
  488. setSkip(human, id, skip)
  489. local heroLen = 0
  490. local heroList = {}
  491. local heroNewList = {}
  492. local heroIndexList = {}
  493. local fenjielist = {}
  494. local heroIDs = nil
  495. local randomMin = math.random(1, heroCnt)
  496. for i = 1, heroCnt do
  497. config = DrawCardExcel[id]
  498. if id == DRAWCARD_ID2 and op == DRAWCARD_OP_2 and i == randomMin and getDraw2Cnt(human, id) > 3 then
  499. config = DrawCardExcel[DRAWCARD_ID5]
  500. elseif id == DRAWCARD_ID2 and op == DRAWCARD_OP_1 then
  501. config = DrawCardExcel[DRAWCARD_ID6]
  502. end
  503. -- 第40抽必出SSR
  504. if id == DRAWCARD_ID2 and getDrawNoSSRCnt(human, id) >= DRAWCARD_40 - 1 then
  505. config = DrawCardExcel[DRAWCARD_ID7]
  506. end
  507. local heroID = randHeroID(human, id, op, config, actConfig, i == randomMin, isAct)
  508. local heroConfig = HeroExcel[heroID]
  509. local star = heroConfig.star
  510. local name = heroConfig.name
  511. local grade = heroConfig.grade
  512. local isNew = not HeroBook.isGet(human, heroConfig.id, heroConfig.star)
  513. local heroIndex, fjlist = HeroLogic.addHero(human, heroID, nil, 1, "draw_card")
  514. heroLen = heroLen + 1
  515. heroList[heroLen] = heroID
  516. heroNewList[heroLen] = isNew
  517. heroIndexList[heroLen] = heroIndex
  518. if fjlist and type(fjlist) == "table" then
  519. for fjItemID, fjItemCnt in pairs(fjlist) do
  520. fenjielist[fjItemID] = (fenjielist[fjItemID] or 0) + fjItemCnt
  521. end
  522. end
  523. if not heroIDs then
  524. heroIDs = heroID
  525. else
  526. heroIDs = heroIDs .. "|" .. heroID
  527. end
  528. -- 判断召唤出来的英雄是否为ssr
  529. if grade < 4 then
  530. addDrawNoSSRCnt(human, id, 1)
  531. else
  532. clearDrawNoSSRCnt(human, id)
  533. end
  534. if star < 5 then
  535. addDrawNoGoodCnt(human, id, 1)
  536. else
  537. clearDrawNoGoodCnt(human, id)
  538. end
  539. if getDrawCnt(human, id) > 0 or getDraw2Cnt(human, id) > 0 then
  540. if id == DRAWCARD_ID1 then
  541. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE3, grade, heroID)
  542. elseif id == DRAWCARD_ID2 then
  543. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE1, grade, heroID)
  544. elseif id == DRAWCARD_ID3 then
  545. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE2, grade, heroID)
  546. elseif id == DRAWCARD_ID6 then
  547. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE21, grade, heroID)
  548. end
  549. end
  550. if op == DRAWCARD_OP_1 then
  551. addDrawCnt(human, id, 1)
  552. elseif op == DRAWCARD_OP_2 then
  553. addDraw2Cnt(human, id, 1)
  554. end
  555. if id == DRAWCARD_ID1 then
  556. LiLianLogic.onCallback(human, LiLianLogic.LILIAN_OUTID26, 1, star)
  557. elseif id == DRAWCARD_ID2 then
  558. LiLianLogic.onCallback(human, LiLianLogic.LILIAN_OUTID27, 1, star)
  559. end
  560. end
  561. updateJifen(human, config.jifen * heroCnt)
  562. if id == DRAWCARD_ID2 then
  563. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_2, heroCnt)
  564. MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_12, heroCnt)
  565. YunYingLogic.onCallBack(human, "onDrawCard", heroCnt, id)
  566. end
  567. sendDrawOp(human, id, op, heroList, fenjielist, heroNewList, heroIndexList, isAct)
  568. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_401)
  569. Log.write(Log.LOGID_OSS_DRAWCARD, human.db._id, human.db.account, human.db.name, human.db.lv, id, heroIDs,
  570. itemID or 0, cnt or 0, zuanshi or 0, getJifen(human))
  571. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_3, heroCnt)
  572. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_DRAW)
  573. end
  574. -- 高级召唤 新版本
  575. local function drawV2(human, id, op, actConfig, skip, isAct)
  576. if isAct == AbsActDefine.ABS_ACT_TYPE_4 then
  577. PerpleHeroLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  578. return
  579. elseif isAct == AbsActDefine.OA_ACT_TYPE_501 then
  580. LimitPerpleHeroLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  581. return
  582. elseif isAct == AbsActDefine.ABS_ACT_TYPE_19 then
  583. HeroComeLogic.onDrawCardActive(human, id, op, actConfig, skip, isAct)
  584. return
  585. end
  586. local config = DrawCardExcel[id]
  587. if not config then return end
  588. local weightConf = DrawCardV2Excel[getDrawLv(human, id)]
  589. if not weightConf then return end
  590. local heroCnt = nil
  591. if op == DRAWCARD_OP_1 then
  592. heroCnt = 1
  593. elseif op == DRAWCARD_OP_2 then
  594. heroCnt = 10
  595. else
  596. return
  597. end
  598. if HeroLogic.getEmptyCnt(human) < heroCnt then
  599. return Broadcast.sendErr(human, Lang.HERO_BAG_FULL)
  600. end
  601. if not checkUseItem(human, id, op, config, isAct) then
  602. return
  603. end
  604. setSkip(human, id, skip)
  605. local heroLen = 0
  606. local heroList = {}
  607. local heroNewList = {}
  608. local heroIndexList = {}
  609. local fenjielist = {}
  610. local heroIDs = nil
  611. local randomMin = math.random(1, heroCnt)
  612. for i = 1, heroCnt do
  613. config = DrawCardExcel[id]
  614. weightConf = DrawCardV2Excel[getDrawLv(human, id)]
  615. local heroID = randHeroIDV2(human, id, op, weightConf, isAct)
  616. local heroConfig = HeroExcel[heroID]
  617. local star = heroConfig.star
  618. local name = heroConfig.name
  619. local grade = heroConfig.grade
  620. local isNew = not HeroBook.isGet(human, heroConfig.id, heroConfig.star)
  621. local heroIndex, fjlist = HeroLogic.addHero(human, heroID, nil, 1, "draw_card")
  622. heroLen = heroLen + 1
  623. heroList[heroLen] = heroID
  624. heroNewList[heroLen] = isNew
  625. heroIndexList[heroLen] = heroIndex
  626. if fjlist and type(fjlist) == "table" then
  627. for fjItemID, fjItemCnt in pairs(fjlist) do
  628. fenjielist[fjItemID] = (fenjielist[fjItemID] or 0) + fjItemCnt
  629. end
  630. end
  631. if not heroIDs then
  632. heroIDs = heroID
  633. else
  634. heroIDs = heroIDs .. "|" .. heroID
  635. end
  636. -- 判断召唤出来的英雄是否为ssr
  637. if grade < 4 then
  638. addDrawNoSSRCnt(human, id, 1)
  639. else
  640. clearDrawNoSSRCnt(human, id)
  641. end
  642. if star < 5 then
  643. addDrawNoGoodCnt(human, id, 1)
  644. else
  645. clearDrawNoGoodCnt(human, id)
  646. end
  647. if getDrawCnt(human, id) > 0 or getDraw2Cnt(human, id) > 0 then
  648. ChatPaoMaLogic.broadcast(human, ChatPaoMaLogic.PAOMA_TYPE_BROAD_TYPE1, grade, heroID)
  649. end
  650. if op == DRAWCARD_OP_1 then
  651. addDrawCnt(human, id, 1)
  652. elseif op == DRAWCARD_OP_2 then
  653. addDraw2Cnt(human, id, 1)
  654. end
  655. --更新抽卡等级
  656. addDrawLv(human, id, 1)
  657. --更新抽卡等级 需要返回
  658. query(human)
  659. LiLianLogic.onCallback(human, LiLianLogic.LILIAN_OUTID27, 1, star)
  660. end
  661. updateJifen(human, config.jifen * heroCnt)
  662. if id == DRAWCARD_ID2 then
  663. ChengjiuLogic.onCallback(human, ChengjiuDefine.CJ_TASK_TYPE_2, heroCnt)
  664. MengxinLogic.onCallBack(human, MengxinLogic.MX_TASK_TYPE_12, heroCnt)
  665. YunYingLogic.onCallBack(human, "onDrawCard", heroCnt, id)
  666. end
  667. sendDrawOp(human, id, op, heroList, fenjielist, heroNewList, heroIndexList, isAct)
  668. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_401)
  669. Log.write(Log.LOGID_OSS_DRAWCARD, human.db._id, human.db.account, human.db.name, human.db.lv, id, heroIDs,
  670. itemID or 0, cnt or 0, zuanshi or 0, getJifen(human))
  671. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_3, heroCnt)
  672. GuideLogic.setDoSpecialGuide(human, GuideLogic.SKIPTYPE_JUMP_DRAW)
  673. end
  674. function op(human, id, op, skip, isAct)
  675. if id == DRAWCARD_ID0 then
  676. jifenDraw(human, isAct)
  677. return
  678. end
  679. -- 高级召唤走新逻辑
  680. if id == DRAWCARD_ID2 then
  681. drawV2(human, id, op, nil, skip, isAct)
  682. return
  683. end
  684. if id == DRAWCARD_ID1 or id == DRAWCARD_ID2 or id == DRAWCARD_ID3 or id == DRAWCARD_ID6 then
  685. draw(human, id, op, nil, skip, isAct)
  686. return
  687. end
  688. end
  689. function initAfterHot()
  690. for _, config in pairs(DrawCardExcel) do
  691. local totalWeight = 0
  692. for k, v in ipairs(config.weight) do
  693. totalWeight = totalWeight + v[2]
  694. end
  695. config.totalWeight = totalWeight
  696. end
  697. end
  698. function isDot(human)
  699. if human.db.lv < 9 then
  700. return false
  701. end
  702. if isFree(human, DRAWCARD_ID1, DRAWCARD_OP_1) then
  703. return true
  704. end
  705. if isFree(human, DRAWCARD_ID2, DRAWCARD_OP_1) then
  706. return true
  707. end
  708. if BagLogic.getItemCnt(human, ItemDefine.ITEM_DRAWCARD_GAOCHOU_ID) >= 10 then
  709. return true
  710. end
  711. return false
  712. end