DrawCardLogic.lua 27 KB

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