AnotherWorldBattleNS.lua 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. -- 异界之战
  2. --db
  3. --[=[
  4. human.db.anotherWorlBattle = {
  5. startTime = nil,
  6. formation = {
  7. [cityId1] = {
  8. [pointIdx1] = {list = {},helpList = {},formation = 1,jiban = {}, elfList = {}}
  9. [pointIdx2] = {list = {},helpList = {},formation = 1,jiban = {}, elfList = {}}
  10. },
  11. [cityId2] = {
  12. [pointIdx1] = {list = {},helpList = {},formation = 1,jiban = {}, elfList = {}}
  13. [pointIdx2] = {list = {},helpList = {},formation = 1,jiban = {}, elfList = {}}
  14. },
  15. }
  16. }
  17. ]=]--
  18. local Config = require("Config")
  19. local Msg = require("core.Msg")
  20. local Lang = require("common.Lang")
  21. local ObjHuman = require("core.ObjHuman")
  22. local Broadcast = require("broadcast.Broadcast")
  23. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  24. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  25. local CombatDefine = require("combat.CombatDefine")
  26. local RoleDBLogic = require("role.RoleDBLogic")
  27. local CombatPosLogic = require("combat.CombatPosLogic")
  28. local CombatLogic = require("combat.CombatLogic")
  29. local MailExcel = require("excel.mail")
  30. local Util = require("common.Util")
  31. local InnerMsg = require("core.InnerMsg")
  32. local RoleHeadLogic = require("role.RoleHeadLogic")
  33. local MailManager = require("mail.MailManager")
  34. local Log = require("common.Log")
  35. local Timer = require("core.Timer")
  36. local Grid = require("bag.Grid")
  37. local UnionLogic = require("union.UnionLogic")
  38. local BillboardLogic = require("billboard.BillboardLogic")
  39. local BillboardDefine = require("billboard.BillboardDefine")
  40. local AnotherWorldBattleDefine = require("anotherWorldBattle.AnotherWorldBattleDefine")
  41. local AnotherWorldBattleConfig = require("excel.anotherWorldBattle")
  42. local MonsterGrid = require("monster.MonsterGrid")
  43. local RoleConfig = require("excel.role")
  44. local MonsterExcel = require("excel.monster")
  45. local HeroExcel = require("excel.hero")
  46. local MiddleCommonLogic = require("middle.MiddleCommonLogic")
  47. local CombatImpl = require("combat.CombatImpl")
  48. local RoleAttr = require("role.RoleAttr")
  49. local CommonDB = require("common.CommonDB")
  50. local HeroLogic
  51. local function writeLog(logStr)
  52. Log.write(Log.LOGID_OSS_ANOTHERWORLDBATTLE, logStr)
  53. end
  54. local function sendMail(mailId, receiverUuid, itemArray, extraInfo, rank)
  55. if not mailId or not receiverUuid then
  56. return
  57. end
  58. local mailCfg = MailExcel.mail[mailId]
  59. local content = mailCfg.content
  60. if mailId == AnotherWorldBattleDefine.AB_AWARD_MAIL_ID then
  61. local v1,v2,v3,v4,v5
  62. v1,v2,v3 = extraInfo and extraInfo[1] or 0, extraInfo and extraInfo[2] or 0, extraInfo and extraInfo[3] or 0
  63. v4,v5 = extraInfo and extraInfo[4] or 0, extraInfo and extraInfo[5] or 0
  64. content = Util.format(content, v1,v2,v3,v4,v5)
  65. elseif mailId == AnotherWorldBattleDefine.AB_UNIONRANK_AWARD_MAIL_ID then
  66. content = Util.format(content, rank)
  67. else
  68. if rank > AnotherWorldBattleDefine.AB_RANK_MAX_NUM then
  69. rank = "50+"
  70. end
  71. content = Util.format(content, rank)
  72. end
  73. MailManager.add(MailManager.SYSTEM, receiverUuid, mailCfg.title, content, itemArray, mailCfg.senderName or "GM")
  74. end
  75. local function createRewardQueue()
  76. local issueRewardQueue = {
  77. playerArray = {},
  78. insertMaxNum = 100, -- 一次最多插入数据库的邮件数量
  79. repeatMaxTimes = 3, -- 重试次数
  80. repeatTb = {},
  81. extraInfo = {},
  82. }
  83. function issueRewardQueue:add(playerInfo)
  84. table.insert(self.playerArray, playerInfo)
  85. end
  86. function issueRewardQueue:insertDB()
  87. local maxNum = math.min(self.insertMaxNum, #self.playerArray)
  88. for i=1, maxNum do
  89. local resTag = AnotherWorldBattleDefine.AB_MAIL_SUCC_TAG
  90. local playerInfo = table.remove(self.playerArray)
  91. local playerUuid = playerInfo[1]
  92. local mailId = playerInfo[3]
  93. local rank = playerInfo[4]
  94. local ok, err = pcall(sendMail, mailId, playerUuid, playerInfo[2], issueRewardQueue.extraInfo, rank)
  95. if not ok then
  96. if not self.repeatTb[playerUuid] or self.repeatTb[playerUuid] < self.repeatMaxTimes then
  97. issueRewardQueue:add(playerInfo)
  98. self.repeatTb[playerUuid] = (self.repeatTb[playerUuid] or 0) + 1
  99. end
  100. resTag = AnotherWorldBattleDefine.AB_MAIL_FAIL_TAG
  101. end
  102. -- 写入日志
  103. local str = string.format("Result: %s, playerUuid: %s, mailId: %d, insertErrTimes: %d, errInfo: %s",
  104. resTag, playerUuid, mailId, self.repeatTb[playerUuid] or 0, err)
  105. writeLog(str)
  106. end
  107. if #self.playerArray > 0 then
  108. Timer.addLater(2, self.insertDB, self)
  109. end
  110. end
  111. return issueRewardQueue
  112. end
  113. -- 获取当天是星期几
  114. local function getWDay()
  115. return Util.getWeekDay()
  116. end
  117. -- 开服天数和玩家等级检查
  118. local function baseCondCheck(human)
  119. return RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1216)
  120. end
  121. -- 根据最近一轮活动开启时间, 判断当前是否处于活动开启时间范围
  122. local function actStartTimeCheck()
  123. local wDay = getWDay()
  124. if wDay > AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[2] and wDay < AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[1] then
  125. return false
  126. end
  127. local startTime = CommonDB.getValueByKey(CommonDB.KEY_ANOTHERWORLDBATTLE_START_TI)
  128. if not startTime then
  129. return false
  130. end
  131. if not IsRuning(startTime) then
  132. return false
  133. end
  134. return true
  135. end
  136. -- 计算怪物战力
  137. local function calcMonsterPower(monsterOutID)
  138. local power = 0
  139. local objList = MonsterGrid.createMonsterObjListByMonsterOutID(monsterOutID)
  140. if not objList then
  141. return power
  142. end
  143. for _, monster in ipairs(objList) do
  144. power = power + (monster.power or 0)
  145. end
  146. return power
  147. end
  148. -- 根据据点所属城池,计算多个据点每分钟产出道具数量之和
  149. local function calcPointAward(cityIdArr)
  150. local myUnionAwardNum = 0
  151. if cityIdArr then
  152. for _, cityId in ipairs(cityIdArr) do
  153. local targetCityCfg = AnotherWorldBattleConfig.city[cityId]
  154. if targetCityCfg.isBaseCity == 1 then
  155. myUnionAwardNum = myUnionAwardNum + targetCityCfg.cityAward[2] * AnotherWorldBattleDefine.AB_POINT_MAX_NUM
  156. else
  157. myUnionAwardNum = myUnionAwardNum + targetCityCfg.cityAward[2]
  158. end
  159. end
  160. end
  161. return myUnionAwardNum
  162. end
  163. -- 获取展示部位的固定Id
  164. local function getDefaultShowId(showType, idx)
  165. local targetCfg
  166. if showType == 1 then
  167. targetCfg = RoleConfig.head
  168. else
  169. targetCfg = RoleConfig.headFrame
  170. end
  171. local t = {}
  172. for k in pairs(targetCfg) do
  173. t[#t+1] = k
  174. end
  175. table.sort(t)
  176. return t[idx] or t[1]
  177. end
  178. -- 单个英雄数据
  179. local function getHeroInfo(human, targetHeroUuid)
  180. HeroLogic = HeroLogic or require("hero.HeroLogic")
  181. local heroGrid = HeroLogic.getHeroGridByUuid(human, targetHeroUuid)
  182. if heroGrid then
  183. local heroCfg = HeroExcel.hero[heroGrid.id]
  184. RoleAttr.calcHeroGrid(heroGrid, nil, human)
  185. local heroInfo = {
  186. heroUuid = targetHeroUuid,
  187. heroStar = heroGrid.star,
  188. heroLevel = heroGrid.lv,
  189. heroCamp = heroGrid.camp or heroCfg.camp,
  190. heroBody = heroCfg.body,
  191. heroIcon = heroGrid.head or heroCfg.head,
  192. heroPower = heroGrid.zhandouli,
  193. heroId = heroGrid.id,
  194. heroQuality = heroCfg.grade,
  195. }
  196. return heroInfo
  197. end
  198. end
  199. -- 获取上阵英雄数据
  200. local function getHeroListInfo(human, targetHeroUuid)
  201. local len = 0
  202. local heroArr = {}
  203. local heroList = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE35)
  204. if not next(heroList) then
  205. return heroArr
  206. end
  207. for _, heroUuid in pairs(heroList) do
  208. if (heroUuid ~= "" and heroUuid ~= "0") and (not targetHeroUuid or targetHeroUuid == heroUuid) then
  209. len = len + 1
  210. heroArr[len] = getHeroInfo(human, heroUuid)
  211. end
  212. end
  213. if len == 0 then
  214. return
  215. end
  216. return heroArr
  217. end
  218. -- 生成展示数据
  219. local function generateShowInfo(human)
  220. local showInfo = {
  221. name = human.db.name,
  222. lv = human.db.lv,
  223. power = human.db.zhandouli,
  224. }
  225. showInfo.head = RoleHeadLogic.getRoleAppearance(human, RoleHeadLogic.HEAD_TYPE_1)
  226. showInfo.headFrame = RoleHeadLogic.getRoleAppearance(human, RoleHeadLogic.HEAD_TYPE_2)
  227. -- showInfo.body = RoleHeadLogic.getRoleAppearance(human, RoleHeadLogic.HEAD_TYPE_3)
  228. showInfo.heroArr = getHeroListInfo(human)
  229. return showInfo
  230. end
  231. -- 阵容数据检查,如果不在 "活动开启且战斗阶段" 则清空
  232. local function formationDataCheeck(human)
  233. if not human.db.anotherWorlBattle then
  234. return
  235. end
  236. -- 不在战斗阶段时间范围
  237. local wDay = getWDay()
  238. if not (AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[1] <= wDay and AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] >= wDay) then
  239. human.db.anotherWorlBattle = nil
  240. return
  241. end
  242. -- 处于战斗阶段最后一天, 但是活动已经结束
  243. local now = os.time()
  244. local toDayStartTime = Util.getDayStartTime(now)
  245. if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] == wDay and now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
  246. human.db.anotherWorlBattle = nil
  247. return
  248. end
  249. -- 处于战斗阶段时间范围内, 但是活动未开(因为两轮活动时间间隔至少9天)
  250. local startTime = human.db.anotherWorlBattle.startTime
  251. local diffDays = Util.diffDay(startTime)
  252. if diffDays > 3 then
  253. human.db.anotherWorlBattle = nil
  254. end
  255. end
  256. -- 把玩家最新的异界之战所有防守英雄uuid推给客户端
  257. local function sendDefHeroArr(human)
  258. local msgRet = Msg.gc.GC_AB_DEF_HERO_QUERY
  259. msgRet.heroUuidArr[0] = 0
  260. if not human.db.anotherWorlBattle then
  261. return Msg.send(msgRet, human.fd)
  262. end
  263. local len = 0
  264. local heroUuidArrMsg = msgRet.heroUuidArr
  265. for _, pointList in pairs(human.db.anotherWorlBattle.formation) do
  266. for _, combatData in pairs(pointList) do
  267. local heroList = combatData.list
  268. for _, heroUuid in pairs(heroList) do
  269. if heroUuid ~= "" and heroUuid ~= "0" then
  270. len = len + 1
  271. heroUuidArrMsg[len] = heroUuid
  272. end
  273. end
  274. end
  275. end
  276. heroUuidArrMsg[0] = len
  277. Msg.send(msgRet, human.fd)
  278. end
  279. -- 是否是防守阵容中的英雄
  280. local function isDefHero(human, checkHeroUuid, excludeCityId, excludePointIdx)
  281. if not human.db.anotherWorlBattle then
  282. return
  283. end
  284. for cityId, pointList in pairs(human.db.anotherWorlBattle.formation) do
  285. for pointIdx, combatData in pairs(pointList) do
  286. if (excludeCityId and excludeCityId == cityId) and (excludePointIdx and excludePointIdx == pointIdx) then
  287. break
  288. end
  289. local heroList = combatData.list
  290. for _, heroUuid in pairs(heroList) do
  291. if heroUuid == checkHeroUuid then
  292. return cityId, pointIdx
  293. end
  294. end
  295. end
  296. end
  297. return
  298. end
  299. -- 是否是公会前二名
  300. local function isTopTwoUnion(human)
  301. local unionRanList = BillboardLogic.GetRankList(BillboardDefine.TYPE_UNION)
  302. if not unionRanList then
  303. return false
  304. end
  305. local unionId = human.db.unionUuid
  306. local isTopTwo = false
  307. for i=1, 2 do
  308. if unionRanList[i].uuid == unionId then
  309. isTopTwo = true
  310. break
  311. end
  312. end
  313. return isTopTwo
  314. end
  315. -- 是否处于战斗阶段
  316. local function isBattleStage()
  317. local wDay = getWDay()
  318. if wDay >= AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[1] and wDay <= AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] then
  319. return true
  320. end
  321. return false
  322. end
  323. -- 重置在线玩家的防守数据
  324. local function resetDefData(playerUuidArr)
  325. for _, playerUuid in ipairs(playerUuidArr or {}) do
  326. local human = ObjHuman.onlineUuid[playerUuid]
  327. if human then
  328. onLogin(human)
  329. end
  330. end
  331. end
  332. -- 获取公会/个人排行榜通用的奖励Id
  333. local function getRankGenericAwadId(rankRewardList, rankType)
  334. for _, v in ipairs(rankRewardList) do
  335. if v.nRankType == rankType then
  336. return v.Prize[1]
  337. end
  338. end
  339. return 101
  340. end
  341. -- 获取排名奖励
  342. local function getRankAward(rankRewardList, rankType, targetRank)
  343. for _, v in ipairs(rankRewardList) do
  344. if v.nRankType == rankType and (targetRank >= v.nOrder[1] and targetRank <= v.nOrder[2]) then
  345. return v.Prize[1], v.Prize[2]
  346. end
  347. end
  348. end
  349. -- 生成奖励发放对象列表
  350. local function genAwardObjArr(unionOccupyInfo)
  351. local function calcMinute(timeArr)
  352. local minuteVal = 0
  353. for _, timeTb in ipairs(timeArr or {}) do
  354. local sec = (timeTb[2] or 0) - (timeTb[1] or 0)
  355. if sec > 0 then
  356. minuteVal = minuteVal + sec
  357. end
  358. end
  359. return math.floor(minuteVal / 60)
  360. end
  361. -- 没有玩家参与
  362. if not unionOccupyInfo.playerInfoArr or #unionOccupyInfo.playerInfoArr <= 0 then
  363. return
  364. end
  365. local itemList = {}
  366. local occupyCityInfo = {0,0,0,0,0}
  367. local item_185_Id = 185
  368. local item_185_Num = 0
  369. occupyCityInfo[1] = unionOccupyInfo.occuoyPointNum
  370. -- 额外奖励
  371. item_185_Num = item_185_Num + (unionOccupyInfo.occuoyPointNum or 0)
  372. for _, cityId in ipairs(unionOccupyInfo.occupyCityArr) do
  373. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  374. if cityCfg then
  375. if cityCfg.isBaseCity == 1 then
  376. item_185_Num = item_185_Num + 20
  377. else
  378. if cityCfg.cityLv == 2 then
  379. item_185_Num = item_185_Num + 2
  380. occupyCityInfo[2] = occupyCityInfo[2] + 1
  381. elseif cityCfg.cityLv == 3 then
  382. item_185_Num = item_185_Num + 3
  383. occupyCityInfo[3] = occupyCityInfo[3] + 1
  384. elseif cityCfg.cityLv == 4 then
  385. item_185_Num = item_185_Num + 5
  386. occupyCityInfo[4] = occupyCityInfo[4] + 1
  387. elseif cityCfg.cityLv == 5 then
  388. item_185_Num = item_185_Num + 20
  389. occupyCityInfo[5] = occupyCityInfo[5] + 1
  390. end
  391. end
  392. end
  393. end
  394. -- 占领据点每分钟的奖励
  395. for _, pointInfo in ipairs(unionOccupyInfo.point2CityIdArr) do
  396. local cityId = pointInfo[1]
  397. local occupyTimeArr = pointInfo[2]
  398. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  399. local totalMinVal = calcMinute(occupyTimeArr)
  400. if totalMinVal > 0 then
  401. local itemId, itemNum = cityCfg.cityAward[1], cityCfg.cityAward[2]
  402. itemList[itemId] = (itemList[itemId] or 0) + totalMinVal * itemNum
  403. end
  404. end
  405. if item_185_Num > 0 then
  406. itemList[item_185_Id] = item_185_Num
  407. end
  408. local itemArr = {}
  409. for itemId, itemNum in pairs(itemList) do
  410. itemArr[#itemArr+1] = { itemId, itemNum }
  411. end
  412. local rankReward = AnotherWorldBattleConfig.rankReward
  413. local awardObjArr = {}
  414. for _, playerInfo in ipairs(unionOccupyInfo.playerInfoArr) do
  415. local playerUuid = playerInfo[1]
  416. local playerRank = playerInfo[2]
  417. -- 据点每分钟奖励 + 额外奖励
  418. awardObjArr[#awardObjArr+1] = {playerUuid, itemArr, AnotherWorldBattleDefine.AB_AWARD_MAIL_ID}
  419. -- 公会排名奖励
  420. local itemId, itemNum = getRankAward(rankReward, 1, unionOccupyInfo.unionRank)
  421. if itemId and itemNum then
  422. awardObjArr[#awardObjArr+1] = {playerUuid, {{itemId, itemNum}}, AnotherWorldBattleDefine.AB_UNIONRANK_AWARD_MAIL_ID, unionOccupyInfo.unionRank}
  423. end
  424. -- 玩家排名奖励
  425. local itemId2, itemNum2 = getRankAward(rankReward, 2, playerRank)
  426. if itemId2 and itemNum2 then
  427. awardObjArr[#awardObjArr+1] = {playerUuid, {{itemId2, itemNum2}}, AnotherWorldBattleDefine.AB_PLAYERRANK_AWARD_MAIL_ID, playerRank}
  428. end
  429. end
  430. return awardObjArr, occupyCityInfo
  431. end
  432. -- 活动是否处于开启中
  433. function IsRuning(joinTime)
  434. if not joinTime then
  435. return true
  436. end
  437. local wDay = getWDay()
  438. if wDay > AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[2] and wDay < AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[1] then
  439. return false
  440. end
  441. local now = os.time()
  442. local toDayStartTime = Util.getDayStartTime(now)
  443. if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] == wDay and now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
  444. return false
  445. end
  446. local diffDays = Util.diffDay(joinTime)
  447. local joinWday = Util.getWeekDay(joinTime)
  448. -- 如果是周六加入则相差5天, 如果是周日加入则相差4天。 当前时间与加入时间相差4或5天, 则都表示当前可能是活动最后一天, 如果当前时间 > 结束时间则活动结束
  449. if (diffDays == 5 and joinWday == 7) or (diffDays == 4 and joinWday == 1) then
  450. if now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
  451. return false
  452. end
  453. end
  454. -- < 5天说明处于本轮活动的开启时间
  455. if diffDays > 5 then
  456. return false
  457. end
  458. return true
  459. end
  460. --检测上阵英雄
  461. function checkUpdatePos(human, msg)
  462. local heroList = Util.split(msg.heroList, ",")
  463. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  464. local uuid = heroList[i] or ""
  465. if uuid ~= "0" and uuid ~= "" then
  466. if isDefHero(human, uuid) then
  467. return false
  468. end
  469. end
  470. end
  471. return true
  472. end
  473. -- 公会战力更新
  474. function UnionPowerChange(unionId, newPower)
  475. if not actStartTimeCheck() then
  476. return false
  477. end
  478. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
  479. msgData.myUnionId = unionId
  480. msgData.updateData = {}
  481. msgData.updateData.power = newPower
  482. InnerMsg.sendMsg(0, msgData)
  483. end
  484. -- 玩家战力更新
  485. function PlayerPowerChange(human)
  486. if not baseCondCheck(human) then
  487. return false
  488. end
  489. if not actStartTimeCheck() then
  490. return false
  491. end
  492. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
  493. msgData.playerUuid = human.db._id
  494. msgData.myUnionId = human.db.unionUuid
  495. msgData.updateData = {}
  496. msgData.updateData.power = human.db.zhandouli
  497. InnerMsg.sendMsg(0, msgData)
  498. end
  499. -- 英雄更新
  500. function HeroDataUpdate(human, heroUuid)
  501. if not baseCondCheck(human) then
  502. return false
  503. end
  504. if not actStartTimeCheck() then
  505. return false
  506. end
  507. local cityId, pointIdx = isDefHero(human, heroUuid)
  508. if not cityId then
  509. return
  510. end
  511. HeroLogic = HeroLogic or require("hero.HeroLogic")
  512. local heroGrid = HeroLogic.getHeroGridByUuid(human, heroUuid)
  513. if heroGrid then
  514. RoleAttr.calcHeroGrid(heroGrid, nil, human)
  515. local heroInfo = {
  516. heroUuid = heroUuid,
  517. heroStar = heroGrid.star,
  518. heroLevel = heroGrid.lv,
  519. heroPower = heroGrid.zhandouli,
  520. }
  521. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_HERO
  522. msgData.playerUuid = human.db._id
  523. msgData.targetCityId = cityId
  524. msgData.targetPointIdx = pointIdx
  525. msgData.heroData = heroInfo
  526. InnerMsg.sendMsg(0, msgData)
  527. end
  528. end
  529. -- 玩家改名
  530. function PlayerChangeName(human)
  531. if not baseCondCheck(human) then
  532. return false
  533. end
  534. if not actStartTimeCheck() then
  535. return false
  536. end
  537. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
  538. msgData.playerUuid = human.db._id
  539. msgData.myUnionId = human.db.unionUuid
  540. msgData.updateData = {}
  541. msgData.updateData.name = human.db.name
  542. InnerMsg.sendMsg(0, msgData)
  543. end
  544. -- 公会改名
  545. function UnionChangeName(unionId, newName)
  546. if not actStartTimeCheck() then
  547. return false
  548. end
  549. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
  550. msgData.myUnionId = unionId
  551. msgData.updateData = {}
  552. msgData.updateData.name = newName
  553. InnerMsg.sendMsg(0, msgData)
  554. end
  555. function isDot(human)
  556. if not baseCondCheck(human) then
  557. return false
  558. end
  559. if not actStartTimeCheck() then
  560. return false
  561. end
  562. return true
  563. end
  564. function onLogin(human)
  565. formationDataCheeck(human)
  566. sendDefHeroArr(human)
  567. end
  568. -- 请求状态
  569. function AB_GetState(human)
  570. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GET_STATE
  571. msgData.sourceServerId = Config.SVR_INDEX
  572. msgData.playerUuid = human.db._id
  573. msgData.myUnionId = human.db.unionUuid or ""
  574. InnerMsg.sendMsg(0, msgData)
  575. end
  576. -- 报名
  577. function AB_Join(human)
  578. local unionId = human.db.unionUuid
  579. local msgRet = Msg.gc.GC_AB_JOIN
  580. if not unionId then
  581. msgRet.Joinstate = 3
  582. return Msg.send(msgRet, human.fd)
  583. end
  584. local wDay = getWDay()
  585. -- if wDay ~= AnotherWorldBattleDefine.AB_JOIN_WDAY then
  586. -- msgRet.Joinstate = 5
  587. -- return Msg.send(msgRet, human.fd)
  588. -- end
  589. if not table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
  590. msgRet.Joinstate = 5
  591. return Msg.send(msgRet, human.fd)
  592. end
  593. -- 公会排名前二才能参加
  594. if not isTopTwoUnion(human) then
  595. msgRet.Joinstate = 2
  596. return Msg.send(msgRet, human.fd)
  597. end
  598. -- 会长/副会长才能报名
  599. if not UnionLogic.IsTopTwoManager(human, unionId) then
  600. return Broadcast.sendErr(human, Lang.AB_NOT_TOPTWO_MANGER)
  601. end
  602. local queryFiles = {name = 1, zhandouli = 1}
  603. local unionInfo = UnionLogic.GetUnionData(unionId, queryFiles)
  604. if not unionInfo then
  605. return Broadcast.sendErr(human, Lang.DATA_ERR)
  606. end
  607. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_JOIN
  608. msgData.sourceServerId = Config.SVR_INDEX
  609. msgData.playerUuid = human.db._id
  610. msgData.unionInfo = {
  611. name = unionInfo.name,
  612. power = unionInfo.zhandouli,
  613. unionId = unionId
  614. }
  615. InnerMsg.sendMsg(0, msgData)
  616. end
  617. -- 查询所有城池信息
  618. function AB_AllCity_Query(human)
  619. if not human.db.unionUuid then
  620. return
  621. end
  622. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_ALLCITY_QUERY
  623. msgData.sourceServerId = Config.SVR_INDEX
  624. msgData.playerUuid = human.db._id
  625. msgData.myUnionId = human.db.unionUuid
  626. InnerMsg.sendMsg(0, msgData)
  627. -- 报名状态查询
  628. -- local msgData2 = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GET_JOIN_STATE
  629. -- msgData2.sourceServerId = Config.SVR_INDEX
  630. -- msgData2.playerUuid = human.db._id
  631. -- msgData2.myUnionId = human.db.unionUuid
  632. -- InnerMsg.sendMsg(0, msgData2)
  633. end
  634. -- 查询单个城池的详细信息
  635. function AB_CityDetailed_Query(human, targetCityId)
  636. if not AnotherWorldBattleConfig.city[targetCityId] then
  637. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  638. end
  639. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_CITYDETAILED_QUERY
  640. msgData.sourceServerId = Config.SVR_INDEX
  641. msgData.playerUuid = human.db._id
  642. msgData.myUnionId = human.db.unionUuid
  643. msgData.targetCityId = targetCityId
  644. InnerMsg.sendMsg(0, msgData)
  645. end
  646. -- 查询某个城池的某个据点的详细信息
  647. function AB_PointDetailed_Query(human, targetCityId, targetPointIdx)
  648. if not AnotherWorldBattleConfig.city[targetCityId] then
  649. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  650. end
  651. if 0 >= targetPointIdx or AnotherWorldBattleDefine.AB_POINT_MAX_NUM < targetPointIdx then
  652. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  653. end
  654. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINTtDETAILED_QUERY
  655. msgData.sourceServerId = Config.SVR_INDEX
  656. msgData.playerUuid = human.db._id
  657. msgData.myUnionId = human.db.unionUuid
  658. msgData.targetCityId = targetCityId
  659. msgData.targetPointIdx = targetPointIdx
  660. InnerMsg.sendMsg(0, msgData)
  661. end
  662. -- 查询本公会出生点信息
  663. function AB_BaseCity_Query(human)
  664. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_BASECITY_QUERY
  665. msgData.sourceServerId = Config.SVR_INDEX
  666. msgData.playerUuid = human.db._id
  667. msgData.myUnionId = human.db.unionUuid
  668. InnerMsg.sendMsg(0, msgData)
  669. end
  670. -- 查询玩家占领的所有据点信息
  671. function AB_PlayerOccupyPOint_Query(human)
  672. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_PLAYEROCCUPYPOINT_QUERY
  673. msgData.sourceServerId = Config.SVR_INDEX
  674. msgData.playerUuid = human.db._id
  675. msgData.myUnionId = human.db.unionUuid
  676. InnerMsg.sendMsg(0, msgData)
  677. end
  678. -- 查询公会排行榜
  679. function AB_UnionRank_Query(human)
  680. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UNIONRANK_QUERY
  681. msgData.sourceServerId = Config.SVR_INDEX
  682. msgData.playerUuid = human.db._id
  683. msgData.myUnionId = human.db.unionUuid
  684. InnerMsg.sendMsg(0, msgData)
  685. end
  686. -- 查询玩家排行榜
  687. function AB_PlayerRank_Query(human)
  688. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_PLAYERRANK_QUERY
  689. msgData.sourceServerId = Config.SVR_INDEX
  690. msgData.playerUuid = human.db._id
  691. msgData.myUnionId = human.db.unionUuid
  692. InnerMsg.sendMsg(0, msgData)
  693. end
  694. -- 发起集结
  695. function AB_Gather(human, targetCityId, opType)
  696. if not AnotherWorldBattleConfig.city[targetCityId] then
  697. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  698. end
  699. if opType ~= 1 and opType ~= 2 then
  700. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  701. end
  702. local unionId = human.db.unionUuid
  703. if not unionId then
  704. return Broadcast.sendErr(human, Lang.AB_NO_UNION)
  705. end
  706. -- 会长/副会长才能集结
  707. if not UnionLogic.IsTopTwoManager(human, unionId) then
  708. return Broadcast.sendErr(human, Lang.AB_NOT_TOPTWO_MANAGER)
  709. end
  710. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GATHER
  711. msgData.sourceServerId = Config.SVR_INDEX
  712. msgData.playerUuid = human.db._id
  713. msgData.myUnionId = human.db.unionUuid
  714. msgData.targetCityId = targetCityId
  715. msgData.opType = opType
  716. InnerMsg.sendMsg(0, msgData)
  717. end
  718. -- 请求挑战某个据点
  719. function AB_Try_Challenge_Point(human, targetCityId, targetPointIdx)
  720. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE35)
  721. if not combatHero or not next(combatHero) then
  722. return Broadcast.sendErr(human, Lang.COMBAT_NEED_FIGHT_HERO)
  723. end
  724. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINT_ISCAN_CHALLENGE
  725. msgData.sourceServerId = Config.SVR_INDEX
  726. msgData.playerUuid = human.db._id
  727. msgData.myUnionId = human.db.unionUuid
  728. msgData.targetCityId = targetCityId
  729. msgData.targetPointIdx = targetPointIdx
  730. InnerMsg.sendMsg(0, msgData)
  731. end
  732. -- 战斗结束
  733. local function challenge_End(human, args)
  734. local cityId = args.cityId
  735. local pointIdx = args.pointIdx
  736. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINT_CHALLENGE_END
  737. msgData.sourceServerId = Config.SVR_INDEX
  738. msgData.playerUuid = human.db._id
  739. msgData.myUnionId = human.db.unionUuid
  740. msgData.targetCityId = cityId
  741. msgData.targetPointIdx = pointIdx
  742. msgData.challengeRes = args.challengeRes
  743. -- 挑战没有胜利
  744. if args.challengeRes ~= CombatDefine.RESULT_WIN then
  745. -- 说明之前已经在跨服上保存玩家的基础数据了
  746. -- if human.db.anotherWorlBattle then
  747. -- return
  748. -- end
  749. msgData.playerShowInfo = {
  750. name = human.db.name,
  751. lv = human.db.lv,
  752. power = human.db.zhandouli,
  753. }
  754. return InnerMsg.sendMsg(0, msgData)
  755. end
  756. if not human.db.anotherWorlBattle then
  757. human.db.anotherWorlBattle = {
  758. startTime = os.time(),
  759. formation = {}
  760. }
  761. end
  762. -- 把当前战斗阵容数据保存到当前模块,作为防守阵容
  763. local combatData = CombatPosLogic.getCombatHeroDB(human, CombatDefine.COMBAT_TYPE35)
  764. local formationData = human.db.anotherWorlBattle.formation or {}
  765. formationData[cityId] = formationData[cityId] or {}
  766. formationData[cityId][pointIdx] = Util.copyTable(combatData)
  767. -- 把最新的防守英雄uuid列表推送给客户端
  768. sendDefHeroArr(human)
  769. --同步到跨服
  770. msgData.playerShowInfo = generateShowInfo(human)
  771. InnerMsg.sendMsg(0, msgData)
  772. -- 清空战斗阵容
  773. CombatPosLogic.cleanCombatHeros(human, CombatDefine.COMBAT_TYPE35)
  774. end
  775. -- 更换据点的防守阵容
  776. function AB_Update_Lineup(human, msg)
  777. if not isBattleStage() then
  778. return Broadcast.sendErr(human, Lang.AB_NOT_BATTLE_TIME)
  779. end
  780. local anotherWorlBattle = human.db.anotherWorlBattle
  781. if not anotherWorlBattle or not anotherWorlBattle.formation then
  782. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_POINT)
  783. end
  784. local cityId = msg.cityId
  785. local pointIdx = msg.pointIdx
  786. local formationData = anotherWorlBattle.formation
  787. if not formationData[cityId] or not formationData[cityId][pointIdx] then
  788. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_TARGET_POINT)
  789. end
  790. local res, heroList, helpList = CombatPosLogic.CheckUpdatePos(human, msg)
  791. if not res then
  792. return Broadcast.sendErr(human, Lang.COMBAT_POS__ERR)
  793. end
  794. local len = 0
  795. local heroArr = {}
  796. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  797. local uuid = heroList[i] or ""
  798. if uuid ~= "0" and uuid ~= "" then
  799. if isDefHero(human, uuid, cityId, pointIdx) then
  800. return Broadcast.sendErr(human, Lang.AB_HERO_IN_OTHER_POINT)
  801. end
  802. len = len + 1
  803. heroArr[len] = getHeroInfo(human, uuid)
  804. end
  805. end
  806. if len == 0 then
  807. return
  808. end
  809. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP
  810. msgData.sourceServerId = Config.SVR_INDEX
  811. msgData.playerUuid = human.db._id
  812. msgData.heroArr = heroArr
  813. msgData.targetCityId = cityId
  814. msgData.targetPointIdx = pointIdx
  815. msgData.formation = msg.formation
  816. msgData.heroList = heroList
  817. msgData.helpList = helpList
  818. InnerMsg.sendMsg(0, msgData)
  819. end
  820. -- 放弃据点
  821. function AB_Leave_Point(human, msg)
  822. local targetCityId = msg.cityId
  823. if not AnotherWorldBattleConfig.city[targetCityId] then
  824. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  825. end
  826. local targetPointIdx = msg.pointIdx
  827. if targetPointIdx <= 0 or targetPointIdx > AnotherWorldBattleDefine.AB_POINT_MAX_NUM then
  828. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  829. end
  830. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_LEAVE_POINT
  831. msgData.sourceServerId = Config.SVR_INDEX
  832. msgData.playerUuid = human.db._id
  833. msgData.myUnionId = human.db.unionUuid
  834. msgData.targetCityId = targetCityId
  835. msgData.targetPointIdx = targetPointIdx
  836. InnerMsg.sendMsg(0, msgData)
  837. end
  838. --获取据点的防守阵容数据
  839. function AB_Get_Point_Lineup(human, msg)
  840. local targetCityId = msg.cityId
  841. local targetPointIdx = msg.pointIdx
  842. local anotherWorlBattle = human.db.anotherWorlBattle
  843. local formationData = anotherWorlBattle.formation
  844. if not formationData[targetCityId] or not formationData[targetCityId][targetPointIdx] then
  845. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_TARGET_POINT)
  846. end
  847. local extraArgs = {
  848. cityId = targetCityId,
  849. pointIdx = targetPointIdx
  850. }
  851. CombatPosLogic.posQuery(human, msg.type, msg.groupID, msg.param, 1, extraArgs)
  852. end
  853. ------------------------------------C2N---------------------------------------------------
  854. -- 跨服通知活动开启
  855. function C2N_Act_Start(msg)
  856. local startTime = msg.startTime
  857. if not startTime or startTime == 0 then
  858. return
  859. end
  860. CommonDB.updateValue(CommonDB.KEY_ANOTHERWORLDBATTLE_START_TI, startTime)
  861. end
  862. -- 错误提示
  863. function C2N_ErrTips(msg)
  864. local human = ObjHuman.onlineUuid[msg.playerUuid]
  865. if not human then
  866. return
  867. end
  868. local tips = Lang.DATA_ERR
  869. local errCode = msg.errCode
  870. if errCode == AnotherWorldBattleDefine.ERR_CODE_1 then
  871. tips = Lang.AB_NOT_OPEN_TIME
  872. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_2 then
  873. tips = Lang.AB_NOT_UNION_NUM_EXCEED
  874. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_3 then
  875. tips = Lang.AB_UNION_NO_JOIN
  876. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_4 then
  877. tips = Lang.DATA_ERR
  878. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_5 then
  879. tips = Lang.AB_NOT_OCCUPY_POINT
  880. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_6 then
  881. tips = Lang.AB_GATHER_CD
  882. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_7 then
  883. tips = Lang.AB_CITY_NOT_ADDJION
  884. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_8 then
  885. tips = Lang.AB_JOINED
  886. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_9 then
  887. tips = Lang.AB_CITY_NO_GATHER
  888. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_10 then
  889. tips = Lang.AB_OCCUPY_POINT_MAX
  890. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_11 then
  891. tips = Lang.AB_POINT_CHALLENGING
  892. end
  893. Broadcast.sendErr(human, tips)
  894. end
  895. -- 跨服返回状态
  896. function C2N_State(msg)
  897. local human = ObjHuman.onlineUuid[msg.playerUuid]
  898. if not human then
  899. return
  900. end
  901. local msgRet = Msg.gc.GC_AB_GetState
  902. msgRet.joinState = msg.joinState
  903. msgRet.systemState = msg.systemState
  904. if msgRet.joinState == 0 then
  905. local unionId = human.db.unionUuid
  906. if not unionId then
  907. msgRet.Joinstate = 2
  908. return Msg.send(msgRet, human.fd)
  909. end
  910. -- 公会排名前二才行
  911. if not isTopTwoUnion(human) then
  912. msgRet.Joinstate = 2
  913. return Msg.send(msgRet, human.fd)
  914. end
  915. end
  916. Msg.send(msgRet, human.fd)
  917. end
  918. -- 报名成功
  919. function C2N_Join_Succ(msg)
  920. local now = os.time()
  921. local unionId = msg.myUnionId
  922. UnionLogic.UpdateJoinAbTime(unionId, now)
  923. local human = ObjHuman.onlineUuid[msg.playerUuid]
  924. if not human then
  925. return
  926. end
  927. local msgRet = Msg.gc.GC_AB_JOIN
  928. msgRet.Joinstate = 1
  929. Msg.send(msgRet, human.fd)
  930. end
  931. -- 跨服返回的所有城池数据
  932. function C2N_AllCity_Query(msg)
  933. local human = ObjHuman.onlineUuid[msg.playerUuid]
  934. if not human then
  935. return
  936. end
  937. local msgRet = Msg.gc.GC_AB_ALLCITY_QUERY
  938. msgRet.myBaseCityId = msg.myUnionBaseCityId
  939. msgRet.hasPointNum = msg.hasPointNum
  940. msgRet.challengeTimes = msg.challengeTimes
  941. local now = os.time()
  942. msgRet.leftTime = msg.lastTime
  943. if msgRet.leftTime ~= 0 then
  944. msgRet.leftTime = (msg.lastTime + AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC) - now
  945. end
  946. msgRet.cityArr[0] = 0
  947. local cityArrMsg = msgRet.cityArr
  948. for cityId, cityInfo in ipairs(msg.cityArr) do
  949. cityArrMsg[0] = cityId
  950. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  951. cityArrMsg[cityId].cityId = cityId
  952. cityArrMsg[cityId].cityName = cityCfg.cityName
  953. cityArrMsg[cityId].cityLv = cityCfg.cityLv
  954. cityArrMsg[cityId].occupyPointNum = cityInfo.occupyPointNum or 0
  955. cityArrMsg[cityId].occupyUnionName = cityInfo.occupyUnionName or ""
  956. cityArrMsg[cityId].cityState = cityInfo.cityState
  957. cityArrMsg[cityId].adJoinCityArr[0] = #cityCfg.adJoinCityArr
  958. for i, cId in ipairs(cityCfg.adJoinCityArr) do
  959. cityArrMsg[cityId].adJoinCityArr[i] = cId
  960. end
  961. end
  962. msgRet.myOccupyCityArr[0] = #msg.myOccupyCityArr
  963. for i, cityId in ipairs(msg.myOccupyCityArr) do
  964. msgRet.myOccupyCityArr[i] = cityId
  965. end
  966. -- 据点每分钟的奖励
  967. local itemId, itemNum = 0, 0
  968. local cityCfg = AnotherWorldBattleConfig.city[1]
  969. itemId = cityCfg.cityAward[1]
  970. for _, pointInfo in ipairs(msg.occupyPointData) do
  971. local cityId = pointInfo[1]
  972. local occupyTimeArr = pointInfo[2]
  973. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  974. local minuteVal = 0
  975. for _, timeTb in ipairs(occupyTimeArr) do
  976. local sec = (timeTb[2] or now) - (timeTb[1] or now)
  977. if sec > 0 then
  978. minuteVal = minuteVal + sec
  979. end
  980. minuteVal = math.floor(minuteVal / 60)
  981. end
  982. itemNum = itemNum + minuteVal * cityCfg.cityAward[2]
  983. end
  984. Grid.makeItem(msgRet.myUnionAward, itemId, itemNum)
  985. Msg.send(msgRet, human.fd)
  986. end
  987. -- 跨服返回某个城池详细数据
  988. function C2N_CityDetailed_Query(msg)
  989. local human = ObjHuman.onlineUuid[msg.playerUuid]
  990. if not human then
  991. return
  992. end
  993. local cityCfg = AnotherWorldBattleConfig.city[msg.targetCityId]
  994. local msgRet = Msg.gc.GC_AB_CITY_DETAILED_QUERY
  995. msgRet.cityId = msg.targetCityId
  996. msgRet.cityLv = cityCfg.cityLv
  997. msgRet.cityIconId = cityCfg.cityIconId
  998. Grid.makeItem(msgRet.cityAward, cityCfg.cityAward[1], cityCfg.cityAward[2] * AnotherWorldBattleDefine.AB_POINT_MAX_NUM )
  999. local myUnionAwardNum = calcPointAward(msg.myUnionOccupyArr)
  1000. Grid.makeItem(msgRet.myUnionAward, cityCfg.cityAward[1], myUnionAwardNum)
  1001. -- 活动没有进入战斗阶段时, 使用默认数据
  1002. if #msg.pointArr == 0 then
  1003. for i=1, AnotherWorldBattleDefine.AB_POINT_MAX_NUM do
  1004. msg.pointArr[i] = {}
  1005. end
  1006. end
  1007. msgRet.pointArr[0] = AnotherWorldBattleDefine.AB_POINT_MAX_NUM
  1008. for pointIdx, pointInfo in ipairs(msg.pointArr) do
  1009. if pointInfo.occupyUnionName then
  1010. msgRet.pointArr[pointIdx].occupyUnionName = pointInfo.occupyUnionName
  1011. msgRet.pointArr[pointIdx].occupyPlayerName = pointInfo.occupyPlayerName
  1012. msgRet.pointArr[pointIdx].power = pointInfo.power
  1013. msgRet.pointArr[pointIdx].state = pointInfo.state
  1014. else
  1015. msgRet.pointArr[pointIdx].occupyUnionName = ""
  1016. msgRet.pointArr[pointIdx].occupyPlayerName = AnotherWorldBattleDefine.AB_DEF_NAME_STR.. pointIdx
  1017. msgRet.pointArr[pointIdx].power = calcMonsterPower(cityCfg.pointMonsterId)
  1018. msgRet.pointArr[pointIdx].state = pointInfo.state
  1019. end
  1020. end
  1021. msgRet.gatherState = msg.gatherState
  1022. if msg.gatherState == 1 then
  1023. -- 公会会长/副会长才能集结
  1024. if not UnionLogic.IsTopTwoManager(human, human.db.unionUuid) then
  1025. msgRet.gatherState = 0
  1026. end
  1027. end
  1028. msgRet.gatherLeftTime = msg.gatherTime
  1029. if msg.gatherTime ~= -1 then
  1030. local now = os.time()
  1031. local subSec = msg.gatherTime + AnotherWorldBattleDefine.AB_GATHER_CD_SEC - now
  1032. msgRet.gatherLeftTime = subSec > 0 and subSec or 0
  1033. end
  1034. Msg.send(msgRet, human.fd)
  1035. end
  1036. -- 跨服返回某个据点数据
  1037. function C2N_PointDetailed_Query(msg)
  1038. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1039. if not human then
  1040. return
  1041. end
  1042. local pointInfo = msg.pointInfo
  1043. local msgRet = Msg.gc.GC_AB_POINT_DETAILEDINFO_QUERY
  1044. msgRet.state = pointInfo.state
  1045. if pointInfo.name then
  1046. msgRet.name = pointInfo.name
  1047. msgRet.power = pointInfo.power
  1048. msgRet.head = pointInfo.head
  1049. msgRet.headFrame = pointInfo.headFrame
  1050. msgRet.defLv = pointInfo.defLv
  1051. msgRet.heroArr[0] = #pointInfo.heroArr
  1052. for i, heroInfo in ipairs(pointInfo.heroArr) do
  1053. msgRet.heroArr[i].heroBody = heroInfo.heroBody
  1054. msgRet.heroArr[i].heroStar = heroInfo.heroStar
  1055. msgRet.heroArr[i].heroLv = heroInfo.heroLv
  1056. msgRet.heroArr[i].heroCamp = heroInfo.heroCamp
  1057. msgRet.heroArr[i].heroIcon = heroInfo.heroIcon
  1058. msgRet.heroArr[i].heroId = heroInfo.heroId
  1059. msgRet.heroArr[i].heroQuality = heroInfo.heroQuality
  1060. end
  1061. else
  1062. msgRet.name = AnotherWorldBattleDefine.AB_DEF_NAME_STR .. msg.targetPointIdx
  1063. msgRet.head = getDefaultShowId(1, msg.targetPointIdx)
  1064. msgRet.headFrame = getDefaultShowId(2, msg.targetPointIdx)
  1065. msgRet.defLv = 200
  1066. local cityCfg = AnotherWorldBattleConfig.city[msg.targetCityId]
  1067. msgRet.power = calcMonsterPower(cityCfg.pointMonsterId)
  1068. msgRet.heroArr[0] = 0
  1069. local monsterOutConfig = MonsterExcel.monsterOut[cityCfg.pointMonsterId]
  1070. for idx, monsterInfo in ipairs(monsterOutConfig.member) do
  1071. if idx > 6 then
  1072. break
  1073. end
  1074. msgRet.heroArr[0] = idx
  1075. local monsterID = monsterInfo[1]
  1076. local mcf = MonsterExcel.monster[monsterID]
  1077. msgRet.heroArr[idx].heroBody = mcf.body
  1078. msgRet.heroArr[idx].heroStar = mcf.star
  1079. msgRet.heroArr[idx].heroLv = monsterInfo[2]
  1080. msgRet.heroArr[idx].heroCamp = mcf.camp
  1081. msgRet.heroArr[idx].heroIcon = mcf.head
  1082. msgRet.heroArr[idx].heroId = monsterID
  1083. msgRet.heroArr[idx].heroQuality = mcf.heroQuality or 1
  1084. end
  1085. end
  1086. Msg.send(msgRet, human.fd)
  1087. end
  1088. -- 跨服返回公会出生点数据
  1089. function C2N_BaseCity_Query(msg)
  1090. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1091. if not human then
  1092. return
  1093. end
  1094. local baseCityInfo = msg.baseCityInfo
  1095. local msgRet = Msg.gc.GC_AB_BASECITY_QUERY
  1096. local cityCfg = AnotherWorldBattleConfig.city[baseCityInfo.cityId]
  1097. msgRet.cityIconId = cityCfg.cityIconId
  1098. Grid.makeItem(msgRet.cityAward, cityCfg.cityAward[1], cityCfg.cityAward[2] * AnotherWorldBattleDefine.AB_POINT_MAX_NUM)
  1099. local myUnionAwardNum = calcPointAward(baseCityInfo.myUnionOccupyArr)
  1100. Grid.makeItem(msgRet.myUnionAward, cityCfg.cityAward[1], myUnionAwardNum)
  1101. msgRet.cityIconId = baseCityInfo.occupyPointNum
  1102. msgRet.occupyPointNum = baseCityInfo.occupyPointNum
  1103. msgRet.occupyCityLv2Num = baseCityInfo.occupyCityLv2Num
  1104. msgRet.occupyCityLv3Num = baseCityInfo.occupyCityLv3Num
  1105. msgRet.occupyCityLv4Num = baseCityInfo.occupyCityLv4Num
  1106. msgRet.occupyCityLv5Num = baseCityInfo.occupyCityLv5Num
  1107. Msg.send(msgRet, human.fd)
  1108. end
  1109. -- 跨服返回玩家占领的据点数据
  1110. function C2N_PlayerOccupyPoint_Query(msg)
  1111. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1112. if not human then
  1113. return
  1114. end
  1115. local msgRet = Msg.gc.GC_AB_MY_OCCUPY_POINT_QUERY
  1116. local myPointArr = msgRet.myPointArr
  1117. myPointArr[0] = 0
  1118. for idx, pointInfo in ipairs(msg.occupyPointArr) do
  1119. myPointArr[0] = idx
  1120. local cityCfg = AnotherWorldBattleConfig.city[pointInfo.cityId]
  1121. myPointArr[idx].cityIconId = cityCfg.cityIconId
  1122. myPointArr[idx].cityName = cityCfg.cityName
  1123. myPointArr[idx].cityLv = cityCfg.cityLv
  1124. myPointArr[idx].pointIdx = pointInfo.pointIdx
  1125. myPointArr[idx].power = pointInfo.power
  1126. myPointArr[idx].cityId = pointInfo.cityId
  1127. myPointArr[idx].heroArr[0] = #pointInfo.heroArr
  1128. for heroIdx, heroInfo in ipairs(pointInfo.heroArr) do
  1129. local hero = myPointArr[idx].heroArr[heroIdx]
  1130. hero.heroBody = heroInfo.heroBody
  1131. hero.heroStar = heroInfo.heroStar
  1132. hero.heroLv = heroInfo.heroLv
  1133. hero.heroCamp = heroInfo.heroCamp
  1134. hero.heroIcon = heroInfo.heroIcon
  1135. hero.heroId = heroInfo.heroId
  1136. hero.heroQuality = heroInfo.heroQuality
  1137. end
  1138. end
  1139. Msg.send(msgRet, human.fd)
  1140. end
  1141. -- 跨服返回集结/取消集结成功
  1142. function C2N_Gather_End(msg)
  1143. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1144. if not human then
  1145. return
  1146. end
  1147. local targetCityId = msg.targetCityId
  1148. local cityCfg = AnotherWorldBattleConfig.city[targetCityId]
  1149. local msgRet = Msg.gc.GC_AB_GARHER
  1150. msgRet.cityId = targetCityId
  1151. msgRet.cityName = cityCfg.cityName
  1152. msgRet.opType = msg.opType
  1153. Msg.send(msgRet, human.fd)
  1154. end
  1155. --跨服返回公会排行榜数据
  1156. function C2N_UnionRank_Query(msg)
  1157. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1158. if not human then
  1159. return
  1160. end
  1161. local itemId, itemNum = 184, 0
  1162. local rankReward = AnotherWorldBattleConfig.rankReward
  1163. itemId = getRankGenericAwadId(rankReward, 1)
  1164. local msgRet = Msg.gc.GC_AB_UNION_RANK_QUERY
  1165. msgRet.unionRankArr[0] = 0
  1166. msgRet.myUnionRank = msg.myUnionRank
  1167. msgRet.myData.name = ""
  1168. msgRet.myData.power = 0
  1169. msgRet.myData.cityNum = 0
  1170. msgRet.myData.pointNum = 0
  1171. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1172. for rank, rankdData in ipairs(msg.unionRankArr) do
  1173. msgRet.unionRankArr[0] = rank
  1174. msgRet.unionRankArr[rank].name = rankdData.name
  1175. msgRet.unionRankArr[rank].power = rankdData.power
  1176. msgRet.unionRankArr[rank].cityNum = rankdData.cityNum
  1177. msgRet.unionRankArr[rank].pointNum = rankdData.pointNum
  1178. itemId, itemNum = getRankAward(rankReward, 1, rank)
  1179. Grid.makeItem(msgRet.unionRankArr[rank].rankAward, itemId, itemNum)
  1180. if rank == msg.myUnionRank then
  1181. msgRet.myData.name = rankdData.name
  1182. msgRet.myData.power = rankdData.power
  1183. msgRet.myData.cityNum = rankdData.cityNum
  1184. msgRet.myData.pointNum = rankdData.pointNum
  1185. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1186. end
  1187. end
  1188. if msgRet.myData.power == 0 then
  1189. local unionId = human.db.unionUuid
  1190. local queryFiles = {name = 1, zhandouli = 1}
  1191. local unionInfo = UnionLogic.GetUnionData(unionId, queryFiles)
  1192. msgRet.myData.name = unionInfo and unionInfo.name or ""
  1193. msgRet.myData.power = unionInfo and unionInfo.zhandouli or 0
  1194. end
  1195. Msg.send(msgRet, human.fd)
  1196. end
  1197. --跨服返回玩家排行榜数据
  1198. function C2N_PlayerRank_Query(msg)
  1199. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1200. if not human then
  1201. return
  1202. end
  1203. local itemId, itemNum = 184, 0
  1204. local rankReward = AnotherWorldBattleConfig.rankReward
  1205. itemId = getRankGenericAwadId(rankReward, 2)
  1206. local msgRet = Msg.gc.GC_AB_PLAYER_RANK_QUERY
  1207. msgRet.playerRankArr[0] = 0
  1208. msgRet.myRank = msg.myRank
  1209. msgRet.myData.name = human.db.name
  1210. msgRet.myData.power = human.db.zhandouli
  1211. msgRet.myData.pointNum = 0
  1212. msgRet.myData.pointWeight = 0
  1213. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1214. for rank, rankdData in ipairs(msg.playerRankArr) do
  1215. msgRet.playerRankArr[0] = rank
  1216. msgRet.playerRankArr[rank].name = rankdData.name
  1217. msgRet.playerRankArr[rank].power = rankdData.power
  1218. msgRet.playerRankArr[rank].pointNum = rankdData.pointNum
  1219. msgRet.playerRankArr[rank].pointWeight = rankdData.pointWeight
  1220. itemId, itemNum = getRankAward(rankReward, 2, rank)
  1221. Grid.makeItem(msgRet.playerRankArr[rank].rankAward, itemId, itemNum)
  1222. if rank == msg.myRank then
  1223. msgRet.myData.pointNum = rankdData.pointNum
  1224. msgRet.myData.pointWeight = rankdData.pointWeight
  1225. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1226. end
  1227. end
  1228. Msg.send(msgRet, human.fd)
  1229. end
  1230. -- 跨服返回要挑战的据点的数据(据点可以被挑战)
  1231. function C2N_Challenge_Point_OK(msg)
  1232. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1233. if not human then
  1234. return
  1235. end
  1236. local pointInfo = msg.pointInfo
  1237. human.AB_Battle_Cache = {
  1238. isGather = pointInfo.isGather,
  1239. cityId = pointInfo.targetCityId,
  1240. pointIdx = pointInfo.targetPointIdx,
  1241. }
  1242. if pointInfo.occupySrvId then -- 玩家占领
  1243. local args = {
  1244. combatType = CombatDefine.COMBAT_TYPE35,
  1245. nServerIndex = pointInfo.occupySrvId,
  1246. param = pointInfo.occupyPlayerUuid,
  1247. extraArgs = {
  1248. cityId = pointInfo.targetCityId,
  1249. pointIdx = pointInfo.targetPointIdx,
  1250. useDef = true,
  1251. }
  1252. }
  1253. MiddleCommonLogic.MiddleCommonLogic_CombatBegin_LW(human, args)
  1254. else
  1255. -- 机器人
  1256. CombatLogic.combatBegin(human, nil, {human.db._id, pointInfo.targetCityId }, CombatDefine.COMBAT_TYPE35)
  1257. end
  1258. end
  1259. -- 跨服通知据点被别的玩家占领了
  1260. function C2N_Point_Lose(msg)
  1261. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1262. if not human then
  1263. local db = RoleDBLogic.getDb(msg.playerUuid) --后续可优化只取 anotherWorlBattle 数据
  1264. if not db then
  1265. return
  1266. end
  1267. human = {}
  1268. human.db = db
  1269. end
  1270. -- 更新防守阵容数据
  1271. local loseCityId = msg.loseCityId
  1272. local losePointIdx = msg.losePointIdx
  1273. local formationData = human.db.anotherWorlBattle.formation
  1274. formationData[loseCityId][losePointIdx] = nil
  1275. -- 玩家不在线, 手动保存数据
  1276. if not human.fd then
  1277. ObjHuman.save(human) --后续可优化只更新 anotherWorlBattle 数据
  1278. end
  1279. local cityCfg = AnotherWorldBattleConfig.city[loseCityId]
  1280. -- 发邮件
  1281. local mailCfg = MailExcel.mail[AnotherWorldBattleDefine.AB_LOSE_POINT_MAIL_ID]
  1282. local content = Util.format(mailCfg.content, cityCfg and cityCfg.cityName or "", loseCityId)
  1283. MailManager.add(MailManager.SYSTEM, msg.playerUuid, mailCfg.title, content, nil, mailCfg.senderName or "GM")
  1284. -- 把最新的防守阵容数据推给客户端
  1285. if human.fd then
  1286. sendDefHeroArr(human)
  1287. end
  1288. end
  1289. -- 跨服通知可以更换据点的防守阵容数据
  1290. function C2N_Update_Point_Lineup(msg)
  1291. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1292. if not human then
  1293. local db = RoleDBLogic.getDb(msg.playerUuid)
  1294. if not db then
  1295. return
  1296. end
  1297. human = {}
  1298. human.db = db
  1299. end
  1300. local anotherWorlBattle = human.db.anotherWorlBattle
  1301. if not anotherWorlBattle or not anotherWorlBattle.formation then
  1302. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_POINT)
  1303. end
  1304. local cityId = msg.targetCityId
  1305. local pointIdx = msg.targetPointIdx
  1306. if not anotherWorlBattle.formation[cityId] or not anotherWorlBattle.formation[cityId][pointIdx] then
  1307. return
  1308. end
  1309. local pointLinupData = anotherWorlBattle.formation[cityId][pointIdx]
  1310. pointLinupData.list = msg.heroList
  1311. pointLinupData.helpList = msg.helpList
  1312. pointLinupData.formation = msg.formation
  1313. if not human.fd then
  1314. ObjHuman.save(human)
  1315. end
  1316. sendDefHeroArr(human)
  1317. Broadcast.sendCenter(human, Lang.AB_UPDATE_LINEUP_SUCC)
  1318. end
  1319. -- 跨服通知放弃据点成功
  1320. function C2N_Leave_Point(msg)
  1321. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1322. if not human then
  1323. local db = RoleDBLogic.getDb(msg.playerUuid)
  1324. if not db then
  1325. return
  1326. end
  1327. human = {}
  1328. human.db = db
  1329. end
  1330. local anotherWorlBattle = human.db.anotherWorlBattle
  1331. if not anotherWorlBattle or not anotherWorlBattle.formation then
  1332. return
  1333. end
  1334. local cityId = msg.targetCityId
  1335. local pointIdx = msg.targetPointIdx
  1336. anotherWorlBattle.formation[cityId][pointIdx] = nil
  1337. if not next(anotherWorlBattle.formation[cityId]) then
  1338. anotherWorlBattle.formation[cityId] = nil
  1339. end
  1340. -- 玩家不在线, 手动保存数据
  1341. if not human.fd then
  1342. ObjHuman.save(human) --后续可优化只更新 anotherWorlBattle 数据
  1343. else
  1344. -- 把最新的防守阵容数据推给客户端
  1345. sendDefHeroArr(human)
  1346. end
  1347. end
  1348. -- 跨服通知给玩家发奖
  1349. function C2N_IssueReward(msg)
  1350. -- 删除公会参加异界之战活动时间
  1351. UnionLogic.UpdateJoinAbTime(msg.unionOccupyInfo.unionId, nil)
  1352. resetDefData(msg.unionOccupyInfo.playerUuidArr)
  1353. -- 发奖
  1354. local awardObjArr, occupyCityInfo = genAwardObjArr(msg.unionOccupyInfo)
  1355. if awardObjArr then
  1356. local issueRewardQueue = createRewardQueue()
  1357. issueRewardQueue.extraInfo = occupyCityInfo
  1358. for _, obj in ipairs(awardObjArr) do
  1359. issueRewardQueue:add(obj)
  1360. end
  1361. issueRewardQueue:insertDB()
  1362. end
  1363. end
  1364. -------------------------------------------战斗---------------------------------
  1365. function getCombatMonsterOutID(human, side, args)
  1366. if side ~= CombatDefine.DEFEND_SIDE then return end
  1367. local cityId = args[2]
  1368. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  1369. return cityCfg and cityCfg.pointMonsterId
  1370. end
  1371. function getCombatObjList(human, side, args, combatType, extraArgs)
  1372. if side == CombatDefine.ATTACK_SIDE and not human then return end
  1373. if side == CombatDefine.DEFEND_SIDE and human then
  1374. return
  1375. end
  1376. if not human then
  1377. local uuid = args[1]
  1378. local db = RoleDBLogic.getDb(uuid)
  1379. if not db then
  1380. return
  1381. end
  1382. human = {}
  1383. human.db = db
  1384. end
  1385. return CombatLogic.getHumanObjList(human, combatType, extraArgs)
  1386. end
  1387. function getCombatHeros(human, combatType, args)
  1388. if not human.db.anotherWorlBattle then
  1389. return
  1390. end
  1391. if not args then
  1392. return
  1393. end
  1394. local formation = human.db.anotherWorlBattle.formation
  1395. if not formation then
  1396. return
  1397. end
  1398. local cityId, pointIdx = args.cityId, args.pointIdx
  1399. if formation[cityId] and formation[cityId][pointIdx] then
  1400. local combatHeroDB = formation[cityId][pointIdx]
  1401. return combatHeroDB.list, combatHeroDB.helpList, combatHeroDB.formation or 1, combatHeroDB
  1402. end
  1403. end
  1404. function onFightBegin(human, cbParam, combatType, param)
  1405. if not human.AB_Battle_Cache or human.AB_Battle_Cache.isGather ~= 1 then
  1406. return
  1407. end
  1408. local gatherAttrs = AnotherWorldBattleConfig.var[1].gatherAttrs
  1409. for index = 1, CombatDefine.COMBAT_HERO_CNT do
  1410. local atkPos = CombatLogic.getPos(CombatDefine.ATTACK_SIDE, index)
  1411. local atkObj = CombatImpl.objList[atkPos]
  1412. if atkObj then
  1413. for _, atrrTb in ipairs(gatherAttrs) do
  1414. local attrId, attrVal = atrrTb[1], atrrTb[2]
  1415. atkObj.sysAttr[attrId] = (atkObj.sysAttr[attrId] or 0) + attrVal
  1416. end
  1417. atkObj.isSysAttrChange = true
  1418. end
  1419. end
  1420. end
  1421. function onFightEnd(human, result, type, cbParam, combatInfo)
  1422. -- if result == CombatDefine.RESULT_WIN then
  1423. -- challenge_Win(human, {cityId = human.AB_Battle_Cache.cityId, pointIdx = human.AB_Battle_Cache.pointIdx})
  1424. -- end
  1425. local args = {
  1426. cityId = human.AB_Battle_Cache.cityId,
  1427. pointIdx = human.AB_Battle_Cache.pointIdx,
  1428. challengeRes = result
  1429. }
  1430. human.AB_Battle_Cache = nil
  1431. challenge_End(human, args)
  1432. end