CombatPosLogic.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. local function calcSinglePosAttr(posCfg, pos, obj)
  367. local idx = 0
  368. for k, v in ipairs(posCfg.pos) do
  369. if v == pos then
  370. idx = k
  371. break
  372. end
  373. end
  374. local posAttr = posCfg.attr[idx]
  375. for _, v in ipairs(posAttr or {}) do
  376. local attrType = v[1]
  377. local attrValue = v[2]
  378. obj.sysAttr[attrType] = (obj.sysAttr[attrType] or 0) + attrValue
  379. obj.isSysAttrChange = true
  380. end
  381. end
  382. function getPosAttr(objList, formation)
  383. local campList = {}
  384. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  385. local obj = objList[i]
  386. local config = CombatLogic.getConfigByObj(obj)
  387. if not config then return end
  388. campList[config.camp] = campList[config.camp] or 0
  389. campList[config.camp] = campList[config.camp] + 1
  390. end
  391. local attr = {}
  392. for k, v in pairs(campList) do
  393. local camp = k
  394. local cnt = v
  395. caclCampAttr(attr, camp, cnt)
  396. end
  397. --阵法中单个位置的属性加成
  398. local posCfg = getFormationConfig(formation)
  399. if posCfg then
  400. for pos, obj in pairs(objList) do
  401. calcSinglePosAttr(posCfg, pos, obj)
  402. end
  403. end
  404. return attr
  405. end
  406. function onFightBegin(human)
  407. -- 获取进攻方种族属性
  408. local attrs1 = human.combat.posAttr[1]
  409. if attrs1 then
  410. for k,v in pairs(attrs1) do
  411. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.ATTACK_SIDE]) do
  412. local obj = CombatImpl.objList[pos]
  413. if obj then
  414. obj.sysAttr[k] = obj.sysAttr[k] + v
  415. obj.isSysAttrChange = true
  416. end
  417. end
  418. end
  419. end
  420. -- 获取防御方种族属性
  421. local attrs2 = human.combat.posAttr[2]
  422. if attrs2 then
  423. for k, v in pairs(attrs2) do
  424. for _,pos in ipairs(CombatDefine.SIDE2POS[CombatDefine.DEFEND_SIDE]) do
  425. local obj = CombatImpl.objList[pos]
  426. if obj then
  427. obj.sysAttr[k] = obj.sysAttr[k] + v
  428. obj.isSysAttrChange = true
  429. end
  430. end
  431. end
  432. end
  433. end
  434. -- 获得 怪物组的 光环 血量加成
  435. function getCombatHpMaxJiaCheng(monsterOutID)
  436. local config = MonsterOutExcel[monsterOutID]
  437. local jobList = {}
  438. if config and #config.member > 5 then
  439. for i,member in ipairs(config.member) do
  440. local monsterID = member[1]
  441. local monsterConfig = MonsterExcel[monsterID]
  442. jobList[monsterConfig.job] = jobList[monsterConfig.job] or 0
  443. jobList[monsterConfig.job] = jobList[monsterConfig.job] + 1
  444. end
  445. end
  446. local attr = {}
  447. for k, v in pairs(jobList) do
  448. local camp = k
  449. local cnt = v
  450. caclCampAttr(attr, camp, cnt)
  451. end
  452. local buff = 0
  453. for k, v in pairs(attr) do
  454. if k == 203 then
  455. buff = v
  456. break
  457. end
  458. end
  459. return buff
  460. end
  461. function onLogin(human)
  462. posAttrQuery(human)
  463. formationQuery(human)
  464. sendAllCombatPos(human)
  465. end
  466. --获得type类型的战斗 上阵的魔兽id index 是指 冠军试炼场 有三个队列才用
  467. function getCombatMoshou(human,combatType)
  468. local _,helpList = getCombatHeros(human,combatType)
  469. return helpList[1]
  470. end
  471. function fontHelpNet(net,type,id,icon)
  472. net.type = type
  473. net.id = id or 0
  474. net.icon = icon or 0
  475. end
  476. function posQuery(human, combatType, group, param, flag)
  477. local combatConfig = CombatExcel.combat[combatType]
  478. if not combatConfig then return end
  479. local msgRet = Msg.gc.GC_COMBAT_POS_QUERY
  480. local len = 0
  481. local newIsQuickTime
  482. if combatType == CombatDefine.COMBAT_TYPE1 then
  483. newIsQuickTime = getTalismanAdd(human)
  484. end
  485. if group and group ~= 0 then
  486. for k,v in ipairs(CombatExcel.combat) do
  487. if v.group == group then
  488. len = len + 1
  489. msgRet.list[len].type = k
  490. msgRet.list[len].name = v.name
  491. -- msgRet.list[len].isQuickTime = v.isQuickTime
  492. msgRet.list[len].isQuickTime = newIsQuickTime and newIsQuickTime or v.isQuickTime
  493. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(v.systemID)
  494. end
  495. end
  496. else
  497. len = len + 1
  498. msgRet.list[len].type = combatType
  499. msgRet.list[len].name = combatConfig.name
  500. -- msgRet.list[len].isQuickTime = combatConfig.isQuickTime
  501. msgRet.list[len].isQuickTime = newIsQuickTime and newIsQuickTime or combatConfig.isQuickTime
  502. msgRet.list[len].needLv = RoleSystemLogic.getOpenLv(combatConfig.systemID)
  503. end
  504. msgRet.type = combatType
  505. msgRet.teamType = combatConfig.teamType
  506. msgRet.list[0] = len
  507. local heroList,helpList,formation,combatHeroDB = getCombatHeros(human,combatType)
  508. local formationConf = FormationExcel[formation]
  509. msgRet.formation = formation
  510. len = 0
  511. local totalZdl = 0
  512. for i = 1,CombatDefine.COMBAT_HERO_CNT do
  513. local uuid = heroList[i] or "0"
  514. local heroGrid = nil
  515. if combatType == CombatDefine.COMBAT_TYPE24 then
  516. heroGrid = LostTempleCombatLogic.getHeroGridByUuid(human, uuid)
  517. else
  518. heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  519. end
  520. if heroGrid then
  521. len = len + 1
  522. msgRet.heroList[len].pos = i
  523. msgRet.heroList[len].bagIndex = heroGrid.bagIndex
  524. msgRet.heroList[len].uuid = heroGrid.uuid
  525. --重新计算战力 缓存的情况下
  526. if not heroGrid.isLostTemple then
  527. if not human.heroAttrs[heroGrid.bagIndex] then
  528. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  529. end
  530. else
  531. LostTempleCombatLogic.getHeroAttrs(human, heroGrid.bagIndex)
  532. end
  533. totalZdl = totalZdl + heroGrid.zhandouli
  534. end
  535. end
  536. msgRet.totalZdl = totalZdl
  537. msgRet.heroList[0] = len
  538. len = 0
  539. if helpList[1] and helpList[1] > 0 then
  540. len = len + 1
  541. MoshouLogic.setPosHelp(msgRet.helpList[len],helpList[1])
  542. end
  543. msgRet.helpList[0] = len
  544. msgRet.backUpLock = canBackup(human)
  545. local mapID = nil
  546. if param ~= nil then
  547. local args = Util.split(param, "|")
  548. mapID = CombatLogic.getMapID(human, combatType, args)
  549. end
  550. msgRet.mapID = mapID or 0
  551. msgRet.jibanLv = RoleSystemLogic.getOpenLv(RoleSystemDefine.ROLE_SYS_ID_207)
  552. msgRet.flag = flag or 0
  553. local cjPrivilege = ChengjiuLogic.checkPrivilege(human, ChengjiuDefine.PRIVILEGE_TYPE_8)
  554. msgRet.moshouLock = cjPrivilege and 1 or 0
  555. local skillID = MoshouLogic.getPutMoshouSkillID(human, combatType) or 0
  556. local skillConfig = SkillExcel.skill[skillID]
  557. msgRet.moshouSkill = skillConfig and skillConfig.icon or ""
  558. Msg.send(msgRet,human.fd)
  559. end
  560. function canBackup(human)
  561. local backupDB = human.db.combatBackup or 0
  562. return backupDB
  563. end
  564. function activeBackup(human)
  565. human.db.combatBackup = 1
  566. end
  567. function checkPos(formation,pos)
  568. local ret
  569. if pos == CombatDefine.COMBAT_BACKUP_POS then
  570. ret = 1
  571. else
  572. local posList = getPosList(formation)
  573. if posList[pos] then
  574. ret = 1
  575. end
  576. end
  577. return ret
  578. end
  579. function getFormationConfig(formation)
  580. return FormationExcel[formation]
  581. end
  582. function sendAllCombatPos(human)
  583. for k, v in pairs(CombatExcel.combat) do
  584. posQuery(human, k, v.group)
  585. JibanLogic.sendQuery(human, k, v.teamType)
  586. end
  587. end
  588. -- 是否是阵容中最后一个英雄
  589. function isLastInCombat(human,heroIndex)
  590. if not heroIndex or heroIndex == "" then return end
  591. local combatTb = Util.copyTable(human.db.combatHero)
  592. for teamType, combatHero in pairs(combatTb) do
  593. local isChange = nil
  594. for k, v in pairs(combatHero.list) do
  595. if type(v) == "table" then
  596. for k2, v2 in pairs(v) do
  597. if v2 == heroIndex then
  598. v[k2] = nil
  599. isChange = true
  600. end
  601. end
  602. elseif v == heroIndex then
  603. combatHero[k] = nil
  604. isChange = true
  605. end
  606. end
  607. if isChange then
  608. local heroCnt = 0
  609. for k, v in pairs(combatHero) do
  610. if type(v) == "table" then
  611. for k2, v2 in pairs(v) do
  612. if v2 ~= 0 then
  613. heroCnt = heroCnt + 1
  614. end
  615. end
  616. elseif v ~= 0 then
  617. heroCnt = heroCnt + 1
  618. end
  619. end
  620. if heroCnt == 0 then
  621. return true
  622. end
  623. end
  624. end
  625. end
  626. local restrict = nil
  627. function getRestrict(attacker,defender,key)
  628. if not restrict then
  629. restrict = {}
  630. for k,v in ipairs(DefineExcel.attrs) do
  631. restrict[v[1]] = v[2]
  632. end
  633. end
  634. if restrict[key] and DefineExcel.restrict[attacker.camp] == defender.camp then
  635. return restrict[key]
  636. end
  637. return 0
  638. end
  639. function setCombatByUnionWarGm(human, combatType)
  640. local heroList = {}
  641. local cnt = 0
  642. local useList = { }
  643. local fatherList = { }
  644. local helpList = {}
  645. -- 确定英雄存不存在
  646. for i = 1, 6 do
  647. local uuid
  648. for k, v in pairs(human.db.heroBag) do
  649. if k and k > 0 and v and v.uuid then
  650. uuid = v.uuid
  651. break
  652. end
  653. end
  654. if uuid then
  655. cnt = cnt + 1
  656. heroList[cnt] = uuid
  657. end
  658. end
  659. local combatHeroDB, teamType = getCombatHeroDB(human,combatType)
  660. combatHeroDB.formation = 1
  661. combatHeroDB.list = heroList
  662. combatHeroDB.helpList = helpList
  663. end
  664. -- 更新战力
  665. function updateZdl(human, uuidList)
  666. local list = Util.split(uuidList, "|")
  667. local msgRet = Msg.gc.GC_HERO_UPDATE_ZDL
  668. local len = 0
  669. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  670. local uuid = list[i]
  671. if uuid then
  672. local heroGrid = HeroLogic.getHeroGridByUuid(human, uuid)
  673. if not heroGrid then return end
  674. if not human.heroAttrs[heroGrid.bagIndex] then
  675. RoleAttr.doCalcHero(human, heroGrid.bagIndex)
  676. len = len + 1
  677. msgRet.list[len].uuid = uuid
  678. msgRet.list[len].zdl = heroGrid.zhandouli
  679. end
  680. end
  681. end
  682. if len > 0 then
  683. msgRet.list[0] = len
  684. Msg.send(msgRet,human.fd)
  685. end
  686. end