CombatPosLogic.lua 24 KB

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