AnotherWorldBattleNS.lua 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  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 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. -- 获取排名奖励
  333. local function getRankAward(rankRewardList, rankType, targetRank)
  334. for _, v in ipairs(rankRewardList) do
  335. if v.nRankType == rankType and (targetRank >= v.nOrder[1] and targetRank <= v.nOrder[2]) then
  336. return v.Prize[1], v.Prize[2]
  337. end
  338. end
  339. end
  340. -- 生成奖励发放对象列表
  341. local function genAwardObjArr(unionOccupyInfo)
  342. local function calcMinute(timeArr)
  343. local minuteVal = 0
  344. for _, timeTb in ipairs(timeArr or {}) do
  345. local sec = (timeTb[2] or 0) - (timeTb[1] or 0)
  346. if sec > 0 then
  347. minuteVal = minuteVal + sec
  348. end
  349. end
  350. return math.floor(minuteVal / 60)
  351. end
  352. -- 没有玩家参与
  353. if not unionOccupyInfo.playerInfoArr or #unionOccupyInfo.playerInfoArr <= 0 then
  354. return
  355. end
  356. local itemList = {}
  357. local occupyCityInfo = {0,0,0,0,0}
  358. local item_185_Id = 185
  359. local item_185_Num = 0
  360. occupyCityInfo[1] = unionOccupyInfo.occuoyPointNum
  361. -- 额外奖励
  362. item_185_Num = item_185_Num + (unionOccupyInfo.occuoyPointNum or 0)
  363. for _, cityId in ipairs(unionOccupyInfo.occupyCityArr) do
  364. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  365. if cityCfg then
  366. if cityCfg.isBaseCity == 1 then
  367. item_185_Num = item_185_Num + 20
  368. else
  369. if cityCfg.cityLv == 2 then
  370. item_185_Num = item_185_Num + 2
  371. occupyCityInfo[2] = occupyCityInfo[2] + 1
  372. elseif cityCfg.cityLv == 3 then
  373. item_185_Num = item_185_Num + 3
  374. occupyCityInfo[3] = occupyCityInfo[3] + 1
  375. elseif cityCfg.cityLv == 4 then
  376. item_185_Num = item_185_Num + 5
  377. occupyCityInfo[4] = occupyCityInfo[4] + 1
  378. elseif cityCfg.cityLv == 5 then
  379. item_185_Num = item_185_Num + 20
  380. occupyCityInfo[5] = occupyCityInfo[5] + 1
  381. end
  382. end
  383. end
  384. end
  385. -- 占领据点每分钟的奖励
  386. for _, pointInfo in ipairs(unionOccupyInfo.point2CityIdArr) do
  387. local cityId = pointInfo[1]
  388. local occupyTimeArr = pointInfo[2]
  389. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  390. local totalMinVal = calcMinute(occupyTimeArr)
  391. if totalMinVal > 0 then
  392. local itemId, itemNum = cityCfg.cityAward[1], cityCfg.cityAward[2]
  393. itemList[itemId] = (itemList[itemId] or 0) + totalMinVal * itemNum
  394. end
  395. end
  396. if item_185_Num > 0 then
  397. itemList[item_185_Id] = item_185_Num
  398. end
  399. local itemArr = {}
  400. for itemId, itemNum in pairs(itemList) do
  401. itemArr[#itemArr+1] = { itemId, itemNum }
  402. end
  403. local rankReward = AnotherWorldBattleConfig.rankReward
  404. local awardObjArr = {}
  405. for _, playerInfo in ipairs(unionOccupyInfo.playerInfoArr) do
  406. local playerUuid = playerInfo[1]
  407. local playerRank = playerInfo[2]
  408. -- 据点每分钟奖励 + 额外奖励
  409. awardObjArr[#awardObjArr+1] = {playerUuid, itemArr, AnotherWorldBattleDefine.AB_AWARD_MAIL_ID}
  410. -- 公会排名奖励
  411. local itemId, itemNum = getRankAward(rankReward, 1, unionOccupyInfo.unionRank)
  412. if itemId and itemNum then
  413. awardObjArr[#awardObjArr+1] = {playerUuid, {{itemId, itemNum}}, AnotherWorldBattleDefine.AB_UNIONRANK_AWARD_MAIL_ID, unionOccupyInfo.unionRank}
  414. end
  415. -- 玩家排名奖励
  416. local itemId2, itemNum2 = getRankAward(rankReward, 2, playerRank)
  417. if itemId2 and itemNum2 then
  418. awardObjArr[#awardObjArr+1] = {playerUuid, {{itemId2, itemNum2}}, AnotherWorldBattleDefine.AB_PLAYERRANK_AWARD_MAIL_ID, playerRank}
  419. end
  420. end
  421. return awardObjArr, occupyCityInfo
  422. end
  423. -- 活动是否处于开启中
  424. function IsRuning(joinTime)
  425. if not joinTime then
  426. return true
  427. end
  428. local wDay = getWDay()
  429. if wDay > AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[2] and wDay < AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[1] then
  430. return false
  431. end
  432. local now = os.time()
  433. local toDayStartTime = Util.getDayStartTime(now)
  434. if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] == wDay and now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
  435. return false
  436. end
  437. local diffDays = Util.diffDay(joinTime)
  438. local joinWday = Util.getWeekDay(joinTime)
  439. -- 如果是周六加入则相差5天, 如果是周日加入则相差4天。 当前时间与加入时间相差4或5天, 则都表示当前可能是活动最后一天, 如果当前时间 > 结束时间则活动结束
  440. if (diffDays == 5 and joinWday == 7) or (diffDays == 4 and joinWday == 1) then
  441. if now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
  442. return false
  443. end
  444. end
  445. -- < 5天说明处于本轮活动的开启时间
  446. if diffDays > 5 then
  447. return false
  448. end
  449. return true
  450. end
  451. --检测上阵英雄
  452. function checkUpdatePos(human, msg)
  453. local heroList = Util.split(msg.heroList, ",")
  454. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  455. local uuid = heroList[i] or ""
  456. if uuid ~= "0" and uuid ~= "" then
  457. if isDefHero(human, uuid) then
  458. return false
  459. end
  460. end
  461. end
  462. return true
  463. end
  464. -- 公会战力更新
  465. function UnionPowerChange(unionId, newPower)
  466. if not actStartTimeCheck() then
  467. return false
  468. end
  469. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
  470. msgData.myUnionId = unionId
  471. msgData.updateData = {}
  472. msgData.updateData.power = newPower
  473. InnerMsg.sendMsg(0, msgData)
  474. end
  475. -- 玩家战力更新
  476. function PlayerPowerChange(human)
  477. if not baseCondCheck(human) then
  478. return false
  479. end
  480. if not actStartTimeCheck() then
  481. return false
  482. end
  483. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
  484. msgData.playerUuid = human.db._id
  485. msgData.myUnionId = human.db.unionUuid
  486. msgData.updateData = {}
  487. msgData.updateData.power = human.db.zhandouli
  488. InnerMsg.sendMsg(0, msgData)
  489. end
  490. -- 英雄更新
  491. function HeroDataUpdate(human, heroUuid)
  492. if not baseCondCheck(human) then
  493. return false
  494. end
  495. if not actStartTimeCheck() then
  496. return false
  497. end
  498. local cityId, pointIdx = isDefHero(human, heroUuid)
  499. if not cityId then
  500. return
  501. end
  502. HeroLogic = HeroLogic or require("hero.HeroLogic")
  503. local heroGrid = HeroLogic.getHeroGridByUuid(human, heroUuid)
  504. if heroGrid then
  505. RoleAttr.calcHeroGrid(heroGrid, nil, human)
  506. local heroInfo = {
  507. heroUuid = heroUuid,
  508. heroStar = heroGrid.star,
  509. heroLevel = heroGrid.lv,
  510. heroPower = heroGrid.zhandouli,
  511. }
  512. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_HERO
  513. msgData.playerUuid = human.db._id
  514. msgData.targetCityId = cityId
  515. msgData.targetPointIdx = pointIdx
  516. msgData.heroData = heroInfo
  517. InnerMsg.sendMsg(0, msgData)
  518. end
  519. end
  520. -- 玩家改名
  521. function PlayerChangeName(human)
  522. if not baseCondCheck(human) then
  523. return false
  524. end
  525. if not actStartTimeCheck() then
  526. return false
  527. end
  528. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
  529. msgData.playerUuid = human.db._id
  530. msgData.myUnionId = human.db.unionUuid
  531. msgData.updateData = {}
  532. msgData.updateData.name = human.db.name
  533. InnerMsg.sendMsg(0, msgData)
  534. end
  535. -- 公会改名
  536. function UnionChangeName(unionId, newName)
  537. if not actStartTimeCheck() then
  538. return false
  539. end
  540. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
  541. msgData.myUnionId = unionId
  542. msgData.updateData = {}
  543. msgData.updateData.name = newName
  544. InnerMsg.sendMsg(0, msgData)
  545. end
  546. function isDot(human)
  547. if not baseCondCheck(human) then
  548. return false
  549. end
  550. if not actStartTimeCheck() then
  551. return false
  552. end
  553. return true
  554. end
  555. function onLogin(human)
  556. formationDataCheeck(human)
  557. sendDefHeroArr(human)
  558. end
  559. -- 请求状态
  560. function AB_GetState(human)
  561. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GET_STATE
  562. msgData.sourceServerId = Config.SVR_INDEX
  563. msgData.playerUuid = human.db._id
  564. msgData.myUnionId = human.db.unionUuid or ""
  565. InnerMsg.sendMsg(0, msgData)
  566. end
  567. -- 报名
  568. function AB_Join(human)
  569. local unionId = human.db.unionUuid
  570. local msgRet = Msg.gc.GC_AB_JOIN
  571. if not unionId then
  572. msgRet.Joinstate = 3
  573. return Msg.send(msgRet, human.fd)
  574. end
  575. local wDay = getWDay()
  576. -- if wDay ~= AnotherWorldBattleDefine.AB_JOIN_WDAY then
  577. -- msgRet.Joinstate = 5
  578. -- return Msg.send(msgRet, human.fd)
  579. -- end
  580. if not table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
  581. msgRet.Joinstate = 5
  582. return Msg.send(msgRet, human.fd)
  583. end
  584. -- 公会排名前二才能参加
  585. if not isTopTwoUnion(human) then
  586. msgRet.Joinstate = 2
  587. return Msg.send(msgRet, human.fd)
  588. end
  589. -- 会长/副会长才能报名
  590. if not UnionLogic.IsTopTwoManager(human, unionId) then
  591. return Broadcast.sendErr(human, Lang.AB_NOT_TOPTWO_MANGER)
  592. end
  593. local queryFiles = {name = 1, zhandouli = 1}
  594. local unionInfo = UnionLogic.GetUnionData(unionId, queryFiles)
  595. if not unionInfo then
  596. return Broadcast.sendErr(human, Lang.DATA_ERR)
  597. end
  598. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_JOIN
  599. msgData.sourceServerId = Config.SVR_INDEX
  600. msgData.playerUuid = human.db._id
  601. msgData.unionInfo = {
  602. name = unionInfo.name,
  603. power = unionInfo.zhandouli,
  604. unionId = unionId
  605. }
  606. InnerMsg.sendMsg(0, msgData)
  607. end
  608. -- 查询所有城池信息
  609. function AB_AllCity_Query(human)
  610. if not human.db.unionUuid then
  611. return
  612. end
  613. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_ALLCITY_QUERY
  614. msgData.sourceServerId = Config.SVR_INDEX
  615. msgData.playerUuid = human.db._id
  616. msgData.myUnionId = human.db.unionUuid
  617. InnerMsg.sendMsg(0, msgData)
  618. -- 报名状态查询
  619. -- local msgData2 = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GET_JOIN_STATE
  620. -- msgData2.sourceServerId = Config.SVR_INDEX
  621. -- msgData2.playerUuid = human.db._id
  622. -- msgData2.myUnionId = human.db.unionUuid
  623. -- InnerMsg.sendMsg(0, msgData2)
  624. end
  625. -- 查询单个城池的详细信息
  626. function AB_CityDetailed_Query(human, targetCityId)
  627. if not AnotherWorldBattleConfig.city[targetCityId] then
  628. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  629. end
  630. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_CITYDETAILED_QUERY
  631. msgData.sourceServerId = Config.SVR_INDEX
  632. msgData.playerUuid = human.db._id
  633. msgData.myUnionId = human.db.unionUuid
  634. msgData.targetCityId = targetCityId
  635. InnerMsg.sendMsg(0, msgData)
  636. end
  637. -- 查询某个城池的某个据点的详细信息
  638. function AB_PointDetailed_Query(human, targetCityId, targetPointIdx)
  639. if not AnotherWorldBattleConfig.city[targetCityId] then
  640. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  641. end
  642. if 0 >= targetPointIdx or AnotherWorldBattleDefine.AB_POINT_MAX_NUM < targetPointIdx then
  643. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  644. end
  645. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINTtDETAILED_QUERY
  646. msgData.sourceServerId = Config.SVR_INDEX
  647. msgData.playerUuid = human.db._id
  648. msgData.myUnionId = human.db.unionUuid
  649. msgData.targetCityId = targetCityId
  650. msgData.targetPointIdx = targetPointIdx
  651. InnerMsg.sendMsg(0, msgData)
  652. end
  653. -- 查询本公会出生点信息
  654. function AB_BaseCity_Query(human)
  655. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_BASECITY_QUERY
  656. msgData.sourceServerId = Config.SVR_INDEX
  657. msgData.playerUuid = human.db._id
  658. msgData.myUnionId = human.db.unionUuid
  659. InnerMsg.sendMsg(0, msgData)
  660. end
  661. -- 查询玩家占领的所有据点信息
  662. function AB_PlayerOccupyPOint_Query(human)
  663. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_PLAYEROCCUPYPOINT_QUERY
  664. msgData.sourceServerId = Config.SVR_INDEX
  665. msgData.playerUuid = human.db._id
  666. msgData.myUnionId = human.db.unionUuid
  667. InnerMsg.sendMsg(0, msgData)
  668. end
  669. -- 查询公会排行榜
  670. function AB_UnionRank_Query(human)
  671. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UNIONRANK_QUERY
  672. msgData.sourceServerId = Config.SVR_INDEX
  673. msgData.playerUuid = human.db._id
  674. msgData.myUnionId = human.db.unionUuid
  675. InnerMsg.sendMsg(0, msgData)
  676. end
  677. -- 查询玩家排行榜
  678. function AB_PlayerRank_Query(human)
  679. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_PLAYERRANK_QUERY
  680. msgData.sourceServerId = Config.SVR_INDEX
  681. msgData.playerUuid = human.db._id
  682. msgData.myUnionId = human.db.unionUuid
  683. InnerMsg.sendMsg(0, msgData)
  684. end
  685. -- 发起集结
  686. function AB_Gather(human, targetCityId, opType)
  687. if not AnotherWorldBattleConfig.city[targetCityId] then
  688. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  689. end
  690. if opType ~= 1 and opType ~= 2 then
  691. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  692. end
  693. local unionId = human.db.unionUuid
  694. if not unionId then
  695. return Broadcast.sendErr(human, Lang.AB_NO_UNION)
  696. end
  697. -- 会长/副会长才能集结
  698. if not UnionLogic.IsTopTwoManager(human, unionId) then
  699. return Broadcast.sendErr(human, Lang.AB_NOT_TOPTWO_MANAGER)
  700. end
  701. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GATHER
  702. msgData.sourceServerId = Config.SVR_INDEX
  703. msgData.playerUuid = human.db._id
  704. msgData.myUnionId = human.db.unionUuid
  705. msgData.targetCityId = targetCityId
  706. msgData.opType = opType
  707. InnerMsg.sendMsg(0, msgData)
  708. end
  709. -- 请求挑战某个据点
  710. function AB_Try_Challenge_Point(human, targetCityId, targetPointIdx)
  711. local combatHero = CombatPosLogic.getCombatHeros(human, CombatDefine.COMBAT_TYPE35)
  712. if not combatHero or not next(combatHero) then
  713. return Broadcast.sendErr(human, Lang.COMBAT_NEED_FIGHT_HERO)
  714. end
  715. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINT_ISCAN_CHALLENGE
  716. msgData.sourceServerId = Config.SVR_INDEX
  717. msgData.playerUuid = human.db._id
  718. msgData.myUnionId = human.db.unionUuid
  719. msgData.targetCityId = targetCityId
  720. msgData.targetPointIdx = targetPointIdx
  721. InnerMsg.sendMsg(0, msgData)
  722. end
  723. -- 战斗结束
  724. local function challenge_End(human, args)
  725. local cityId = args.cityId
  726. local pointIdx = args.pointIdx
  727. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_POINT_CHALLENGE_END
  728. msgData.sourceServerId = Config.SVR_INDEX
  729. msgData.playerUuid = human.db._id
  730. msgData.myUnionId = human.db.unionUuid
  731. msgData.targetCityId = cityId
  732. msgData.targetPointIdx = pointIdx
  733. msgData.challengeRes = args.challengeRes
  734. -- 挑战没有胜利
  735. if args.challengeRes ~= CombatDefine.RESULT_WIN then
  736. -- 说明之前已经在跨服上保存玩家的基础数据了
  737. -- if human.db.anotherWorlBattle then
  738. -- return
  739. -- end
  740. msgData.playerShowInfo = {
  741. name = human.db.name,
  742. lv = human.db.lv,
  743. power = human.db.zhandouli,
  744. }
  745. return InnerMsg.sendMsg(0, msgData)
  746. end
  747. if not human.db.anotherWorlBattle then
  748. human.db.anotherWorlBattle = {
  749. startTime = os.time(),
  750. formation = {}
  751. }
  752. end
  753. -- 把当前战斗阵容数据保存到当前模块,作为防守阵容
  754. local combatData = CombatPosLogic.getCombatHeroDB(human, CombatDefine.COMBAT_TYPE35)
  755. local formationData = human.db.anotherWorlBattle.formation or {}
  756. formationData[cityId] = formationData[cityId] or {}
  757. formationData[cityId][pointIdx] = Util.copyTable(combatData)
  758. -- 把最新的防守英雄uuid列表推送给客户端
  759. sendDefHeroArr(human)
  760. --同步到跨服
  761. msgData.playerShowInfo = generateShowInfo(human)
  762. InnerMsg.sendMsg(0, msgData)
  763. -- 清空战斗阵容
  764. CombatPosLogic.cleanCombatHeros(human, CombatDefine.COMBAT_TYPE35)
  765. end
  766. -- 更换据点的防守阵容
  767. function AB_Update_Lineup(human, msg)
  768. if not isBattleStage() then
  769. return Broadcast.sendErr(human, Lang.AB_NOT_BATTLE_TIME)
  770. end
  771. local anotherWorlBattle = human.db.anotherWorlBattle
  772. if not anotherWorlBattle or not anotherWorlBattle.formation then
  773. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_POINT)
  774. end
  775. local cityId = msg.cityId
  776. local pointIdx = msg.pointIdx
  777. local formationData = anotherWorlBattle.formation
  778. if not formationData[cityId] or not formationData[cityId][pointIdx] then
  779. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_TARGET_POINT)
  780. end
  781. local res, heroList, helpList = CombatPosLogic.CheckUpdatePos(human, msg)
  782. if not res then
  783. return Broadcast.sendErr(human, Lang.COMBAT_POS__ERR)
  784. end
  785. local len = 0
  786. local heroArr = {}
  787. for i = 1, CombatDefine.COMBAT_HERO_CNT do
  788. local uuid = heroList[i] or ""
  789. if uuid ~= "0" and uuid ~= "" then
  790. if isDefHero(human, uuid, cityId, pointIdx) then
  791. return Broadcast.sendErr(human, Lang.AB_HERO_IN_OTHER_POINT)
  792. end
  793. len = len + 1
  794. heroArr[len] = getHeroInfo(human, uuid)
  795. end
  796. end
  797. if len == 0 then
  798. return
  799. end
  800. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP
  801. msgData.sourceServerId = Config.SVR_INDEX
  802. msgData.playerUuid = human.db._id
  803. msgData.heroArr = heroArr
  804. msgData.targetCityId = cityId
  805. msgData.targetPointIdx = pointIdx
  806. msgData.formation = msg.formation
  807. msgData.heroList = heroList
  808. msgData.helpList = helpList
  809. InnerMsg.sendMsg(0, msgData)
  810. end
  811. -- 放弃据点
  812. function AB_Leave_Point(human, msg)
  813. local targetCityId = msg.cityId
  814. if not AnotherWorldBattleConfig.city[targetCityId] then
  815. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  816. end
  817. local targetPointIdx = msg.pointIdx
  818. if targetPointIdx <= 0 or targetPointIdx > AnotherWorldBattleDefine.AB_POINT_MAX_NUM then
  819. return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
  820. end
  821. local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_LEAVE_POINT
  822. msgData.sourceServerId = Config.SVR_INDEX
  823. msgData.playerUuid = human.db._id
  824. msgData.myUnionId = human.db.unionUuid
  825. msgData.targetCityId = targetCityId
  826. msgData.targetPointIdx = targetPointIdx
  827. InnerMsg.sendMsg(0, msgData)
  828. end
  829. --获取据点的防守阵容数据
  830. function AB_Get_Point_Lineup(human, msg)
  831. local targetCityId = msg.cityId
  832. local targetPointIdx = msg.pointIdx
  833. local anotherWorlBattle = human.db.anotherWorlBattle
  834. local formationData = anotherWorlBattle.formation
  835. if not formationData[targetCityId] or not formationData[targetCityId][targetPointIdx] then
  836. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_TARGET_POINT)
  837. end
  838. local extraArgs = {
  839. cityId = targetCityId,
  840. pointIdx = targetPointIdx
  841. }
  842. CombatPosLogic.posQuery(human, msg.type, msg.groupID, msg.param, 1, extraArgs)
  843. end
  844. ------------------------------------C2N---------------------------------------------------
  845. -- 跨服通知活动开启
  846. function C2N_Act_Start(msg)
  847. local startTime = msg.startTime
  848. if not startTime or startTime == 0 then
  849. return
  850. end
  851. CommonDB.updateValue(CommonDB.KEY_ANOTHERWORLDBATTLE_START_TI, startTime)
  852. end
  853. -- 错误提示
  854. function C2N_ErrTips(msg)
  855. local human = ObjHuman.onlineUuid[msg.playerUuid]
  856. if not human then
  857. return
  858. end
  859. local tips = Lang.DATA_ERR
  860. local errCode = msg.errCode
  861. if errCode == AnotherWorldBattleDefine.ERR_CODE_1 then
  862. tips = Lang.AB_NOT_OPEN_TIME
  863. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_2 then
  864. tips = Lang.AB_NOT_UNION_NUM_EXCEED
  865. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_3 then
  866. tips = Lang.AB_UNION_NO_JOIN
  867. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_4 then
  868. tips = Lang.DATA_ERR
  869. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_5 then
  870. tips = Lang.AB_NOT_OCCUPY_POINT
  871. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_6 then
  872. tips = Lang.AB_GATHER_CD
  873. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_7 then
  874. tips = Lang.AB_CITY_NOT_ADDJION
  875. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_8 then
  876. tips = Lang.AB_JOINED
  877. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_9 then
  878. tips = Lang.AB_CITY_NO_GATHER
  879. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_10 then
  880. tips = Lang.AB_OCCUPY_POINT_MAX
  881. elseif errCode == AnotherWorldBattleDefine.ERR_CODE_11 then
  882. tips = Lang.AB_POINT_CHALLENGING
  883. end
  884. Broadcast.sendErr(human, tips)
  885. end
  886. -- 跨服返回状态
  887. function C2N_State(msg)
  888. local human = ObjHuman.onlineUuid[msg.playerUuid]
  889. if not human then
  890. return
  891. end
  892. local msgRet = Msg.gc.GC_AB_GetState
  893. msgRet.joinState = msg.joinState
  894. msgRet.systemState = msg.systemState
  895. if msgRet.joinState == 0 then
  896. local unionId = human.db.unionUuid
  897. if not unionId then
  898. msgRet.Joinstate = 2
  899. return Msg.send(msgRet, human.fd)
  900. end
  901. -- 公会排名前二才行
  902. if not isTopTwoUnion(human) then
  903. msgRet.Joinstate = 2
  904. return Msg.send(msgRet, human.fd)
  905. end
  906. end
  907. Msg.send(msgRet, human.fd)
  908. end
  909. -- 报名成功
  910. function C2N_Join_Succ(msg)
  911. local now = os.time()
  912. local unionId = msg.myUnionId
  913. UnionLogic.UpdateJoinAbTime(unionId, now)
  914. local human = ObjHuman.onlineUuid[msg.playerUuid]
  915. if not human then
  916. return
  917. end
  918. local msgRet = Msg.gc.GC_AB_JOIN
  919. msgRet.Joinstate = 1
  920. Msg.send(msgRet, human.fd)
  921. end
  922. -- 跨服返回的所有城池数据
  923. function C2N_AllCity_Query(msg)
  924. local human = ObjHuman.onlineUuid[msg.playerUuid]
  925. if not human then
  926. return
  927. end
  928. local msgRet = Msg.gc.GC_AB_ALLCITY_QUERY
  929. msgRet.myBaseCityId = msg.myUnionBaseCityId
  930. msgRet.hasPointNum = msg.hasPointNum
  931. msgRet.challengeTimes = msg.challengeTimes
  932. local now = os.time()
  933. msgRet.leftTime = msg.lastTime
  934. if msgRet.leftTime ~= 0 then
  935. msgRet.leftTime = (msg.lastTime + AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC) - now
  936. end
  937. msgRet.cityArr[0] = 0
  938. local cityArrMsg = msgRet.cityArr
  939. for cityId, cityInfo in ipairs(msg.cityArr) do
  940. cityArrMsg[0] = cityId
  941. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  942. cityArrMsg[cityId].cityId = cityId
  943. cityArrMsg[cityId].cityName = cityCfg.cityName
  944. cityArrMsg[cityId].cityLv = cityCfg.cityLv
  945. cityArrMsg[cityId].occupyPointNum = cityInfo.occupyPointNum or 0
  946. cityArrMsg[cityId].occupyUnionName = cityInfo.occupyUnionName or ""
  947. cityArrMsg[cityId].cityState = cityInfo.cityState
  948. cityArrMsg[cityId].adJoinCityArr[0] = #cityCfg.adJoinCityArr
  949. for i, cId in ipairs(cityCfg.adJoinCityArr) do
  950. cityArrMsg[cityId].adJoinCityArr[i] = cId
  951. end
  952. end
  953. msgRet.myOccupyCityArr[0] = #msg.myOccupyCityArr
  954. for i, cityId in ipairs(msg.myOccupyCityArr) do
  955. msgRet.myOccupyCityArr[i] = cityId
  956. end
  957. -- 据点每分钟的奖励
  958. local itemId, itemNum = 0, 0
  959. local cityCfg = AnotherWorldBattleConfig.city[1]
  960. itemId = cityCfg.cityAward[1]
  961. for _, pointInfo in ipairs(msg.occupyPointData) do
  962. local cityId = pointInfo[1]
  963. local occupyTimeArr = pointInfo[2]
  964. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  965. local minuteVal = 0
  966. for _, timeTb in ipairs(occupyTimeArr) do
  967. local sec = (timeTb[2] or now) - (timeTb[1] or now)
  968. if sec > 0 then
  969. minuteVal = minuteVal + sec
  970. end
  971. minuteVal = math.floor(minuteVal / 60)
  972. end
  973. itemNum = itemNum + minuteVal * cityCfg.cityAward[2]
  974. end
  975. Grid.makeItem(msgRet.myUnionAward, itemId, itemNum)
  976. Msg.send(msgRet, human.fd)
  977. end
  978. -- 跨服返回某个城池详细数据
  979. function C2N_CityDetailed_Query(msg)
  980. local human = ObjHuman.onlineUuid[msg.playerUuid]
  981. if not human then
  982. return
  983. end
  984. local cityCfg = AnotherWorldBattleConfig.city[msg.targetCityId]
  985. local msgRet = Msg.gc.GC_AB_CITY_DETAILED_QUERY
  986. msgRet.cityId = msg.targetCityId
  987. msgRet.cityLv = cityCfg.cityLv
  988. msgRet.cityIconId = cityCfg.cityIconId
  989. Grid.makeItem(msgRet.cityAward, cityCfg.cityAward[1], cityCfg.cityAward[2] * AnotherWorldBattleDefine.AB_POINT_MAX_NUM )
  990. local myUnionAwardNum = calcPointAward(msg.myUnionOccupyArr)
  991. Grid.makeItem(msgRet.myUnionAward, cityCfg.cityAward[1], myUnionAwardNum)
  992. -- 活动没有进入战斗阶段时, 使用默认数据
  993. if #msg.pointArr == 0 then
  994. for i=1, AnotherWorldBattleDefine.AB_POINT_MAX_NUM do
  995. msg.pointArr[i] = {}
  996. end
  997. end
  998. msgRet.pointArr[0] = AnotherWorldBattleDefine.AB_POINT_MAX_NUM
  999. for pointIdx, pointInfo in ipairs(msg.pointArr) do
  1000. if pointInfo.occupyUnionName then
  1001. msgRet.pointArr[pointIdx].occupyUnionName = pointInfo.occupyUnionName
  1002. msgRet.pointArr[pointIdx].occupyPlayerName = pointInfo.occupyPlayerName
  1003. msgRet.pointArr[pointIdx].power = pointInfo.power
  1004. msgRet.pointArr[pointIdx].state = pointInfo.state
  1005. else
  1006. msgRet.pointArr[pointIdx].occupyUnionName = ""
  1007. msgRet.pointArr[pointIdx].occupyPlayerName = AnotherWorldBattleDefine.AB_DEF_NAME_STR.. pointIdx
  1008. msgRet.pointArr[pointIdx].power = calcMonsterPower(cityCfg.pointMonsterId)
  1009. msgRet.pointArr[pointIdx].state = pointInfo.state
  1010. end
  1011. end
  1012. msgRet.gatherState = msg.gatherState
  1013. if msg.gatherState == 1 then
  1014. -- 公会会长/副会长才能集结
  1015. if not UnionLogic.IsTopTwoManager(human, human.db.unionUuid) then
  1016. msgRet.gatherState = 0
  1017. end
  1018. end
  1019. msgRet.gatherLeftTime = msg.gatherTime
  1020. if msg.gatherTime ~= -1 then
  1021. local now = os.time()
  1022. local subSec = msg.gatherTime + AnotherWorldBattleDefine.AB_GATHER_CD_SEC - now
  1023. msgRet.gatherLeftTime = subSec > 0 and subSec or 0
  1024. end
  1025. Msg.send(msgRet, human.fd)
  1026. end
  1027. -- 跨服返回某个据点数据
  1028. function C2N_PointDetailed_Query(msg)
  1029. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1030. if not human then
  1031. return
  1032. end
  1033. local pointInfo = msg.pointInfo
  1034. local msgRet = Msg.gc.GC_AB_POINT_DETAILEDINFO_QUERY
  1035. msgRet.state = pointInfo.state
  1036. if pointInfo.name then
  1037. msgRet.name = pointInfo.name
  1038. msgRet.power = pointInfo.power
  1039. msgRet.head = pointInfo.head
  1040. msgRet.headFrame = pointInfo.headFrame
  1041. msgRet.defLv = pointInfo.defLv
  1042. msgRet.heroArr[0] = #pointInfo.heroArr
  1043. for i, heroInfo in ipairs(pointInfo.heroArr) do
  1044. msgRet.heroArr[i].heroBody = heroInfo.heroBody
  1045. msgRet.heroArr[i].heroStar = heroInfo.heroStar
  1046. msgRet.heroArr[i].heroLv = heroInfo.heroLv
  1047. msgRet.heroArr[i].heroCamp = heroInfo.heroCamp
  1048. msgRet.heroArr[i].heroIcon = heroInfo.heroIcon
  1049. msgRet.heroArr[i].heroId = heroInfo.heroId
  1050. msgRet.heroArr[i].heroQuality = heroInfo.heroQuality
  1051. end
  1052. else
  1053. msgRet.name = AnotherWorldBattleDefine.AB_DEF_NAME_STR .. msg.targetPointIdx
  1054. msgRet.head = getDefaultShowId(1, msg.targetPointIdx)
  1055. msgRet.headFrame = getDefaultShowId(2, msg.targetPointIdx)
  1056. msgRet.defLv = 200
  1057. local cityCfg = AnotherWorldBattleConfig.city[msg.targetCityId]
  1058. msgRet.power = calcMonsterPower(cityCfg.pointMonsterId)
  1059. msgRet.heroArr[0] = 0
  1060. local monsterOutConfig = MonsterExcel.monsterOut[cityCfg.pointMonsterId]
  1061. for idx, monsterInfo in ipairs(monsterOutConfig.member) do
  1062. if idx > 6 then
  1063. break
  1064. end
  1065. msgRet.heroArr[0] = idx
  1066. local monsterID = monsterInfo[1]
  1067. local mcf = MonsterExcel.monster[monsterID]
  1068. msgRet.heroArr[idx].heroBody = mcf.body
  1069. msgRet.heroArr[idx].heroStar = mcf.star
  1070. msgRet.heroArr[idx].heroLv = monsterInfo[2]
  1071. msgRet.heroArr[idx].heroCamp = mcf.camp
  1072. msgRet.heroArr[idx].heroIcon = mcf.head
  1073. msgRet.heroArr[idx].heroId = monsterID
  1074. msgRet.heroArr[idx].heroQuality = mcf.heroQuality or 1
  1075. end
  1076. end
  1077. Msg.send(msgRet, human.fd)
  1078. end
  1079. -- 跨服返回公会出生点数据
  1080. function C2N_BaseCity_Query(msg)
  1081. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1082. if not human then
  1083. return
  1084. end
  1085. local baseCityInfo = msg.baseCityInfo
  1086. local msgRet = Msg.gc.GC_AB_BASECITY_QUERY
  1087. local cityCfg = AnotherWorldBattleConfig.city[baseCityInfo.cityId]
  1088. msgRet.cityIconId = cityCfg.cityIconId
  1089. Grid.makeItem(msgRet.cityAward, cityCfg.cityAward[1], cityCfg.cityAward[2] * AnotherWorldBattleDefine.AB_POINT_MAX_NUM)
  1090. local myUnionAwardNum = calcPointAward(baseCityInfo.myUnionOccupyArr)
  1091. Grid.makeItem(msgRet.myUnionAward, cityCfg.cityAward[1], myUnionAwardNum)
  1092. msgRet.cityIconId = baseCityInfo.occupyPointNum
  1093. msgRet.occupyPointNum = baseCityInfo.occupyPointNum
  1094. msgRet.occupyCityLv2Num = baseCityInfo.occupyCityLv2Num
  1095. msgRet.occupyCityLv3Num = baseCityInfo.occupyCityLv3Num
  1096. msgRet.occupyCityLv4Num = baseCityInfo.occupyCityLv4Num
  1097. msgRet.occupyCityLv5Num = baseCityInfo.occupyCityLv5Num
  1098. Msg.send(msgRet, human.fd)
  1099. end
  1100. -- 跨服返回玩家占领的据点数据
  1101. function C2N_PlayerOccupyPoint_Query(msg)
  1102. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1103. if not human then
  1104. return
  1105. end
  1106. local msgRet = Msg.gc.GC_AB_MY_OCCUPY_POINT_QUERY
  1107. local myPointArr = msgRet.myPointArr
  1108. myPointArr[0] = 0
  1109. for idx, pointInfo in ipairs(msg.occupyPointArr) do
  1110. myPointArr[0] = idx
  1111. local cityCfg = AnotherWorldBattleConfig.city[pointInfo.cityId]
  1112. myPointArr[idx].cityIconId = cityCfg.cityIconId
  1113. myPointArr[idx].cityName = cityCfg.cityName
  1114. myPointArr[idx].cityLv = cityCfg.cityLv
  1115. myPointArr[idx].pointIdx = pointInfo.pointIdx
  1116. myPointArr[idx].power = pointInfo.power
  1117. myPointArr[idx].cityId = pointInfo.cityId
  1118. myPointArr[idx].heroArr[0] = #pointInfo.heroArr
  1119. for heroIdx, heroInfo in ipairs(pointInfo.heroArr) do
  1120. local hero = myPointArr[idx].heroArr[heroIdx]
  1121. hero.heroBody = heroInfo.heroBody
  1122. hero.heroStar = heroInfo.heroStar
  1123. hero.heroLv = heroInfo.heroLv
  1124. hero.heroCamp = heroInfo.heroCamp
  1125. hero.heroIcon = heroInfo.heroIcon
  1126. hero.heroId = heroInfo.heroId
  1127. hero.heroQuality = heroInfo.heroQuality
  1128. end
  1129. end
  1130. Msg.send(msgRet, human.fd)
  1131. end
  1132. -- 跨服返回集结/取消集结成功
  1133. function C2N_Gather_End(msg)
  1134. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1135. if not human then
  1136. return
  1137. end
  1138. local targetCityId = msg.targetCityId
  1139. local cityCfg = AnotherWorldBattleConfig.city[targetCityId]
  1140. local msgRet = Msg.gc.GC_AB_GARHER
  1141. msgRet.cityId = targetCityId
  1142. msgRet.cityName = cityCfg.cityName
  1143. msgRet.opType = msg.opType
  1144. Msg.send(msgRet, human.fd)
  1145. end
  1146. --跨服返回公会排行榜数据
  1147. function C2N_UnionRank_Query(msg)
  1148. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1149. if not human then
  1150. return
  1151. end
  1152. local msgRet = Msg.gc.GC_AB_UNION_RANK_QUERY
  1153. msgRet.unionRankArr[0] = 0
  1154. msgRet.myUnionRank = msg.myUnionRank
  1155. msgRet.myData.name = ""
  1156. msgRet.myData.power = 0
  1157. msgRet.myData.cityNum = 0
  1158. msgRet.myData.pointNum = 0
  1159. local rankReward = AnotherWorldBattleConfig.rankReward
  1160. for rank, rankdData in ipairs(msg.unionRankArr) do
  1161. msgRet.unionRankArr[0] = rank
  1162. msgRet.unionRankArr[rank].name = rankdData.name
  1163. msgRet.unionRankArr[rank].power = rankdData.power
  1164. msgRet.unionRankArr[rank].cityNum = rankdData.cityNum
  1165. msgRet.unionRankArr[rank].pointNum = rankdData.pointNum
  1166. local itemId, itemNum = 184, 0
  1167. itemId, itemNum = getRankAward(rankReward, 1, rank)
  1168. Grid.makeItem(msgRet.unionRankArr[rank].rankAward, itemId, itemNum)
  1169. if rank == msg.myUnionRank then
  1170. msgRet.myData.name = rankdData.name
  1171. msgRet.myData.power = rankdData.power
  1172. msgRet.myData.cityNum = rankdData.cityNum
  1173. msgRet.myData.pointNum = rankdData.pointNum
  1174. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1175. end
  1176. end
  1177. if msgRet.myData.power == 0 then
  1178. local unionId = human.db.unionUuid
  1179. local queryFiles = {name = 1, zhandouli = 1}
  1180. local unionInfo = UnionLogic.GetUnionData(unionId, queryFiles)
  1181. msgRet.myData.name = unionInfo and unionInfo.name or ""
  1182. msgRet.myData.power = unionInfo and unionInfo.zhandouli or 0
  1183. end
  1184. Msg.send(msgRet, human.fd)
  1185. end
  1186. --跨服返回玩家排行榜数据
  1187. function C2N_PlayerRank_Query(msg)
  1188. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1189. if not human then
  1190. return
  1191. end
  1192. local rankReward = AnotherWorldBattleConfig.rankReward
  1193. local msgRet = Msg.gc.GC_AB_PLAYER_RANK_QUERY
  1194. msgRet.playerRankArr[0] = 0
  1195. msgRet.myRank = msg.myRank
  1196. msgRet.myData.name = human.db.name
  1197. msgRet.myData.power = human.db.zhandouli
  1198. msgRet.myData.pointNum = 0
  1199. msgRet.myData.pointWeight = 0
  1200. Grid.makeItem(msgRet.myData.rankAward, 184, 0)
  1201. for rank, rankdData in ipairs(msg.playerRankArr) do
  1202. msgRet.playerRankArr[0] = rank
  1203. msgRet.playerRankArr[rank].name = rankdData.name
  1204. msgRet.playerRankArr[rank].power = rankdData.power
  1205. msgRet.playerRankArr[rank].pointNum = rankdData.pointNum
  1206. msgRet.playerRankArr[rank].pointWeight = rankdData.pointWeight
  1207. local itemId, itemNum = 184, 0
  1208. itemId, itemNum = getRankAward(rankReward, 2, rank)
  1209. Grid.makeItem(msgRet.playerRankArr[rank].rankAward, itemId, itemNum)
  1210. if rank == msg.myRank then
  1211. msgRet.myData.pointNum = rankdData.pointNum
  1212. msgRet.myData.pointWeight = rankdData.pointWeight
  1213. Grid.makeItem(msgRet.myData.rankAward, itemId, itemNum)
  1214. end
  1215. end
  1216. Msg.send(msgRet, human.fd)
  1217. end
  1218. -- 跨服返回要挑战的据点的数据(据点可以被挑战)
  1219. function C2N_Challenge_Point_OK(msg)
  1220. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1221. if not human then
  1222. return
  1223. end
  1224. local pointInfo = msg.pointInfo
  1225. human.AB_Battle_Cache = {
  1226. isGather = pointInfo.isGather,
  1227. cityId = pointInfo.targetCityId,
  1228. pointIdx = pointInfo.targetPointIdx,
  1229. }
  1230. if pointInfo.occupySrvId then -- 玩家占领
  1231. local args = {
  1232. combatType = CombatDefine.COMBAT_TYPE35,
  1233. nServerIndex = pointInfo.occupySrvId,
  1234. param = pointInfo.occupyPlayerUuid,
  1235. extraArgs = {
  1236. cityId = pointInfo.targetCityId,
  1237. pointIdx = pointInfo.targetPointIdx,
  1238. useDef = true,
  1239. }
  1240. }
  1241. MiddleCommonLogic.MiddleCommonLogic_CombatBegin_LW(human, args)
  1242. else
  1243. -- 机器人
  1244. CombatLogic.combatBegin(human, nil, {human.db._id, pointInfo.targetCityId }, CombatDefine.COMBAT_TYPE35)
  1245. end
  1246. end
  1247. -- 跨服通知据点被别的玩家占领了
  1248. function C2N_Point_Lose(msg)
  1249. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1250. if not human then
  1251. local db = RoleDBLogic.getDb(msg.playerUuid) --后续可优化只取 anotherWorlBattle 数据
  1252. if not db then
  1253. return
  1254. end
  1255. human = {}
  1256. human.db = db
  1257. end
  1258. -- 更新防守阵容数据
  1259. local loseCityId = msg.loseCityId
  1260. local losePointIdx = msg.losePointIdx
  1261. local formationData = human.db.anotherWorlBattle.formation
  1262. formationData[loseCityId][losePointIdx] = nil
  1263. -- 玩家不在线, 手动保存数据
  1264. if not human.fd then
  1265. ObjHuman.save(human) --后续可优化只更新 anotherWorlBattle 数据
  1266. end
  1267. local cityCfg = AnotherWorldBattleConfig.city[loseCityId]
  1268. -- 发邮件
  1269. local mailCfg = MailExcel.mail[AnotherWorldBattleDefine.AB_LOSE_POINT_MAIL_ID]
  1270. local content = Util.format(mailCfg.content, cityCfg and cityCfg.cityName or "", loseCityId)
  1271. MailManager.add(MailManager.SYSTEM, msg.playerUuid, mailCfg.title, content, nil, mailCfg.senderName or "GM")
  1272. -- 把最新的防守阵容数据推给客户端
  1273. if human.fd then
  1274. sendDefHeroArr(human)
  1275. end
  1276. end
  1277. -- 跨服通知可以更换据点的防守阵容数据
  1278. function C2N_Update_Point_Lineup(msg)
  1279. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1280. if not human then
  1281. local db = RoleDBLogic.getDb(msg.playerUuid)
  1282. if not db then
  1283. return
  1284. end
  1285. human = {}
  1286. human.db = db
  1287. end
  1288. local anotherWorlBattle = human.db.anotherWorlBattle
  1289. if not anotherWorlBattle or not anotherWorlBattle.formation then
  1290. return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_POINT)
  1291. end
  1292. local cityId = msg.targetCityId
  1293. local pointIdx = msg.targetPointIdx
  1294. if not anotherWorlBattle.formation[cityId] or not anotherWorlBattle.formation[cityId][pointIdx] then
  1295. return
  1296. end
  1297. local pointLinupData = anotherWorlBattle.formation[cityId][pointIdx]
  1298. pointLinupData.list = msg.heroList
  1299. pointLinupData.helpList = msg.helpList
  1300. pointLinupData.formation = msg.formation
  1301. if not human.fd then
  1302. ObjHuman.save(human)
  1303. end
  1304. sendDefHeroArr(human)
  1305. Broadcast.sendCenter(human, Lang.AB_UPDATE_LINEUP_SUCC)
  1306. end
  1307. -- 跨服通知放弃据点成功
  1308. function C2N_Leave_Point(msg)
  1309. local human = ObjHuman.onlineUuid[msg.playerUuid]
  1310. if not human then
  1311. local db = RoleDBLogic.getDb(msg.playerUuid)
  1312. if not db then
  1313. return
  1314. end
  1315. human = {}
  1316. human.db = db
  1317. end
  1318. local anotherWorlBattle = human.db.anotherWorlBattle
  1319. if not anotherWorlBattle or not anotherWorlBattle.formation then
  1320. return
  1321. end
  1322. local cityId = msg.targetCityId
  1323. local pointIdx = msg.targetPointIdx
  1324. anotherWorlBattle.formation[cityId][pointIdx] = nil
  1325. if not next(anotherWorlBattle.formation[cityId]) then
  1326. anotherWorlBattle.formation[cityId] = nil
  1327. end
  1328. -- 玩家不在线, 手动保存数据
  1329. if not human.fd then
  1330. ObjHuman.save(human) --后续可优化只更新 anotherWorlBattle 数据
  1331. else
  1332. -- 把最新的防守阵容数据推给客户端
  1333. sendDefHeroArr(human)
  1334. end
  1335. end
  1336. -- 跨服通知给玩家发奖
  1337. function C2N_IssueReward(msg)
  1338. -- 删除公会参加异界之战活动时间
  1339. UnionLogic.UpdateJoinAbTime(msg.unionOccupyInfo.unionId, nil)
  1340. resetDefData(msg.unionOccupyInfo.playerUuidArr)
  1341. -- 发奖
  1342. local awardObjArr, occupyCityInfo = genAwardObjArr(msg.unionOccupyInfo)
  1343. if awardObjArr then
  1344. local issueRewardQueue = createRewardQueue()
  1345. issueRewardQueue.extraInfo = occupyCityInfo
  1346. for _, obj in ipairs(awardObjArr) do
  1347. issueRewardQueue:add(obj)
  1348. end
  1349. issueRewardQueue:insertDB()
  1350. end
  1351. end
  1352. -------------------------------------------战斗---------------------------------
  1353. function getCombatMonsterOutID(human, side, args)
  1354. if side ~= CombatDefine.DEFEND_SIDE then return end
  1355. local cityId = args[2]
  1356. local cityCfg = AnotherWorldBattleConfig.city[cityId]
  1357. return cityCfg and cityCfg.pointMonsterId
  1358. end
  1359. function getCombatObjList(human, side, args, combatType, extraArgs)
  1360. if side == CombatDefine.ATTACK_SIDE and not human then return end
  1361. if side == CombatDefine.DEFEND_SIDE and human then
  1362. return
  1363. end
  1364. if not human then
  1365. local uuid = args[1]
  1366. local db = RoleDBLogic.getDb(uuid)
  1367. if not db then
  1368. return
  1369. end
  1370. human = {}
  1371. human.db = db
  1372. end
  1373. return CombatLogic.getHumanObjList(human, combatType, extraArgs)
  1374. end
  1375. function getCombatHeros(human, combatType, args)
  1376. if not human.db.anotherWorlBattle then
  1377. return
  1378. end
  1379. if not args then
  1380. return
  1381. end
  1382. local formation = human.db.anotherWorlBattle.formation
  1383. if not formation then
  1384. return
  1385. end
  1386. local cityId, pointIdx = args.cityId, args.pointIdx
  1387. if formation[cityId] and formation[cityId][pointIdx] then
  1388. local combatHeroDB = formation[cityId][pointIdx]
  1389. return combatHeroDB.list, combatHeroDB.helpList, combatHeroDB.formation or 1, combatHeroDB
  1390. end
  1391. end
  1392. function onFightBegin(human, cbParam, combatType, param)
  1393. if not human.AB_Battle_Cache or human.AB_Battle_Cache.isGather ~= 1 then
  1394. return
  1395. end
  1396. local gatherAttrs = AnotherWorldBattleConfig.var[1].gatherAttrs
  1397. for index = 1, CombatDefine.COMBAT_HERO_CNT do
  1398. local atkPos = CombatLogic.getPos(CombatDefine.ATTACK_SIDE, index)
  1399. local atkObj = CombatImpl.objList[atkPos]
  1400. if atkObj then
  1401. for _, atrrTb in ipairs(gatherAttrs) do
  1402. local attrId, attrVal = atrrTb[1], atrrTb[2]
  1403. atkObj.sysAttr[attrId] = (atkObj.sysAttr[attrId] or 0) + attrVal
  1404. end
  1405. atkObj.isSysAttrChange = true
  1406. end
  1407. end
  1408. end
  1409. function onFightEnd(human, result, type, cbParam, combatInfo)
  1410. -- if result == CombatDefine.RESULT_WIN then
  1411. -- challenge_Win(human, {cityId = human.AB_Battle_Cache.cityId, pointIdx = human.AB_Battle_Cache.pointIdx})
  1412. -- end
  1413. local args = {
  1414. cityId = human.AB_Battle_Cache.cityId,
  1415. pointIdx = human.AB_Battle_Cache.pointIdx,
  1416. challengeRes = result
  1417. }
  1418. human.AB_Battle_Cache = nil
  1419. challenge_End(human, args)
  1420. end