DrawCardLogic.lua 23 KB

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