CombatPosLogic.lua 24 KB

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