CombatPosLogic.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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. local function getSinglePosAttr(net, attrCfg)
  252. for k ,v in ipairs(attrCfg) do
  253. net[k].key = v[1]
  254. net[k].value = v[2]
  255. net[0] = k
  256. end
  257. end
  258. -- 发送阵型信息
  259. FormationInitFlag = nil
  260. function formationQuery(human)
  261. local msgRet = Msg.gc.GC_COMBAT_FORMATION_QUERY
  262. if not FormationInitFlag then
  263. FormationInitFlag = true
  264. local len = 0
  265. for k,v in ipairs(FormationExcel) do
  266. len = len + 1
  267. local net = msgRet.list[len]
  268. local len1 = 0
  269. for k1,v1 in ipairs(v.pos) do
  270. len1 = len1 + 1
  271. net.list[len1] = v1
  272. end
  273. net.list[0] = len1
  274. --阵法属性加成
  275. for k2,v2 in ipairs(v.attr) do
  276. getSinglePosAttr(net.posAttrLit[k2].posAttr, v2)
  277. net.posAttrLit[0] = k2
  278. end
  279. net.id = k
  280. net.lv = v.lv
  281. net.icon = v.icon
  282. net.name = v.name
  283. end
  284. msgRet.list[0] = len
  285. end
  286. msgRet.lv = human.db.lv
  287. Msg.send(msgRet,human.fd)
  288. end
  289. -- 去掉所有阵容中的数据
  290. function updateAllPos(human, uuid)
  291. heroIndexByDelForPos(human, uuid)
  292. local msgRet = Msg.gc.GC_HERO_UPDATE_ALL_POS
  293. Msg.send(msgRet,human.fd)
  294. end
  295. -- 英雄被分解 从默认出战中 去除
  296. function heroIndexByDelForPos(human, uuid)
  297. if not uuid or uuid == "0" or uuid == "" then return end
  298. for teamType, combatHero in pairs(human.db.combatHero) do
  299. if teamType ~= CombatDefine.COMBAT_TYPE10 then
  300. local isChange = nil
  301. for k, v in pairs(combatHero.list) do
  302. if v == uuid then
  303. combatHero.list[k] = nil
  304. isChange = true
  305. end
  306. end
  307. if isChange then
  308. onUpdatePos(human, teamType)
  309. posQuery(human, teamType)
  310. end
  311. end
  312. end
  313. end
  314. function caclCampAttr(attr, camp, cnt)
  315. -- 计算基础属性
  316. local conf = CombatPosExcel[camp]
  317. if basicsAttrExcel then
  318. for _, v in ipairs(conf) do
  319. if cnt == v.cnt then
  320. for k1,v1 in ipairs(v.attrs) do
  321. attr[v1[1]] = attr[v1[1]] or 0
  322. attr[v1[1]] = attr[v1[1]] + v1[2]
  323. end
  324. end
  325. end
  326. end
  327. end
  328. PosAttrInitFlag = nil
  329. function posAttrQuery(human)
  330. local msgRet = Msg.gc.GC_COMBAT_POS_ATTR_QUERY
  331. if not PosAttrInitFlag then
  332. PosAttrInitFlag = true
  333. local len = 0
  334. for k,v in ipairs(DefineExcel.attrs) do
  335. len = len + 1
  336. msgRet.attrs[len].key = v[1]
  337. msgRet.attrs[len].value = v[2]
  338. end
  339. msgRet.attrs[0] = len
  340. len = 0
  341. for camp = 1,CombatDefine.CAMP_ALL do
  342. local conf = CombatPosExcel[camp]
  343. len = len + 1
  344. local net = msgRet.list[len]
  345. net.camp = camp
  346. net.name = conf[1].name
  347. local len1 = 0
  348. for k,v in ipairs(conf) do
  349. len1 = len1 + 1
  350. local subNet = net.list[len1]
  351. subNet.cnt = v.cnt
  352. local len2 = 0
  353. for k,v in ipairs(v.attrs) do
  354. len2 = len2 + 1
  355. subNet.attrs[len2].key = v[1]
  356. subNet.attrs[len2].value = v[2]
  357. end
  358. subNet.attrs[0] = len2
  359. end
  360. net.list[0] = len1
  361. end
  362. msgRet.list[0] = len
  363. end
  364. Msg.send(msgRet,human.fd)
  365. end
  366. function getPosAttr(objList)
  367. local campList = {}
  368. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  369. local obj = objList[i]
  370. local config = CombatLogic.getConfigByObj(obj)
  371. if not config then return end
  372. campList[config.camp] = campList[config.camp] or 0
  373. campList[config.camp] = campList[config.camp] + 1
  374. end
  375. local attr = {}
  376. for k, v in pairs(campList) do
  377. local camp = k
  378. local cnt = v
  379. caclCampAttr(attr, camp, cnt)
  380. end
  381. return attr
  382. end
  383. local function calcSinglePosAttr(posCfg, pos, obj)
  384. local idx = 0
  385. for k, v in ipairs(posCfg.pos) do
  386. if v == obj.formationPos then
  387. idx = k
  388. break
  389. end
  390. end
  391. local posAttr = posCfg.attr[idx]
  392. for _, v in ipairs(posAttr or {}) do
  393. local attrType = v[1]
  394. local attrValue = v[2]
  395. obj.sysAttr[attrType] = (obj.sysAttr[attrType] or 0) + attrValue
  396. obj.isSysAttrChange = true
  397. end
  398. end
  399. local function posAttrAdd(formation, posList)
  400. --阵法中单个位置的属性加成
  401. local posCfg = getFormationConfig(formation)
  402. if posCfg then
  403. for _,pos in ipairs(posList) do
  404. local obj = CombatImpl.objList[pos]
  405. if obj then
  406. calcSinglePosAttr(posCfg, pos, obj)
  407. end
  408. end
  409. end
  410. end
  411. function onFightBegin(human)
  412. -- 获取进攻方种族属性
  413. local attrs1 = human.combat.posAttr[1]
  414. if attrs1 then
  415. for k,v in pairs(attrs1) do
  416. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.ATTACK_SIDE]) do
  417. local obj = CombatImpl.objList[pos]
  418. if obj then
  419. obj.sysAttr[k] = obj.sysAttr[k] + v
  420. obj.isSysAttrChange = true
  421. end
  422. end
  423. end
  424. end
  425. -- 获取防御方种族属性
  426. local attrs2 = human.combat.posAttr[2]
  427. if attrs2 then
  428. for k, v in pairs(attrs2) do
  429. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.DEFEND_SIDE]) do
  430. local obj = CombatImpl.objList[pos]
  431. if obj then
  432. obj.sysAttr[k] = obj.sysAttr[k] + v
  433. obj.isSysAttrChange = true
  434. end
  435. end
  436. end
  437. end
  438. --阵法中位置的属性加成
  439. posAttrAdd(human.combat.atkFormation, CombatDefine.SIDE2POS[CombatDefine.ATTACK_SIDE])
  440. posAttrAdd(human.combat.defFormation, CombatDefine.SIDE2POS[CombatDefine.DEFEND_SIDE])
  441. end
  442. -- 获得 怪物组的 光环 血量加成
  443. function getCombatHpMaxJiaCheng(monsterOutID)
  444. local config = MonsterOutExcel[monsterOutID]
  445. local jobList = {}
  446. if config and #config.member > 5 then
  447. for i,member in ipairs(config.member) do
  448. local monsterID = member[1]
  449. local monsterConfig = MonsterExcel[monsterID]
  450. jobList[monsterConfig.job] = jobList[monsterConfig.job] or 0
  451. jobList[monsterConfig.job] = jobList[monsterConfig.job] + 1
  452. end
  453. end
  454. local attr = {}
  455. for k, v in pairs(jobList) do
  456. local camp = k
  457. local cnt = v
  458. caclCampAttr(attr, camp, cnt)
  459. end
  460. local buff = 0
  461. for k, v in pairs(attr) do
  462. if k == 203 then
  463. buff = v
  464. break
  465. end
  466. end
  467. return buff
  468. end
  469. function onLogin(human)
  470. posAttrQuery(human)
  471. formationQuery(human)
  472. sendAllCombatPos(human)
  473. end
  474. --获得type类型的战斗 上阵的魔兽id index 是指 冠军试炼场 有三个队列才用
  475. function getCombatMoshou(human,combatType)
  476. local _,helpList = getCombatHeros(human,combatType)
  477. return helpList[1]
  478. end
  479. function fontHelpNet(net,type,id,icon)
  480. net.type = type
  481. net.id = id or 0
  482. net.icon = icon or 0
  483. end
  484. function posQuery(human, combatType, group, param, flag)
  485. local combatConfig = CombatExcel.combat[combatType]
  486. if not combatConfig then return end
  487. local msgRet = Msg.gc.GC_COMBAT_POS_QUERY
  488. local len = 0
  489. local newIsQuickTime
  490. if combatType == CombatDefine.COMBAT_TYPE1 then
  491. newIsQuickTime = getTalismanAdd(human)
  492. end
  493. if group and group ~= 0 then
  494. for k,v in ipairs(CombatExcel.combat) do
  495. if v.group == group then
  496. len = len + 1
  497. msgRet.list[len].type = k
  498. msgRet.list[len].name = v.name
  499. -- msgRet.list[len].isQuickTime = v.isQuickTime
  500. msgRet.list[len].isQuickTime = newIsQuickTime and newIsQuickTime or v.isQuickTime
  501. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(v.systemID)
  502. end
  503. end
  504. else
  505. len = len + 1
  506. msgRet.list[len].type = combatType
  507. msgRet.list[len].name = combatConfig.name
  508. -- msgRet.list[len].isQuickTime = combatConfig.isQuickTime
  509. msgRet.list[len].isQuickTime = newIsQuickTime and newIsQuickTime or combatConfig.isQuickTime
  510. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(combatConfig.systemID)
  511. end
  512. msgRet.type = combatType
  513. msgRet.teamType = combatConfig.teamType
  514. msgRet.list[0] = len
  515. local heroList,helpList,formation,combatHeroDB = getCombatHeros(human,combatType)
  516. local formationConf = FormationExcel[formation]
  517. msgRet.formation = formation
  518. len = 0
  519. local totalZdl = 0
  520. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  521. local uuid = heroList[i] or "0"
  522. local heroGrid = nil
  523. if combatType == CombatDefine.COMBAT_TYPE24 then
  524. heroGrid = LostTempleCombatLogic.getHeroGridByUuid(human, uuid)
  525. else
  526. heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  527. end
  528. if heroGrid then
  529. len = len + 1
  530. msgRet.heroList[len].pos = i
  531. msgRet.heroList[len].bagIndex = heroGrid.bagIndex
  532. msgRet.heroList[len].uuid = heroGrid.uuid
  533. --重新计算战力 缓存的情况下
  534. if not heroGrid.isLostTemple then
  535. if not human.heroAttrs[heroGrid.bagIndex] then
  536. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  537. end
  538. else
  539. LostTempleCombatLogic.getHeroAttrs(human, heroGrid.bagIndex)
  540. end
  541. totalZdl = totalZdl + heroGrid.zhandouli
  542. end
  543. end
  544. msgRet.totalZdl = totalZdl
  545. msgRet.heroList[0] = len
  546. len = 0
  547. if helpList[1] and helpList[1] > 0 then
  548. len = len + 1
  549. MoshouLogic.setPosHelp(msgRet.helpList[len],helpList[1])
  550. end
  551. msgRet.helpList[0] = len
  552. msgRet.backUpLock = canBackup(human)
  553. local mapID = nil
  554. if param ~= nil then
  555. local args = Util.split(param, "|")
  556. mapID = CombatLogic.getMapID(human, combatType, args)
  557. end
  558. msgRet.mapID = mapID or 0
  559. msgRet.jibanLv = RoleSystemLogic.getOpenLv(RoleSystemDefine.ROLE_SYS_ID_207)
  560. msgRet.flag = flag or 0
  561. local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
  562. msgRet.moshouLock = cjPrivilege and 1 or 0
  563. local skillID = MoshouLogic.getPutMoshouSkillID(human, combatType) or 0
  564. local skillConfig = SkillExcel.skill[skillID]
  565. msgRet.moshouSkill = skillConfig and skillConfig.icon or ""
  566. Msg.send(msgRet,human.fd)
  567. end
  568. function canBackup(human)
  569. local backupDB = human.db.combatBackup or 0
  570. return backupDB
  571. end
  572. function activeBackup(human)
  573. human.db.combatBackup = 1
  574. end
  575. function checkPos(formation,pos)
  576. local ret
  577. if pos == CombatDefine.COMBAT_BACKUP_POS then
  578. ret = 1
  579. else
  580. local posList = getPosList(formation)
  581. if posList[pos] then
  582. ret = 1
  583. end
  584. end
  585. return ret
  586. end
  587. function getFormationConfig(formation)
  588. return FormationExcel[formation]
  589. end
  590. function sendAllCombatPos(human)
  591. for k, v in pairs(CombatExcel.combat) do
  592. posQuery(human, k, v.group)
  593. JibanLogic.sendQuery(human, k, v.teamType)
  594. end
  595. end
  596. -- 是否是阵容中最后一个英雄
  597. function isLastInCombat(human,heroIndex)
  598. if not heroIndex or heroIndex == "" then return end
  599. local combatTb = Util.copyTable(human.db.combatHero)
  600. for teamType, combatHero in pairs(combatTb) do
  601. local isChange = nil
  602. for k, v in pairs(combatHero.list) do
  603. if type(v) == "table" then
  604. for k2, v2 in pairs(v) do
  605. if v2 == heroIndex then
  606. v[k2] = nil
  607. isChange = true
  608. end
  609. end
  610. elseif v == heroIndex then
  611. combatHero[k] = nil
  612. isChange = true
  613. end
  614. end
  615. if isChange then
  616. local heroCnt = 0
  617. for k, v in pairs(combatHero) do
  618. if type(v) == "table" then
  619. for k2, v2 in pairs(v) do
  620. if v2 ~= 0 then
  621. heroCnt = heroCnt + 1
  622. end
  623. end
  624. elseif v ~= 0 then
  625. heroCnt = heroCnt + 1
  626. end
  627. end
  628. if heroCnt == 0 then
  629. return true
  630. end
  631. end
  632. end
  633. end
  634. local restrict = nil
  635. function getRestrict(attacker,defender,key)
  636. if not restrict then
  637. restrict = {}
  638. for k,v in ipairs(DefineExcel.attrs) do
  639. restrict[v[1]] = v[2]
  640. end
  641. end
  642. if restrict[key] and DefineExcel.restrict[attacker.camp] == defender.camp then
  643. return restrict[key]
  644. end
  645. return 0
  646. end
  647. function setCombatByUnionWarGm(human, combatType)
  648. local heroList = {}
  649. local cnt = 0
  650. local useList = { }
  651. local fatherList = { }
  652. local helpList = {}
  653. -- 确定英雄存不存在
  654. for i = 1, 6 do
  655. local uuid
  656. for k, v in pairs(human.db.heroBag) do
  657. if k and k > 0 and v and v.uuid then
  658. uuid = v.uuid
  659. break
  660. end
  661. end
  662. if uuid then
  663. cnt = cnt + 1
  664. heroList[cnt] = uuid
  665. end
  666. end
  667. local combatHeroDB, teamType = getCombatHeroDB(human,combatType)
  668. combatHeroDB.formation = 1
  669. combatHeroDB.list = heroList
  670. combatHeroDB.helpList = helpList
  671. end
  672. -- 更新战力
  673. function updateZdl(human, uuidList)
  674. local list = Util.split(uuidList, "|")
  675. local msgRet = Msg.gc.GC_HERO_UPDATE_ZDL
  676. local len = 0
  677. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  678. local uuid = list[i]
  679. if uuid then
  680. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  681. if not heroGrid then return end
  682. if not human.heroAttrs[heroGrid.bagIndex] then
  683. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  684. len = len + 1
  685. msgRet.list[len].uuid = uuid
  686. msgRet.list[len].zdl = heroGrid.zhandouli
  687. end
  688. end
  689. end
  690. if len > 0 then
  691. msgRet.list[0] = len
  692. Msg.send(msgRet,human.fd)
  693. end
  694. end