CombatPosLogic.lua 20 KB

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