DrawCardLogic.lua 22 KB

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