DrawCardLogic.lua 28 KB

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