CombatPosLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. -------------------------------------------------
  2. -- 队伍上阵
  3. -- db.combatHero 上阵信息
  4. -- getTeamType 根据战斗类型获取出战队伍类型
  5. -- getCombatHeros 根据出战类型获取出战队伍下标列表
  6. -- getCombatHeroZDL 根据战斗类型获取出战战力
  7. -- cleanCombatHeros 清空出战信息
  8. -- updatePos 设置上阵信息
  9. -------------------------------------------------
  10. local CombatExcel = require("excel.combat")
  11. local HeroExcel = require("excel.hero")
  12. local MonsterExcel = require("excel.monster").monster
  13. local MonsterOutExcel = require("excel.monster").monsterOut
  14. local CombatPosExcel = require("excel.combatPos")
  15. local FormationExcel = CombatPosExcel.formation
  16. local DefineExcel = CombatPosExcel.define[1]
  17. local Util = require("common.Util")
  18. local Lang = require("common.Lang")
  19. local Msg = require("core.Msg")
  20. local ObjHuman = require("core.ObjHuman")
  21. local Broadcast = require("broadcast.Broadcast")
  22. local CombatDefine = require("combat.CombatDefine")
  23. local CombatLogic = require("combat.CombatLogic")
  24. local CombatImpl = require("combat.CombatImpl")
  25. local DrillLogic = require("drill.DrillLogic")
  26. local JjcLogic = require("jjc.JjcLogic")
  27. local UnionWarLogic = require("union.UnionWarLogic")
  28. local UnionLogic = require("union.UnionLogic")
  29. local RoleDefine = require("role.RoleDefine")
  30. local MoshouLogic = require("moshou.MoshouLogic")
  31. local HeroLogic = require("hero.HeroLogic")
  32. local Grid = require("bag.Grid")
  33. local BagLogic = require("bag.BagLogic")
  34. local YjTreasureLogic = require("yjTreasure.YjTreasureLogic")
  35. local RoleHeadLogic = require("role.RoleHeadLogic")
  36. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  37. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  38. local JibanLogic = require("combat.JibanLogic")
  39. local JjcGodWarLogic = require("jjcGodWar.JjcGodWarLogic")
  40. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  41. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  42. local SkillExcel = require("excel.skill")
  43. local RoleAttr = require("role.RoleAttr")
  44. local LostTempleCombatLogic = require("lostTemple.lostTempleCombatLogic")
  45. local RecommendLineup = require("drawCard.RecommendLineup")
  46. -- 根据战斗类型获取出战队伍类型
  47. function getTeamType(combatType)
  48. if not CombatExcel.combat[combatType] then return end
  49. return CombatExcel.combat[combatType].teamType
  50. end
  51. function getCombatHeroDB(human,combatType)
  52. local teamType = getTeamType(combatType)
  53. if not human.db.combatHero[teamType] then
  54. human.db.combatHero[teamType] = {list = {},helpList = {},formation = 1,jiban = {}}
  55. end
  56. return human.db.combatHero[teamType],teamType
  57. end
  58. --根据阵法id返回可用站位
  59. function getPosList(formation)
  60. local formationConf = FormationExcel[formation]
  61. if not formationConf.posList then
  62. for k,v in pairs(FormationExcel) do
  63. v.posList = {}
  64. for _,v1 in ipairs(v.pos) do
  65. v.posList[v1] = 1
  66. end
  67. end
  68. end
  69. return formationConf.posList
  70. end
  71. function getCombatHeros(human, combatType)
  72. local combatHeroDB = getCombatHeroDB(human,combatType)
  73. return combatHeroDB.list,combatHeroDB.helpList,combatHeroDB.formation or 1,combatHeroDB
  74. end
  75. -- 清空出战信息
  76. function cleanCombatHeros(human, combatType)
  77. local teamType = getTeamType(combatType)
  78. human.db.combatHero[teamType] = nil
  79. end
  80. -- 拷贝上阵
  81. function copyCombatHeros(human, sourceType, targetType)
  82. local sTeamType = getTeamType(sourceType)
  83. local tTeamType = getTeamType(targetType)
  84. if sTeamType == tTeamType then return end
  85. local combatHeroDB = human.db.combatHero[sTeamType]
  86. human.db.combatHero[tTeamType] = Util.copyTable(combatHeroDB)
  87. end
  88. -- 可否更新阵容
  89. local function checkUpdatePos(human, msg)
  90. if msg.type == CombatDefine.COMBAT_TYPE4 then
  91. if not JjcGodWarLogic.checkCanPos(human) then return end
  92. end
  93. if msg.type == CombatDefine.COMBAT_TYPE24 then
  94. local moduleFn = CombatLogic.getModule(msg.type)
  95. if moduleFn and moduleFn.checkUpdatePos then
  96. return moduleFn.checkUpdatePos(human, msg)
  97. end
  98. return
  99. end
  100. if msg.type == CombatDefine.COMBAT_TYPE25 or msg.type == CombatDefine.COMBAT_TYPE26 or
  101. msg.type == CombatDefine.COMBAT_TYPE27 or msg.type == CombatDefine.COMBAT_TYPE28 then
  102. local moduleFn = CombatLogic.getModule(msg.type)
  103. if moduleFn and moduleFn.checkUpdatePos then
  104. if not moduleFn.checkUpdatePos(human, msg) then
  105. return false
  106. end
  107. end
  108. end
  109. local posList = getPosList(msg.formation)
  110. local heroList = Util.split(msg.heroList, ",")
  111. local helpList = Util.split(msg.helpList, ",", true)
  112. local cnt = 0
  113. local useList = { }
  114. local fatherList = { }
  115. -- 确定英雄存不存在
  116. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  117. local uuid = heroList[i] or ""
  118. if uuid ~= "0" and uuid ~= "" then
  119. if i == CombatDefine.COMBAT_HERO_CNT and canBackup(human) == 0 then
  120. -- 援军未激活
  121. return
  122. end
  123. if posList[i] == nil and i ~= CombatDefine.COMBAT_HERO_CNT then
  124. -- 站位不可用
  125. return
  126. end
  127. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  128. if not heroGrid then return end
  129. local heroConfig = HeroExcel.hero[heroGrid.id]
  130. if useList[uuid] or fatherList[heroGrid.id] then
  131. -- 同父类英雄重复
  132. return
  133. else
  134. cnt = cnt + 1
  135. useList[uuid] = true
  136. fatherList[heroGrid.id] = true
  137. end
  138. end
  139. end
  140. if cnt == 0 then
  141. -- 上阵英雄空
  142. return
  143. end
  144. -- 检查辅助对象是否激活 todo
  145. return true, heroList, helpList
  146. end
  147. -- 上阵成功处理
  148. function onUpdatePos(human, teamType)
  149. for combatType, config in pairs(CombatExcel.combat) do
  150. if config.teamType == teamType then
  151. CombatLogic.onUpdatePos(human, combatType)
  152. if combatType == CombatDefine.COMBAT_TYPE1 then
  153. ObjHuman.doCalc(human)
  154. local heroListZDL = getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1)
  155. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_8,heroListZDL)
  156. RecommendLineup.RecommendLineup_UpDate(human)
  157. end
  158. end
  159. end
  160. end
  161. -- 更新上阵信息
  162. function updatePos(human, msg)
  163. local combatType = msg.type
  164. local canUpdate,heroList,helpList = checkUpdatePos(human,msg)
  165. if not canUpdate then
  166. return
  167. end
  168. local combatHeroDB, teamType = getCombatHeroDB(human,combatType)
  169. combatHeroDB.formation = msg.formation
  170. combatHeroDB.list = heroList
  171. combatHeroDB.helpList = helpList
  172. local msgRet = Msg.gc.GC_COMBAT_POS_UPDATE
  173. msgRet.type = combatType
  174. msgRet.teamType = teamType
  175. Msg.send(msgRet,human.fd)
  176. if combatType == CombatDefine.COMBAT_TYPE1 then
  177. HeroLogic.sendBagDots(human)
  178. end
  179. RoleHeadLogic.CG_ROLE_COMBATHERO_QUERY(human, msg.type)
  180. onUpdatePos(human, teamType)
  181. end
  182. -- 设置能否跳过
  183. function setQuick(human, combatType, isQuick)
  184. local combatConfig = CombatExcel.combat[combatType]
  185. if combatConfig.isQuick == 1 then
  186. human.db.combatQuick[combatType] = isQuick
  187. end
  188. end
  189. -- 升级检测
  190. function onLvUp(human, oldLv, newLv)
  191. local heroListZDL = getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1)
  192. if heroListZDL <= 0 then return end
  193. local jjcDenType = CombatDefine.COMBAT_TYPE3
  194. local jjcGodType = CombatDefine.COMBAT_TYPE4
  195. local jjcDenLv = RoleSystemLogic.getOpenLv(CombatExcel.combat[jjcDenType].systemID)
  196. local jjcGodLv = RoleSystemLogic.getOpenLv(CombatExcel.combat[jjcGodType].systemID)
  197. local change = false
  198. -- 同步 战役阵容 到 竞技场防守阵容
  199. if oldLv < jjcDenLv and newLv >= jjcDenLv then
  200. local heroListJjc = getCombatHeroZDL(human, jjcDenType)
  201. if heroListJjc <= 0 then
  202. copyCombatHeros(human, CombatDefine.COMBAT_TYPE1, jjcDenType)
  203. change = true
  204. end
  205. end
  206. -- 同步 战役阵容 到 众神之战/王者争霸
  207. if oldLv < jjcGodLv and newLv >= jjcGodLv then
  208. local heroListJjc = getCombatHeroZDL(human, jjcGodType)
  209. if heroListJjc <= 0 then
  210. copyCombatHeros(human, CombatDefine.COMBAT_TYPE1, jjcGodType)
  211. change = true
  212. end
  213. end
  214. if change then
  215. ObjHuman.save(human)
  216. end
  217. end
  218. -- 获取上阵战力
  219. function getCombatHeroZDL(human, combatType)
  220. local zhandouli = 0
  221. local teamType = getTeamType(combatType)
  222. if teamType then
  223. local heroList = getCombatHeros(human, combatType)
  224. if heroList then
  225. for pos = 1, CombatDefine.COMBAT_HERO_CNT do
  226. local uuid = heroList[pos]
  227. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  228. if heroGrid and type(heroGrid) == "table" then
  229. if human.heroAttrs and not human.heroAttrs[heroGrid.bagIndex] then
  230. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  231. end
  232. zhandouli = zhandouli + (heroGrid.zhandouli or 0)
  233. end
  234. end
  235. end
  236. end
  237. return zhandouli
  238. end
  239. -- 发送阵型信息
  240. FormationInitFlag = nil
  241. function formationQuery(human)
  242. local msgRet = Msg.gc.GC_COMBAT_FORMATION_QUERY
  243. if not FormationInitFlag then
  244. FormationInitFlag = true
  245. local len = 0
  246. for k,v in ipairs(FormationExcel) do
  247. len = len + 1
  248. local net = msgRet.list[len]
  249. local len1 = 0
  250. for k1,v1 in ipairs(v.pos) do
  251. len1 = len1 + 1
  252. net.list[len1] = v1
  253. end
  254. net.list[0] = len1
  255. net.id = k
  256. net.lv = v.lv
  257. net.icon = v.icon
  258. net.name = v.name
  259. end
  260. msgRet.list[0] = len
  261. end
  262. msgRet.lv = human.db.lv
  263. Msg.send(msgRet,human.fd)
  264. end
  265. -- 去掉所有阵容中的数据
  266. function updateAllPos(human, uuid)
  267. heroIndexByDelForPos(human, uuid)
  268. local msgRet = Msg.gc.GC_HERO_UPDATE_ALL_POS
  269. Msg.send(msgRet,human.fd)
  270. end
  271. -- 英雄被分解 从默认出战中 去除
  272. function heroIndexByDelForPos(human, uuid)
  273. if not uuid or uuid == "0" or uuid == "" then return end
  274. for teamType, combatHero in pairs(human.db.combatHero) do
  275. if teamType ~= CombatDefine.COMBAT_TYPE10 then
  276. local isChange = nil
  277. for k, v in pairs(combatHero.list) do
  278. if v == uuid then
  279. combatHero.list[k] = nil
  280. isChange = true
  281. end
  282. end
  283. if isChange then
  284. onUpdatePos(human, teamType)
  285. posQuery(human, teamType)
  286. end
  287. end
  288. end
  289. end
  290. function caclCampAttr(attr, camp, cnt)
  291. -- 计算基础属性
  292. local conf = CombatPosExcel[camp]
  293. if basicsAttrExcel then
  294. for _, v in ipairs(conf) do
  295. if cnt == v.cnt then
  296. for k1,v1 in ipairs(v.attrs) do
  297. attr[v1[1]] = attr[v1[1]] or 0
  298. attr[v1[1]] = attr[v1[1]] + v1[2]
  299. end
  300. end
  301. end
  302. end
  303. end
  304. PosAttrInitFlag = nil
  305. function posAttrQuery(human)
  306. local msgRet = Msg.gc.GC_COMBAT_POS_ATTR_QUERY
  307. if not PosAttrInitFlag then
  308. PosAttrInitFlag = true
  309. local len = 0
  310. for k,v in ipairs(DefineExcel.attrs) do
  311. len = len + 1
  312. msgRet.attrs[len].key = v[1]
  313. msgRet.attrs[len].value = v[2]
  314. end
  315. msgRet.attrs[0] = len
  316. len = 0
  317. for camp = 1,CombatDefine.CAMP_ALL do
  318. local conf = CombatPosExcel[camp]
  319. len = len + 1
  320. local net = msgRet.list[len]
  321. net.camp = camp
  322. net.name = conf[1].name
  323. local len1 = 0
  324. for k,v in ipairs(conf) do
  325. len1 = len1 + 1
  326. local subNet = net.list[len1]
  327. subNet.cnt = v.cnt
  328. local len2 = 0
  329. for k,v in ipairs(v.attrs) do
  330. len2 = len2 + 1
  331. subNet.attrs[len2].key = v[1]
  332. subNet.attrs[len2].value = v[2]
  333. end
  334. subNet.attrs[0] = len2
  335. end
  336. net.list[0] = len1
  337. end
  338. msgRet.list[0] = len
  339. end
  340. Msg.send(msgRet,human.fd)
  341. end
  342. function getPosAttr(objList)
  343. local campList = {}
  344. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  345. local obj = objList[i]
  346. local config = CombatLogic.getConfigByObj(obj)
  347. if not config then return end
  348. campList[config.camp] = campList[config.camp] or 0
  349. campList[config.camp] = campList[config.camp] + 1
  350. end
  351. local attr = {}
  352. for k, v in pairs(campList) do
  353. local camp = k
  354. local cnt = v
  355. caclCampAttr(attr, camp, cnt)
  356. end
  357. return attr
  358. end
  359. function onFightBegin(human)
  360. local attrs1 = human.combat.posAttr[1]
  361. if attrs1 then
  362. for k,v in pairs(attrs1) do
  363. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.ATTACK_SIDE]) do
  364. local obj = CombatImpl.objList[pos]
  365. if obj then
  366. obj.sysAttr[k] = obj.sysAttr[k] + v
  367. obj.isSysAttrChange = true
  368. end
  369. end
  370. end
  371. end
  372. local attrs2 = human.combat.posAttr[2]
  373. if attrs2 then
  374. for k, v in pairs(attrs2) do
  375. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.DEFEND_SIDE]) do
  376. local obj = CombatImpl.objList[pos]
  377. if obj then
  378. obj.sysAttr[k] = obj.sysAttr[k] + v
  379. obj.isSysAttrChange = true
  380. end
  381. end
  382. end
  383. end
  384. end
  385. -- 获得 怪物组的 光环 血量加成
  386. function getCombatHpMaxJiaCheng(monsterOutID)
  387. local config = MonsterOutExcel[monsterOutID]
  388. local jobList = {}
  389. if config and #config.member > 5 then
  390. for i,member in ipairs(config.member) do
  391. local monsterID = member[1]
  392. local monsterConfig = MonsterExcel[monsterID]
  393. jobList[monsterConfig.job] = jobList[monsterConfig.job] or 0
  394. jobList[monsterConfig.job] = jobList[monsterConfig.job] + 1
  395. end
  396. end
  397. local attr = {}
  398. for k, v in pairs(jobList) do
  399. local camp = k
  400. local cnt = v
  401. caclCampAttr(attr, camp, cnt)
  402. end
  403. local buff = 0
  404. for k, v in pairs(attr) do
  405. if k == 203 then
  406. buff = v
  407. break
  408. end
  409. end
  410. return buff
  411. end
  412. function onLogin(human)
  413. posAttrQuery(human)
  414. formationQuery(human)
  415. sendAllCombatPos(human)
  416. end
  417. --获得type类型的战斗 上阵的魔兽id index 是指 冠军试炼场 有三个队列才用
  418. function getCombatMoshou(human,combatType)
  419. local _,helpList = getCombatHeros(human,combatType)
  420. return helpList[1]
  421. end
  422. function fontHelpNet(net,type,id,icon)
  423. net.type = type
  424. net.id = id or 0
  425. net.icon = icon or 0
  426. end
  427. function posQuery(human, combatType, group, param, flag)
  428. local combatConfig = CombatExcel.combat[combatType]
  429. if not combatConfig then return end
  430. local msgRet = Msg.gc.GC_COMBAT_POS_QUERY
  431. local len = 0
  432. if group and group ~= 0 then
  433. for k,v in ipairs(CombatExcel.combat) do
  434. if v.group == group then
  435. len = len + 1
  436. msgRet.list[len].type = k
  437. msgRet.list[len].name = v.name
  438. msgRet.list[len].isQuickTime = v.isQuickTime
  439. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(v.systemID)
  440. end
  441. end
  442. else
  443. len = len + 1
  444. msgRet.list[len].type = combatType
  445. msgRet.list[len].name = combatConfig.name
  446. msgRet.list[len].isQuickTime = combatConfig.isQuickTime
  447. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(combatConfig.systemID)
  448. end
  449. msgRet.type = combatType
  450. msgRet.teamType = combatConfig.teamType
  451. msgRet.list[0] = len
  452. local heroList,helpList,formation,combatHeroDB = getCombatHeros(human,combatType)
  453. local formationConf = FormationExcel[formation]
  454. msgRet.formation = formation
  455. len = 0
  456. local totalZdl = 0
  457. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  458. local uuid = heroList[i] or "0"
  459. local heroGrid = nil
  460. if combatType == CombatDefine.COMBAT_TYPE24 then
  461. heroGrid = LostTempleCombatLogic.getHeroGridByUuid(human, uuid)
  462. else
  463. heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  464. end
  465. if heroGrid then
  466. len = len + 1
  467. msgRet.heroList[len].pos = i
  468. msgRet.heroList[len].bagIndex = heroGrid.bagIndex
  469. msgRet.heroList[len].uuid = heroGrid.uuid
  470. --重新计算战力 缓存的情况下
  471. if not heroGrid.isLostTemple then
  472. if not human.heroAttrs[heroGrid.bagIndex] then
  473. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  474. end
  475. else
  476. LostTempleCombatLogic.getHeroAttrs(human, heroGrid.bagIndex)
  477. end
  478. totalZdl = totalZdl + heroGrid.zhandouli
  479. end
  480. end
  481. msgRet.totalZdl = totalZdl
  482. msgRet.heroList[0] = len
  483. len = 0
  484. if helpList[1] and helpList[1] > 0 then
  485. len = len + 1
  486. MoshouLogic.setPosHelp(msgRet.helpList[len],helpList[1])
  487. end
  488. msgRet.helpList[0] = len
  489. msgRet.backUpLock = canBackup(human)
  490. local mapID = nil
  491. if param ~= nil then
  492. local args = Util.split(param, "|")
  493. mapID = CombatLogic.getMapID(human, combatType, args)
  494. end
  495. msgRet.mapID = mapID or 0
  496. msgRet.jibanLv = RoleSystemLogic.getOpenLv(RoleSystemDefine.ROLE_SYS_ID_207)
  497. msgRet.flag = flag or 0
  498. local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
  499. msgRet.moshouLock = cjPrivilege and 1 or 0
  500. local skillID = MoshouLogic.getPutMoshouSkillID(human, combatType) or 0
  501. local skillConfig = SkillExcel.skill[skillID]
  502. msgRet.moshouSkill = skillConfig and skillConfig.icon or ""
  503. Msg.send(msgRet,human.fd)
  504. end
  505. function canBackup(human)
  506. local backupDB = human.db.combatBackup or 0
  507. return backupDB
  508. end
  509. function activeBackup(human)
  510. human.db.combatBackup = 1
  511. end
  512. function checkPos(formation,pos)
  513. local ret
  514. if pos == CombatDefine.COMBAT_BACKUP_POS then
  515. ret = 1
  516. else
  517. local posList = getPosList(formation)
  518. if posList[pos] then
  519. ret = 1
  520. end
  521. end
  522. return ret
  523. end
  524. function getFormationConfig(formation)
  525. return FormationExcel[formation]
  526. end
  527. function sendAllCombatPos(human)
  528. for k, v in pairs(CombatExcel.combat) do
  529. posQuery(human, k, v.group)
  530. JibanLogic.sendQuery(human, k, v.teamType)
  531. end
  532. end
  533. -- 是否是阵容中最后一个英雄
  534. function isLastInCombat(human,heroIndex)
  535. if not heroIndex or heroIndex == "" then return end
  536. local combatTb = Util.copyTable(human.db.combatHero)
  537. for teamType, combatHero in pairs(combatTb) do
  538. local isChange = nil
  539. for k, v in pairs(combatHero.list) do
  540. if type(v) == "table" then
  541. for k2, v2 in pairs(v) do
  542. if v2 == heroIndex then
  543. v[k2] = nil
  544. isChange = true
  545. end
  546. end
  547. elseif v == heroIndex then
  548. combatHero[k] = nil
  549. isChange = true
  550. end
  551. end
  552. if isChange then
  553. local heroCnt = 0
  554. for k, v in pairs(combatHero) do
  555. if type(v) == "table" then
  556. for k2, v2 in pairs(v) do
  557. if v2 ~= 0 then
  558. heroCnt = heroCnt + 1
  559. end
  560. end
  561. elseif v ~= 0 then
  562. heroCnt = heroCnt + 1
  563. end
  564. end
  565. if heroCnt == 0 then
  566. return true
  567. end
  568. end
  569. end
  570. end
  571. local restrict = nil
  572. function getRestrict(attacker,defender,key)
  573. if not restrict then
  574. restrict = {}
  575. for k,v in ipairs(DefineExcel.attrs) do
  576. restrict[v[1]] = v[2]
  577. end
  578. end
  579. if restrict[key] and DefineExcel.restrict[attacker.camp] == defender.camp then
  580. return restrict[key]
  581. end
  582. return 0
  583. end
  584. function setCombatByUnionWarGm(human, combatType)
  585. local heroList = {}
  586. local cnt = 0
  587. local useList = { }
  588. local fatherList = { }
  589. local helpList = {}
  590. -- 确定英雄存不存在
  591. for i = 1, 6 do
  592. local uuid
  593. for k, v in pairs(human.db.heroBag) do
  594. if k and k > 0 and v and v.uuid then
  595. uuid = v.uuid
  596. break
  597. end
  598. end
  599. if uuid then
  600. cnt = cnt + 1
  601. heroList[cnt] = uuid
  602. end
  603. end
  604. local combatHeroDB, teamType = getCombatHeroDB(human,combatType)
  605. combatHeroDB.formation = 1
  606. combatHeroDB.list = heroList
  607. combatHeroDB.helpList = helpList
  608. end
  609. -- 更新战力
  610. function updateZdl(human, uuidList)
  611. local list = Util.split(uuidList, "|")
  612. local msgRet = Msg.gc.GC_HERO_UPDATE_ZDL
  613. local len = 0
  614. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  615. local uuid = list[i]
  616. if uuid then
  617. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  618. if not heroGrid then return end
  619. if not human.heroAttrs[heroGrid.bagIndex] then
  620. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  621. len = len + 1
  622. msgRet.list[len].uuid = uuid
  623. msgRet.list[len].zdl = heroGrid.zhandouli
  624. end
  625. end
  626. end
  627. if len > 0 then
  628. msgRet.list[0] = len
  629. Msg.send(msgRet,human.fd)
  630. end
  631. end