DrawCardLogic.lua 23 KB

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