CombatPosLogic.lua 21 KB

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