CombatPosLogic.lua 20 KB

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