LiLianLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. -- 历练 --
  2. local Lang = require("common.Lang")
  3. local Util = require("common.Util")
  4. local Msg = require("core.Msg")
  5. local ObjHuman = require("core.ObjHuman")
  6. local LiLianExcel = require("excel.liLian")
  7. local LiLianTaskExcel = require("excel.liLian").group
  8. local BagLogic = require("bag.BagLogic")
  9. local Grid = require("bag.Grid")
  10. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  11. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  12. local CombatDefine = require("combat.CombatDefine")
  13. local HeroExcel = require("excel.hero")
  14. local YjTreasureLogic = require("yjTreasure.YjTreasureLogic")
  15. local ChatHandler = require("chat.Handler")
  16. local Broadcast = require("broadcast.Broadcast")
  17. local ChatLogic = require("chat.ChatLogic")
  18. local RoleDBLogic = require("role.RoleDBLogic")
  19. local Timer = require("core.Timer")
  20. LILIAN_TASK_TYPE1 = 1 --竞技历练
  21. LILIAN_TASK_TYPE2 = 2 --战斗历练
  22. LILIAN_TASK_TYPE3 = 3 --终极历练
  23. LILIAN_TASK_TYPE4 = 4 --达标奖励
  24. LILIAN_TASK1 = 1 --皇冠联赛中,6回合内战胜高战力对手,累计{1}次 o
  25. LILIAN_TASK2 = 2 --皇冠联赛中,4回合内战胜高战力对手,累计{1}次 o
  26. LILIAN_TASK3 = 3 --众神之战累计进入{1}次32强 o
  27. LILIAN_TASK4 = 4 --众神之战累计进入{1}次8强 o
  28. LILIAN_TASK5 = 5 --获得{1}次众神之战冠军 o
  29. LILIAN_TASK6 = 6 --天梯争霸赛季结算时获得前{1}名 o
  30. LILIAN_TASK7 = 7 --天梯争霸累计挑战胜利{1}次 o
  31. LILIAN_TASK8 = 8 --巅峰段位赛累计获胜{1}场 x
  32. LILIAN_TASK9 = 9 --巅峰段位赛结算时达到铂金及以上段位 x
  33. LILIAN_TASK10 = 10 --巅峰段位赛结算时达到钻石及以上段位 x
  34. LILIAN_TASK11 = 11 --巅峰段位赛赛季结算时获得前{1}名 x
  35. LILIAN_TASK12 = 12 --通关通天塔{1}层 o
  36. LILIAN_TASK13 = 13 --挑战公会boss,当场累计造成{1}伤害 o
  37. LILIAN_TASK14 = 14 --公会战中累计获得{1}次个人胜利 o
  38. LILIAN_TASK15 = 15 --通关{1}次圣树试炼普通难度 o
  39. LILIAN_TASK16 = 16 --通关{1}次圣树试炼精英难度 o
  40. LILIAN_TASK17 = 17 --通关{1}次圣树试炼噩梦难度 o
  41. LILIAN_TASK18 = 18 --进入遗迹探宝{1}层 o
  42. LILIAN_TASK19 = 19 --遗迹探宝中累计击败{1}守卫 o
  43. LILIAN_TASK20 = 20 --单场公会boss累计造成{1}中毒伤害 o
  44. LILIAN_TASK21 = 21 --单场通天塔累计造成{1}流血伤害 o
  45. LILIAN_TASK22 = 22 --单场公会战累计造成{1}燃烧伤害 o
  46. LILIAN_TASK23 = 23 --通关无尽之路{1}关 x
  47. LILIAN_TASK24 = 24 --通关任意圣殿第{1}关 x
  48. LILIAN_TASK25 = 25 --本周内通关每个圣殿第{1}关 x
  49. LILIAN_TASK26 = 26 --守望圣殿排行榜结算时累计获得{1}次前10 x
  50. LILIAN_TASK27 = 27 --守望圣殿排行榜结算时累计获得{1}次前3 x
  51. LILIAN_TASK28 = 28 --完美通关神之领域前{1}章 x
  52. LILIAN_TASK29 = 29 --最高战力达到{1}万 o
  53. LILIAN_TASK30 = 30 --当前拥有{1}个10星英雄 o
  54. LILIAN_TASK31 = 31 --当前拥有{1}个11星英雄 o
  55. LILIAN_TASK32 = 32 --使{1}个恶魔英雄达到10星 1 o
  56. LILIAN_TASK33 = 33 --使{1}个恶魔英雄达到11星 o
  57. LILIAN_TASK34 = 34 --使{1}个不死英雄达到10星 2 o
  58. LILIAN_TASK35 = 35 --使{1}个不死英雄达到11星 o
  59. LILIAN_TASK36 = 36 --使{1}个圣堂英雄达到10星 3 o
  60. LILIAN_TASK37 = 37 --使{1}个圣堂英雄达到11星 o
  61. LILIAN_TASK38 = 38 --使{1}个神谕英雄达到10星 4 o
  62. LILIAN_TASK39 = 39 --使{1}个神谕英雄达到11星 o
  63. LILIAN_TASK40 = 40 --使{1}个混沌英雄达到10星 5 o
  64. LILIAN_TASK41 = 41 --使{1}个混沌英雄达到11星 o
  65. LILIAN_TASK42 = 42 --任意一场众神之战中{1}次竞猜全部正确 o
  66. LILIAN_TASK43 = 43 --普通招募累计活动{1}个5星英雄 o
  67. LILIAN_TASK44 = 44 --友情招募累计获得{1}个5星英雄 o
  68. LILIAN_TASK45 = 45 --累计获得{1}个神话符文 o
  69. LILIAN_TASK46 = 46 --累计获得{1}个传说符文 o
  70. LILIAN_TASK47 = 47 --累计领悟{1}本初级兵书 o
  71. LILIAN_TASK48 = 48 --累计领悟{1}本中级兵书 o
  72. LILIAN_TASK49 = 49 --累计充值{1}钻石 o
  73. LILIAN_TASK50 = 50 --公会建设中累计花费{1}钻石 o
  74. LILIAN_TASK51 = 51 --获得{1}次公会红包的手气最佳 o
  75. LILIAN_TASK52 = 52 --发放的红包累计超过{1}钻石 o
  76. LILIAN_TASK53 = 53 --累计完成{1}个历练任务 o
  77. LILIAN_OUTID1 = 1 --皇冠联赛中,x回合内战胜高战力对手,累计{1}次
  78. LILIAN_OUTID2 = 2 --众神之战累计进入{1}次x强
  79. LILIAN_OUTID3 = 3 --天梯争霸赛季结算时获得前{1}名
  80. LILIAN_OUTID4 = 4 --天梯争霸累计挑战胜利{1}次
  81. LILIAN_OUTID5 = 5 --巅峰段位赛累计获胜{1}场
  82. LILIAN_OUTID6 = 6 --巅峰段位赛结算时达到x及以上段位
  83. LILIAN_OUTID7 = 7 --巅峰段位赛赛季结算时获得前{1}名
  84. LILIAN_OUTID8 = 8 --通关通天塔{1}层
  85. LILIAN_OUTID9 = 9 --挑战公会boss,当场累计造成{1}伤害
  86. LILIAN_OUTID10 = 10 --公会战中累计获得{1}次个人胜利
  87. LILIAN_OUTID11 = 11 --通关{1}次圣树试炼x难度
  88. LILIAN_OUTID12 = 12 --进入遗迹探宝{1}层
  89. LILIAN_OUTID13 = 13 --遗迹探宝中累计击败{1}守卫
  90. LILIAN_OUTID14 = 14 --单场公会boss累计造成{1}中毒伤害
  91. LILIAN_OUTID15 = 15 --单场通天塔累计造成{1}流血伤害
  92. LILIAN_OUTID16 = 16 --单场公会战累计造成{1}燃烧伤害
  93. LILIAN_OUTID17 = 17 --通关无尽之路{1}关
  94. LILIAN_OUTID18 = 18 --通关任意圣殿第{1}关
  95. LILIAN_OUTID19 = 19 --本周内通关每个圣殿第{1}关
  96. LILIAN_OUTID20 = 20 --守望圣殿排行榜结算时累计获得{1}次前x
  97. LILIAN_OUTID21 = 21 --完美通关神之领域前{1}章
  98. LILIAN_OUTID22 = 22 --最高战力达到{1}
  99. LILIAN_OUTID23 = 23 --当前拥有{1}个x星英雄
  100. LILIAN_OUTID24 = 24 --使{1}个x英雄达到x星
  101. LILIAN_OUTID25 = 25 --任意一场众神之战中{1}次竞猜全部正确
  102. LILIAN_OUTID26 = 26 --普通招募累计活动{1}个x星英雄
  103. LILIAN_OUTID27 = 27 --友情招募累计获得{1}个x星英雄
  104. LILIAN_OUTID28 = 28 --累计获得{1}个x符文
  105. LILIAN_OUTID29 = 29 --累计充值{1}钻石
  106. LILIAN_OUTID30 = 30 --公会建设中累计花费{1}钻石
  107. LILIAN_OUTID31 = 31 --获得{1}次公会红包的手气最佳
  108. LILIAN_OUTID32 = 32 --发放的红包累计超过{1}钻石
  109. LILIAN_OUTID33 = 33 --累计完成{1}个历练任务
  110. LILIAN_OUT2TASK = {
  111. [LILIAN_OUTID1] = {LILIAN_TASK1,LILIAN_TASK2},
  112. [LILIAN_OUTID2] = {LILIAN_TASK3,LILIAN_TASK4,LILIAN_TASK5},
  113. [LILIAN_OUTID3] = {LILIAN_TASK6},
  114. [LILIAN_OUTID4] = {LILIAN_TASK7},
  115. [LILIAN_OUTID5] = {LILIAN_TASK8},
  116. [LILIAN_OUTID6] = {LILIAN_TASK9,LILIAN_TASK10},
  117. [LILIAN_OUTID7] = {LILIAN_TASK11},
  118. [LILIAN_OUTID8] = {LILIAN_TASK12},
  119. [LILIAN_OUTID9] = {LILIAN_TASK13},
  120. [LILIAN_OUTID10] = {LILIAN_TASK14},
  121. [LILIAN_OUTID11] = {LILIAN_TASK15,LILIAN_TASK16,LILIAN_TASK17},
  122. [LILIAN_OUTID12] = {LILIAN_TASK18},
  123. [LILIAN_OUTID13] = {LILIAN_TASK19},
  124. [LILIAN_OUTID14] = {LILIAN_TASK20},
  125. [LILIAN_OUTID15] = {LILIAN_TASK21},
  126. [LILIAN_OUTID16] = {LILIAN_TASK22},
  127. [LILIAN_OUTID17] = {LILIAN_TASK23},
  128. [LILIAN_OUTID18] = {LILIAN_TASK24},
  129. [LILIAN_OUTID19] = {LILIAN_TASK25},
  130. [LILIAN_OUTID20] = {LILIAN_TASK26,LILIAN_TASK27},
  131. [LILIAN_OUTID21] = {LILIAN_TASK28},
  132. [LILIAN_OUTID22] = {LILIAN_TASK29},
  133. [LILIAN_OUTID23] = {LILIAN_TASK30,LILIAN_TASK31},
  134. [LILIAN_OUTID24] = {LILIAN_TASK32,LILIAN_TASK33,LILIAN_TASK34,LILIAN_TASK35,LILIAN_TASK36,LILIAN_TASK37,LILIAN_TASK38,LILIAN_TASK39,LILIAN_TASK40,LILIAN_TASK41},
  135. [LILIAN_OUTID25] = {LILIAN_TASK42},
  136. [LILIAN_OUTID26] = {LILIAN_TASK43},
  137. [LILIAN_OUTID27] = {LILIAN_TASK44},
  138. [LILIAN_OUTID28] = {LILIAN_TASK45,LILIAN_TASK46,LILIAN_TASK47,LILIAN_TASK48},
  139. [LILIAN_OUTID29] = {LILIAN_TASK49},
  140. [LILIAN_OUTID30] = {LILIAN_TASK50},
  141. [LILIAN_OUTID31] = {LILIAN_TASK51},
  142. [LILIAN_OUTID32] = {LILIAN_TASK52},
  143. [LILIAN_OUTID33] = {LILIAN_TASK53},
  144. }
  145. LILIAN_STATE_NOT = 0 -- 未完成
  146. LILIAN_STATE_CAN = 1 -- 可获取
  147. LILIAN_STATE_HAD = 2 -- 已获取
  148. -- 根据历练类型获取配表
  149. local function getConfigByType(lilianType)
  150. if lilianType == LILIAN_TASK_TYPE1 then
  151. return LiLianExcel.jjcLiLian
  152. elseif lilianType == LILIAN_TASK_TYPE2 then
  153. return LiLianExcel.combatLiLian
  154. elseif lilianType == LILIAN_TASK_TYPE3 then
  155. return LiLianExcel.finalLiLian
  156. elseif lilianType == LILIAN_TASK_TYPE4 then
  157. return LiLianExcel.dabiaoReward
  158. end
  159. end
  160. -- 获取历练组id详细历练配置
  161. -- config 历练类型配表
  162. -- groupID 历练任务组
  163. function getLiLianConf(human,config,groupID)
  164. -- 初始化历练db
  165. human.db.liLianGroup = human.db.liLianGroup or {}
  166. human.db.liLianGroup[groupID] = human.db.liLianGroup[groupID] or {0,1}
  167. local liLianDB = human.db.liLianGroup[groupID]
  168. local groupConfig = LiLianTaskExcel[groupID]
  169. if groupConfig == nil then
  170. return
  171. end
  172. local liLianID = groupConfig.sub[liLianDB[2]]
  173. return config[liLianID],groupConfig,liLianID
  174. end
  175. -- 获取背包中传入星级英雄个数
  176. local function getStarHeroCnt(human,starTarget)
  177. local cnt = 0
  178. for index, heroGrid in pairs(human.db.heroBag) do
  179. if index ~= 0 then
  180. local id = heroGrid and (heroGrid.id or heroGrid.heroID)
  181. local config = id and HeroExcel.hero[id]
  182. local star = config and config.star or 0
  183. if star == starTarget then
  184. cnt = cnt + 1
  185. end
  186. end
  187. end
  188. return cnt
  189. end
  190. -- 获取任务组完成次数
  191. local function getFinishCntByTask(human,groupID)
  192. --通天塔
  193. if groupID == LILIAN_TASK12 then
  194. return human.db.tower and human.db.tower.lv or 0
  195. --遗迹探宝
  196. elseif groupID == LILIAN_TASK18 then
  197. return YjTreasureLogic.getLayerMax(human)
  198. -- --无尽之路
  199. -- elseif task == LILIAN_TASK23 then
  200. -- return
  201. -- --任意圣殿x关
  202. -- elseif task == LILIAN_TASK24 then
  203. -- return
  204. -- --每个圣殿x关
  205. -- elseif task == LILIAN_TASK25 then
  206. -- return
  207. -- --神之领域x章
  208. -- elseif task == LILIAN_TASK28 then
  209. -- return
  210. --x个10星英雄
  211. elseif groupID == LILIAN_TASK30 then
  212. return getStarHeroCnt(human,10)
  213. --x个11星英雄
  214. elseif groupID == LILIAN_TASK31 then
  215. return getStarHeroCnt(human,11)
  216. --累充
  217. elseif groupID == LILIAN_TASK49 then
  218. return human.db.topupAcountDaily or 0
  219. end
  220. return human.db.liLian and human.db.liLian.taskRecord and human.db.liLian.taskRecord[groupID] or 0
  221. end
  222. -- 根据历练类型及历练id获取历练状态
  223. local function getStateByLiLianID(human,taskType,id)
  224. local config = getConfigByType(taskType)
  225. if not config or not config[id] then
  226. return LILIAN_STATE_NOT
  227. end
  228. if human.db.liLian
  229. and human.db.liLian[taskType]
  230. and human.db.liLian[taskType].getList
  231. and human.db.liLian[taskType].getList[id] then
  232. return LILIAN_STATE_HAD
  233. end
  234. local need = config[id].param
  235. local now = getFinishCntByTask(human,config[id].task)
  236. local taskConfig = LiLianExcel.tasks[config[id].task]
  237. if taskConfig.compareType ~= 0 then
  238. if now <= need and now ~= 0 then return LILIAN_STATE_CAN end
  239. else
  240. if now >= need then return LILIAN_STATE_CAN end
  241. end
  242. return LILIAN_STATE_NOT
  243. end
  244. -- 构造历练任务结构体
  245. local function makeLiLianTask(human,net,config,taskType,id)
  246. net.id = id
  247. net.taskName = config.taskName
  248. net.taskDesc = config.desc
  249. net.finishCnt = getFinishCntByTask(human,config.task)
  250. net.needCnt = config.param
  251. net.state = getStateByLiLianID(human,taskType,id)
  252. net.panelID = config.panelID
  253. net.items[0] = #config.reward
  254. for i=1,#config.reward do
  255. Grid.makeItem(net.items[i],config.reward[i][1],config.reward[i][2])
  256. end
  257. end
  258. -- 获取一个类型所有任务完成数量
  259. local function getAllFinishCnt(human,taskType)
  260. local getList = nil
  261. if human.db.liLian
  262. and human.db.liLian[taskType]
  263. and human.db.liLian[taskType]
  264. and human.db.liLian[taskType].getList then
  265. getList = human.db.liLian[taskType].getList
  266. end
  267. local cnt = 0
  268. if getList then
  269. for _,_ in pairs(getList) do
  270. cnt = cnt + 1
  271. end
  272. end
  273. local config = getConfigByType(taskType)
  274. return cnt,#config
  275. end
  276. -- 红点检查
  277. local function isRedByTaskType(human,taskType)
  278. local config = getConfigByType(taskType)
  279. for i=1,#config do
  280. local state = getStateByLiLianID(human,taskType,i)
  281. if state == LILIAN_STATE_CAN then
  282. return true
  283. end
  284. end
  285. end
  286. --
  287. local function makeLiLianTaskState(human,net,taskType)
  288. net[0] = 4
  289. local index = 0
  290. for i=1,4 do
  291. index = index + 1
  292. net[index].taskType = i
  293. local finishCnt,needCnt = getAllFinishCnt(human,i)
  294. net[index].finishCnt = finishCnt
  295. net[index].needCnt = needCnt
  296. net[index].isRed = isRedByTaskType(human,i) and 1 or 0
  297. end
  298. end
  299. -- 查询历练
  300. function lilianQuery(human,taskType)
  301. local config = getConfigByType(taskType)
  302. if not config then return end
  303. local msgRet = Msg.gc.GC_LILIAN_QUERY
  304. msgRet.taskType = taskType
  305. local len = #LiLianTaskExcel
  306. local count = 0
  307. for i=1,len do
  308. if LiLianTaskExcel[i].taskType == taskType then
  309. local lilianConfig,groupConfig,id = getLiLianConf(human,config,i)
  310. if lilianConfig ~= nil then
  311. count = count + 1
  312. makeLiLianTask(human,msgRet.lists[count],lilianConfig,taskType,id)
  313. end
  314. end
  315. end
  316. msgRet.lists[0] = count
  317. makeLiLianTaskState(human,msgRet.taskState,taskType)
  318. --Msg.trace(msgRet)
  319. Msg.send(msgRet,human.fd)
  320. end
  321. function lilianGet(human,taskType,liLianID)
  322. local config = getConfigByType(taskType)
  323. if not config or not config[liLianID] then
  324. return
  325. end
  326. local state = getStateByLiLianID(human,taskType,liLianID)
  327. if state ~= LILIAN_STATE_CAN then
  328. return
  329. end
  330. human.db.liLian = human.db.liLian or {}
  331. human.db.liLian[taskType] = human.db.liLian[taskType] or {}
  332. human.db.liLian[taskType].getList = human.db.liLian[taskType].getList or {}
  333. human.db.liLian[taskType].getList[liLianID] = liLianID
  334. human.db.liLianGroup = human.db.liLianGroup or {}
  335. human.db.liLianGroup[config[liLianID].task] = human.db.liLianGroup[config[liLianID].task] or {0,1}
  336. human.db.liLianGroup[config[liLianID].task][2] = human.db.liLianGroup[config[liLianID].task][2] + 1
  337. BagLogic.addItemList(human, config[liLianID].reward, "li_lian")
  338. lilianQuery(human,taskType)
  339. onCallback(human,LILIAN_OUTID33,1,nil,nil,true)
  340. end
  341. --
  342. function setCnt(human,task,param1,noAdd)
  343. if noAdd then
  344. human.db.liLian = human.db.liLian or {}
  345. human.db.liLian.taskRecord = human.db.liLian.taskRecord or {}
  346. human.db.liLian.taskRecord[task] = param1
  347. else
  348. human.db.liLian = human.db.liLian or {}
  349. human.db.liLian.taskRecord = human.db.liLian.taskRecord or {}
  350. human.db.liLian.taskRecord[task] = (human.db.liLian.taskRecord[task] or 0 ) + param1
  351. end
  352. -- print("human.db.liLian.taskRecord[task]",human.db.liLian.taskRecord[task])
  353. end
  354. -- 触发回调
  355. function onCallback(human,outID,param1,param2,param3,noAdd)
  356. if not LILIAN_OUT2TASK[outID] then return end
  357. for i=1,#LILIAN_OUT2TASK[outID] do
  358. local task = LILIAN_OUT2TASK[outID][i]
  359. local taskConfig = LiLianExcel.tasks[task]
  360. local set = true
  361. local paramCnf = taskConfig.param
  362. if #paramCnf > 0 then
  363. local paramCnf1 = paramCnf[1]
  364. local paramCnf2 = paramCnf[2] or 0
  365. if param2 ~= paramCnf1 then
  366. set = nil
  367. end
  368. if paramCnf2 ~= 0 then
  369. if param3 ~= paramCnf2 then
  370. set = nil
  371. end
  372. end
  373. if outID == LILIAN_OUTID1 or outID == LILIAN_OUTID2 or outID == LILIAN_OUTID20 then
  374. if param2 <= paramCnf1 then
  375. set = true
  376. end
  377. end
  378. else
  379. local nowCnt = getFinishCntByTask(human,task)
  380. if nowCnt ~= 0 then
  381. if taskConfig.compareType ~= 0 then
  382. if nowCnt <= param1 then
  383. set = nil
  384. end
  385. else
  386. if nowCnt >= param1 then
  387. set = nil
  388. end
  389. end
  390. end
  391. end
  392. if set then
  393. setCnt(human,task,param1,noAdd)
  394. end
  395. end
  396. end
  397. function onCallbackByUuid(uuid,task,param1,param2,param3,noAdd)
  398. do return end
  399. local target = ObjHuman.onlineUuid[uuid]
  400. if target and target.fd then
  401. onCallback(target,task,param1,param2,param3,noAdd)
  402. else
  403. local fakeDB = RoleDBLogic.getDb(uuid,{liLian = 1})
  404. if fakeDB then
  405. local fakeHuman = {}
  406. fakeHuman.db = fakeDB
  407. onCallback(fakeHuman,task,param1,param2,param3,noAdd)
  408. ObjHuman.save(fakeHuman)
  409. end
  410. end
  411. end
  412. function onCallbackByCombat(human,combatInfo)
  413. do return end
  414. if not combatInfo then return end
  415. local attacker = combatInfo.attacker
  416. local defender = combatInfo.defender
  417. local combatType = combatInfo.type
  418. if combatType ~= CombatDefine.COMBAT_TYPE2 or --皇冠联赛/冠军联赛(进攻)
  419. combatType ~= CombatDefine.COMBAT_TYPE11 or --公会boss
  420. combatType ~= CombatDefine.COMBAT_TYPE12 or --公会战(进攻)
  421. combatType ~= CombatDefine.COMBAT_TYPE6 then --通天塔/恶魔之塔
  422. return
  423. end
  424. if attacker.uuid ~= human.db._id then return end
  425. if attacker.zhandouli < defender.zhandouli and combatType == CombatDefine.COMBAT_TYPE2 then
  426. onCallback(human,LILIAN_OUTID1,1,combatInfo.result.round)
  427. end
  428. local totalzhongdu = nil
  429. local totalliuxue = nil
  430. local totalranshao = nil
  431. local totalhurt = nil
  432. for pos = 1, CombatDefine.COMBAT_HERO_CNT do
  433. local obj = objList and objList[pos]
  434. if obj then
  435. local extraCombatRecord = obj.extraCombatRecord
  436. local zhongdu = extraCombatRecord and extraCombatRecord.zhongdu or 0
  437. local liuxue = extraCombatRecord and extraCombatRecord.liuxue or 0
  438. local ranshao = extraCombatRecord and extraCombatRecord.ranshao or 0
  439. local hurt = obj.result and obj.result[1] or 0
  440. if zhongdu > 0 and combatType == CombatDefine.COMBAT_TYPE11 then
  441. totalzhongdu = (totalzhongdu or 0) + zhongdu
  442. end
  443. if liuxue > 0 and combatType == CombatDefine.COMBAT_TYPE6 then
  444. totalliuxue = (totalliuxue or 0) + liuxue
  445. end
  446. if ranshao > 0 and combatType == CombatDefine.COMBAT_TYPE12 then
  447. totalranshao = (totalranshao or 0) + ranshao
  448. end
  449. if hurt > 0 and combatType == CombatDefine.COMBAT_TYPE11 then
  450. totalhurt = (totalhurt or 0) + hurt
  451. end
  452. end
  453. end
  454. if totalzhongdu then
  455. onCallback(human,LILIAN_OUTID14,totalzhongdu)
  456. end
  457. if totalliuxue then
  458. onCallback(human,LILIAN_OUTID15,totalliuxue)
  459. end
  460. if totalranshao then
  461. onCallback(human,LILIAN_OUTID16,totalliuxue)
  462. end
  463. if totalhurt then
  464. onCallback(human,LILIAN_OUTID9,totalhurt)
  465. end
  466. end
  467. -- 历练分享
  468. function lilianShare(human,taskType,id,shareType)
  469. local state = getStateByLiLianID(human,taskType,id)
  470. if state ~= LILIAN_STATE_HAD then return end
  471. if shareType ~= ChatHandler.CHAT_TYPE_WORLD and shareType ~= ChatHandler.CHAT_TYPE_UNION and shareType ~= ChatHandler.CHAT_TYPE_MIDDLE then
  472. return
  473. end
  474. -- 如果是分享在世界上检测是否在聊天CD 中
  475. if shareType == ChatHandler.CHAT_TYPE_WORLD and human.worldChatTime and human.worldChatTime + CHAT_CD > Timer.now then
  476. local cdLeftSec = math.ceil((CHAT_CD - (Timer.now - human.worldChatTime))/1000)
  477. Broadcast.sendDown(human, Util.format(Lang.CHAT_TIME_SHORT, cdLeftSec))
  478. return
  479. end
  480. if shareType == ChatHandler.CHAT_TYPE_UNION and human.db.unionUuid == nil then
  481. return Broadcast.sendErr(human, Lang.UNION_PLAYER_IN_NO)
  482. end
  483. local shareConf = LiLianExcel.share[taskType]
  484. if not shareConf then return end
  485. local config = getConfigByType(taskType)
  486. if not config then return end
  487. local name = shareConf.name
  488. local desc = shareConf.desc
  489. local taskName = config[id].taskName
  490. local content = Util.format(desc,name,taskName)
  491. local msgNet = {}
  492. msgNet.msgType = shareType
  493. msgNet.msg = content
  494. local flag = ChatLogic.chat(human, msgNet)
  495. if flag == true then
  496. Broadcast.sendErr(human, Lang.SHARE_SUCCESS)
  497. else
  498. Broadcast.sendErr(human, Lang.SHARE_ERROR)
  499. end
  500. end
  501. function isDot(human)
  502. for i = 1, 4 do
  503. if isRedByTaskType(human,i) then
  504. return true
  505. end
  506. end
  507. return false
  508. end