CombatPosLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  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. -- 获取进攻方种族属性
  359. local attrs1 = human.combat.posAttr[1]
  360. if attrs1 then
  361. for k,v in pairs(attrs1) do
  362. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.ATTACK_SIDE]) do
  363. local obj = CombatImpl.objList[pos]
  364. if obj then
  365. obj.sysAttr[k] = obj.sysAttr[k] + v
  366. obj.isSysAttrChange = true
  367. end
  368. end
  369. end
  370. end
  371. -- 获取防御方种族属性
  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