CombatPosLogic.lua 20 KB

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