DrawCardLogic.lua 28 KB

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