lostTempleLogic.lua 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  1. --[[
  2. 失落神庙
  3. ]]
  4. local Msg = require("core.Msg")
  5. local LuaMongo = _G.lua_mongo
  6. local DB = require("common.DB")
  7. local LostTempleExcel = require("excel.lostTemple")
  8. local ElementExcel = require("excel.lostTemple").Element
  9. local CombatPosLogic = require("combat.CombatPosLogic")
  10. local CombatDefine = require("combat.CombatDefine")
  11. local MonsterOutExcel = require("excel.monster").monsterOut
  12. local HeroLogic = require("hero.HeroLogic")
  13. local MonsterExcel = require("excel.monster")
  14. local CombatLogic = require("combat.CombatLogic")
  15. local Grid = require("bag.Grid")
  16. local HeroGrid = require("hero.HeroGrid")
  17. local CombatPosExcel = require("excel.combatPos")
  18. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  19. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  20. local Util = require("common.Util")
  21. local LostTempleCombatLogic = require("lostTemple.lostTempleCombatLogic")
  22. local HeroDefine = require("hero.HeroDefine")
  23. local BagLogic = require("bag.BagLogic")
  24. local Broadcast = require("broadcast.Broadcast")
  25. local Lang = require("common.Lang")
  26. local CommonDB = require("common.CommonDB")
  27. local TriggerDefine = require("trigger.TriggerDefine")
  28. local TriggerLogic = require("trigger.TriggerLogic")
  29. local HeroGrowUp = require("absAct.HeroGrowUp")
  30. local YunYingLogic = require("yunying.YunYingLogic")
  31. local Timer = require("core.Timer")
  32. local Lost_Handle_Func = { }
  33. QUEUE_LEN = 3 -- 每次推送的横向队列数
  34. START_X = 1 -- 起始横向位置
  35. START_LAYER = 1 -- 起始层数
  36. OP_QUERY = 0
  37. OP_CONFIRM = 1
  38. INIT_HP_MAX = 100
  39. DAY_7s = 604800
  40. DAY_2s = 172800
  41. DAY_1s = 86400
  42. --跳过战斗需要的战力
  43. local SHOWQUICKPOWER = 0 --2000000
  44. local function resetDB(human)
  45. local query = { _id = human.db._id }
  46. LuaMongo.remove(DB.db_lost_temple, query)
  47. end
  48. function initAfterHot()
  49. end
  50. function getLeftTime()
  51. local openDay = CommonDB.getServerOpenDay()
  52. if not openDay then
  53. return 0
  54. end
  55. local curTime = os.time()
  56. local tNowDate = os.date("*t", curTime)
  57. tNowDate.hour = 0
  58. tNowDate.min = 0
  59. tNowDate.sec = 0
  60. -- if openDay % 2 == 1 then
  61. -- tNowDate.day = tNowDate.day + 2
  62. -- else
  63. -- tNowDate.day = tNowDate.day + 1
  64. -- end
  65. tNowDate.day = tNowDate.day + 1
  66. local nEndTime = os.time(tNowDate)
  67. return nEndTime - curTime
  68. end
  69. --
  70. local function isOpen(human)
  71. --[[
  72. local openDay = CommonDB.getServerOpenDay()
  73. if not openDay then
  74. return
  75. end
  76. if openDay < 7 then
  77. return
  78. end
  79. ---- 已经开启
  80. if (openDay - 7 + 1) % 2 ~= 1 then
  81. return
  82. end
  83. ]]
  84. if not RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1208) then
  85. return
  86. end
  87. return true
  88. end
  89. function onZero()
  90. local openDay = CommonDB.getServerOpenDay()
  91. if not openDay then
  92. return
  93. end
  94. -- print("[lostTempleLogic - onZero] 失落神庙零点刷新开始 openDay = "..openDay)
  95. -- -- 奇数天刷新
  96. -- if openDay % 2 == 1 then
  97. -- print("[lostTempleLogic - onZero] 失落神庙零点, 当前为奇数天移除DB数据\n")
  98. -- LuaMongo.remove(DB.db_lost_temple)
  99. -- end
  100. -- 修改: 每日刷新
  101. -- LuaMongo.remove(DB.db_lost_temple)
  102. -- 修改: 延迟60s再清除数据
  103. -- Timer.addLater(60, LuaMongo.remove, DB.db_lost_temple)
  104. -- 已经关闭
  105. -- if (openDay - 7 + 1) % 2 ~= 0 then
  106. -- return
  107. -- end
  108. end
  109. function updateDaily(human)
  110. if not isOpen(human) then
  111. return
  112. end
  113. resetDB(human)
  114. print("[lostTempleLogic - updateDaily] 天数刷新 玩家移除lostTemple数据 name = "..human.db.name)
  115. human.lostTemple = nil
  116. local msgRet = Msg.gc.GC_LOST_TEMPLE_CLOSE
  117. Msg.send(msgRet, human.fd)
  118. end
  119. -- db
  120. local QueryByUuid = { _id = nil }
  121. -- 插入新的数据
  122. function dbRead(human)
  123. if not isOpen(human) then return end
  124. human.lostTemple = { }
  125. QueryByUuid._id = human.db._id
  126. LuaMongo.find(DB.db_lost_temple, QueryByUuid)
  127. if not LuaMongo.next(human.lostTemple) then
  128. human.lostTemple = nil
  129. end
  130. end
  131. --
  132. local DB_DATA = { }
  133. function dbSave(human)
  134. if not human.lostTemple then return end
  135. if not human.db then return end
  136. DB_DATA = { }
  137. LuaMongo.find(DB.db_lost_temple, QueryByUuid)
  138. -- if not LuaMongo.next(DB_DATA) then
  139. -- human.lostTemple._id = human.db._id
  140. -- LuaMongo.insert(DB.db_lost_temple, human.lostTemple)
  141. -- return
  142. -- end
  143. if not LuaMongo.next(DB_DATA) then
  144. -- 检查 human.db._id 是否已经存在
  145. local exists = false
  146. local tempQuery = { _id = human.db._id }
  147. LuaMongo.find(DB.db_lost_temple, tempQuery)
  148. if LuaMongo.next(DB_DATA) then
  149. exists = true
  150. end
  151. if exists then
  152. -- 如果存在,更新文档
  153. LuaMongo.update(DB.db_lost_temple, tempQuery, human.lostTemple)
  154. else
  155. -- 如果不存在,插入新文档
  156. human.lostTemple._id = human.db._id
  157. LuaMongo.insert(DB.db_lost_temple, human.lostTemple)
  158. end
  159. return
  160. end
  161. QueryByUuid._id = human.db._id
  162. LuaMongo.update(DB.db_lost_temple, QueryByUuid, human.lostTemple)
  163. end
  164. -- db
  165. function onLogin(human)
  166. if not isOpen(human) then return end
  167. dbRead(human)
  168. end
  169. -- 初始化玩家当前格子
  170. local function printGrid(human)
  171. if not human.lostTemple then return end
  172. local startX = human.lostTemple.x + 1
  173. local endX = human.lostTemple.x + QUEUE_LEN
  174. local layer = human.lostTemple.layer
  175. local random = human.lostTemple.random
  176. local LostTempleConfig = LostTempleExcel[layer]
  177. if not LostTempleConfig then return end
  178. local LostTemple = LostTempleConfig[random]
  179. if not LostTemple then return end
  180. print("layler=", human.lostTemple.layer, "random=", human.lostTemple.random, "playerX=", human.lostTemple.x, "playerY=", human.lostTemple.y)
  181. for x = startX, endX do
  182. human.lostTemple.grid[x] = human.lostTemple.grid[x] or { }
  183. local LostTempleX = LostTemple[x]
  184. if LostTempleX then
  185. for y = 1, LostTemple.vertical do
  186. if LostTempleX[y] then
  187. print("x=", x, "y=", y, "id=", human.lostTemple.grid[x][y].id)
  188. end
  189. end
  190. end
  191. end
  192. return true
  193. end
  194. --
  195. local function makeMonsterGrid(human, cmd)
  196. if not human.lostTemple then return end
  197. local x = human.lostTemple.x
  198. local layer = human.lostTemple.layer
  199. local LostTempleMonster = LostTempleExcel.Lost[x]
  200. if not LostTempleMonster then return end
  201. -- 取共鸣英雄的等级
  202. local totalLv = 0
  203. local equally = 0
  204. local equallyLv = 0
  205. local db = human.db.xingYaoGongMing
  206. if db and db.defList then
  207. for heroIndex in pairs(db.defList) do
  208. local heroGrid = human.db.heroBag[heroIndex]
  209. if heroGrid then
  210. totalLv = totalLv + heroGrid.lv
  211. equally = equally + 1
  212. end
  213. end
  214. end
  215. local randomId = 0
  216. if cmd == "nomalMonster" then
  217. randomId = math.random(LostTempleMonster.nomal[layer][1], LostTempleMonster.nomal[layer][2])
  218. elseif cmd == "eliteMonster" then
  219. randomId = math.random(LostTempleMonster.elite[layer][1], LostTempleMonster.elite[layer][2])
  220. elseif cmd == "eliteBoss" then
  221. randomId = math.random(LostTempleMonster.elite[layer][1], LostTempleMonster.elite[layer][2])
  222. end
  223. equallyLv = math.ceil(totalLv / equally * randomId / 10000)
  224. local monsterOutID = 0
  225. for i = 1, #LostTempleExcel.Monster do
  226. if equallyLv >= LostTempleExcel.Monster[i].lvminmax[1] and equallyLv <= LostTempleExcel.Monster[i].lvminmax[2] then
  227. local randomIndex = math.random(1, #LostTempleExcel.Monster[i].monsteroutid)
  228. monsterOutID = LostTempleExcel.Monster[i].monsteroutid[randomIndex]
  229. break
  230. end
  231. end
  232. if monsterOutID == 0 then
  233. assert(nil, "monsterOutID is error equallyLv=" .. equallyLv .. "-randomId=" .. randomId)
  234. end
  235. return monsterOutID
  236. end
  237. -- 制造一个召唤祭坛
  238. local function makeSummonHeroGrid(human)
  239. -- 取共鸣英雄的等级
  240. local totalLv = 0
  241. local equally = 0
  242. local equallyLv = 0
  243. local db = human.db.xingYaoGongMing
  244. if db and db.defList then
  245. for heroIndex in pairs(db.defList) do
  246. local heroGrid = human.db.heroBag[heroIndex]
  247. if heroGrid then
  248. totalLv = totalLv + heroGrid.lv
  249. equally = equally + 1
  250. end
  251. end
  252. end
  253. equallyLv = math.ceil(totalLv / equally)
  254. local heroIndex = nil
  255. for i = 1, #LostTempleExcel.Hero do
  256. if equallyLv >= LostTempleExcel.Hero[i].lvminmax[1] and equallyLv <= LostTempleExcel.Hero[i].lvminmax[2] then
  257. heroIndex = i
  258. break
  259. end
  260. end
  261. if heroIndex == nil then
  262. assert(nil, "heroid is error equallyLv=" .. equallyLv)
  263. end
  264. --
  265. local summonHero = { }
  266. local weightHeroTb = Util.copyTable(LostTempleExcel.Hero[heroIndex].heroid)
  267. -- 根据权重取出4英雄
  268. local totalWeight = 0
  269. for i = 1, #weightHeroTb do
  270. totalWeight = totalWeight + weightHeroTb[i][4]
  271. end
  272. -- 取4次
  273. local len = 0
  274. for k = 1, 4 do
  275. local random = math.random(1, totalWeight)
  276. for i = 1, #weightHeroTb do
  277. if random <= weightHeroTb[i][4] then
  278. len = len + 1
  279. summonHero[len] = { }
  280. summonHero[len].id = weightHeroTb[i][1]
  281. summonHero[len].lv = weightHeroTb[i][2]
  282. local maxStar = HeroDefine.getMaxHeroStar(weightHeroTb[i][1])
  283. summonHero[len].star = maxStar > weightHeroTb[i][3] and weightHeroTb[i][3] or maxStar
  284. -- 最后一个放入到 这一个里面 删掉最后一个
  285. totalWeight = totalWeight - weightHeroTb[i][4]
  286. weightHeroTb[i] = weightHeroTb[#weightHeroTb]
  287. weightHeroTb[#weightHeroTb] = nil
  288. break
  289. end
  290. random = random - weightHeroTb[i][4]
  291. end
  292. end
  293. if #summonHero == 0 then
  294. assert(nil, "summonHero is error equallyLv=" .. equallyLv)
  295. end
  296. return summonHero
  297. end
  298. -- 制造一个智慧树
  299. local function makeSummonTreeGrid(human)
  300. --
  301. local summonTree = { }
  302. local weightTreeTb = Util.copyTable(LostTempleExcel.Tree)
  303. -- 根据权重取出4英雄
  304. local totalWeight = 0
  305. for i = 1, #weightTreeTb do
  306. totalWeight = totalWeight + weightTreeTb[i].weight
  307. end
  308. -- 取3次
  309. local len = 0
  310. for k = 1, 3 do
  311. local random = math.random(1, totalWeight)
  312. for i = 1, #weightTreeTb do
  313. if random <= weightTreeTb[i].weight then
  314. len = len + 1
  315. summonTree[len] = i
  316. -- 最后一个放入到 这一个里面 删掉最后一个
  317. totalWeight = totalWeight - weightTreeTb[i].weight
  318. weightTreeTb[i] = weightTreeTb[#weightTreeTb]
  319. weightTreeTb[#weightTreeTb] = nil
  320. break
  321. end
  322. random = random - weightTreeTb[i].weight
  323. end
  324. end
  325. if #summonTree == 0 then
  326. assert(nil, "summonTree is error")
  327. end
  328. return summonTree
  329. end
  330. -- 神界商店
  331. local function makeSummonShopGrid(human)
  332. --
  333. local summonShop = { }
  334. local weightShopTb = Util.copyTable(LostTempleExcel.LostShop)
  335. -- 根据权重取出4英雄
  336. local totalWeight = 0
  337. for i = 1, #weightShopTb do
  338. totalWeight = totalWeight + weightShopTb[i].weight
  339. end
  340. -- 取3次
  341. local len = 0
  342. for k = 1, 4 do
  343. local random = math.random(1, totalWeight)
  344. for i = 1, #weightShopTb do
  345. if random <= weightShopTb[i].weight then
  346. len = len + 1
  347. summonShop[len] = i
  348. -- 最后一个放入到 这一个里面 删掉最后一个
  349. totalWeight = totalWeight - weightShopTb[i].weight
  350. weightShopTb[i] = weightShopTb[#weightShopTb]
  351. weightShopTb[#weightShopTb] = nil
  352. break
  353. end
  354. random = random - weightShopTb[i].weight
  355. end
  356. end
  357. if #summonShop == 0 then
  358. assert(nil, "summonShop is error")
  359. end
  360. return summonShop
  361. end
  362. -- 制造一个宝箱
  363. local function makeBoxGrid(human)
  364. for i = 1, #ElementExcel do
  365. local element = ElementExcel[i]
  366. if element.cmd == "summonBox" then
  367. return i
  368. end
  369. end
  370. end
  371. -- 制造一个传送门
  372. local function makeConverDoorGrid(human)
  373. for i = 1, #ElementExcel do
  374. local element = ElementExcel[i]
  375. if element.cmd == "conveyDoor" then
  376. return i
  377. end
  378. end
  379. end
  380. -- 初始化玩家当前格子
  381. local function makeGrid(human)
  382. if not human.lostTemple then return end
  383. local layer = human.lostTemple.layer
  384. local random = human.lostTemple.random
  385. local LostTempleConfig = LostTempleExcel[layer]
  386. if not LostTempleConfig then return end
  387. local LostTemple = LostTempleConfig[random]
  388. if not LostTemple then return end
  389. -- 清除玩家当前位置的数据
  390. human.lostTemple.grid = human.lostTemple.grid or { }
  391. human.lostTemple.grid[human.lostTemple.x] = nil
  392. local startX = human.lostTemple.x + 1
  393. local endX = human.lostTemple.x + QUEUE_LEN
  394. for x = startX, endX do
  395. local LostTempleX = LostTemple[x]
  396. if LostTempleX then
  397. human.lostTemple.grid[x] = human.lostTemple.grid[x] or { }
  398. for y = 1, LostTemple.vertical do
  399. if LostTempleX[y] then
  400. if not human.lostTemple.grid[x][y] then
  401. human.lostTemple.grid[x][y] = { id = LostTempleX[y][1] }
  402. end
  403. local element = ElementExcel[LostTempleX[y][1]]
  404. -- 召唤神坛
  405. if element.cmd == "summonHero" then
  406. human.lostTemple.grid[x][y].summonHero = makeSummonHeroGrid(human)
  407. end
  408. -- 智慧树
  409. if element.cmd == "summonTree" then
  410. human.lostTemple.grid[x][y].summonTree = makeSummonTreeGrid(human)
  411. end
  412. -- 神界商店
  413. if element.cmd == "summonShop" then
  414. human.lostTemple.grid[x][y].summonShop = makeSummonShopGrid(human)
  415. end
  416. --只生成 第一层的怪物
  417. if x == startX then
  418. if element.cmd == "nomalMonster" or element.cmd == "eliteMonster" or element.cmd == "eliteBoss" then
  419. human.lostTemple.grid[x][y].monsterOutID = makeMonsterGrid(human, element.cmd)
  420. end
  421. end
  422. end
  423. end
  424. end
  425. end
  426. return true
  427. end
  428. -- 制造一个默认的位置数据
  429. local function makeLostTempLe(layer)
  430. -- 第一层
  431. local LostTempleConfig = LostTempleExcel[layer]
  432. if not LostTempleConfig then
  433. assert(nil, "lostTemple startLayer error = " .. layer)
  434. end
  435. -- 随机一张地图
  436. local startRandom = math.random(1, #LostTempleConfig)
  437. local LostTemple = LostTempleConfig[startRandom]
  438. if not LostTemple then return end
  439. -- 起始位置
  440. local LostTempleX = LostTemple[START_X]
  441. if not LostTempleX then
  442. assert(nil, "lostTemple startX error = " .. START_LAYER)
  443. end
  444. -- 找到纵向可以站立的位置
  445. local startY = 1
  446. for y = 1, LostTemple.vertical do
  447. if LostTempleX[y] and LostTempleX[y][1] == 0 then
  448. startY = y
  449. break
  450. end
  451. end
  452. return layer, START_X, startY, startRandom
  453. end
  454. -- 初始化
  455. local function initDB(human)
  456. if human.lostTemple then return end
  457. local lostLayer, lostX, lostY, lostRandom = makeLostTempLe(START_LAYER)
  458. if not lostLayer then return end
  459. human.lostTemple = { layer = lostLayer, x = lostX, y = lostY, random = lostRandom, box = nil, grid = nil }
  460. makeGrid(human)
  461. dbSave(human)
  462. end
  463. -- 重置之后的Y值
  464. local function getStartYVal(mapIdx)
  465. local LostTempleConfig = LostTempleExcel[START_LAYER]
  466. if not LostTempleConfig then
  467. return -1
  468. end
  469. local LostTemple = LostTempleConfig[mapIdx]
  470. if not LostTemple then
  471. return -1
  472. end
  473. local LostTempleX = LostTemple[START_X]
  474. if not LostTempleX then
  475. return -1
  476. end
  477. local startY = -1
  478. for y = 1, LostTemple.vertical do
  479. if LostTempleX[y] and LostTempleX[y][1] == 0 then
  480. startY = y
  481. break
  482. end
  483. end
  484. return startY
  485. end
  486. -- 是否已经挑战过
  487. local function isChallenge(human)
  488. if not human.lostTemple then
  489. return false
  490. end
  491. -- 层数判断
  492. local layer = human.lostTemple.layer or 0
  493. if layer > 1 then
  494. return true
  495. end
  496. -- X 值判断
  497. local start_X_Val = human.lostTemple.x or 0
  498. if start_X_Val ~= START_X then
  499. return true
  500. end
  501. local y_Val = human.lostTemple.y or 0
  502. local mapIdx = human.lostTemple.random or 0
  503. local start_Y_Val = getStartYVal(mapIdx)
  504. if start_Y_Val == -1 then
  505. assert(false, "失落神庙数据异常")
  506. end
  507. -- Y 值判断
  508. if y_Val ~= start_Y_Val then
  509. return true
  510. end
  511. return false
  512. end
  513. -- human = { }
  514. -- initDB(human)
  515. -- printGrid(human)
  516. -- print("-----------------------------")
  517. -- 下一格
  518. function nextGrid(human, y)
  519. if not human.lostTemple then return end
  520. local layer = human.lostTemple.layer
  521. local LostTempleConfig = LostTempleExcel[layer]
  522. if not LostTempleConfig then
  523. assert(nil, "lostTemple startLayer error = " .. layer)
  524. end
  525. local random = human.lostTemple.random
  526. local LostTemple = LostTempleConfig[random]
  527. if not LostTemple then return end
  528. local x = human.lostTemple.x + 1
  529. local LostTempleX = LostTemple[x]
  530. if not LostTempleX then return end
  531. local LostTempleY = LostTempleX[y]
  532. if not LostTempleY then return end
  533. human.lostTemple.x = x
  534. human.lostTemple.y = y
  535. makeGrid(human)
  536. end
  537. -- 下一层
  538. local function nextDB(human)
  539. if not human.lostTemple then return end
  540. local nextLayer = human.lostTemple.layer + 1
  541. local LostTempleConfig = LostTempleExcel[nextLayer]
  542. if not LostTempleConfig then return end
  543. local lostLayer, lostX, lostY, lostRandom = makeLostTempLe(nextLayer)
  544. if not lostLayer then return end
  545. -- TriggerLogic.PublishEvent(TriggerDefine.LOSTTEMPLE_PASS_LAYER, human.db._id, 1)
  546. human.lostTemple.layer = lostLayer
  547. human.lostTemple.x = lostX
  548. human.lostTemple.y = lostY
  549. human.lostTemple.random = lostRandom
  550. human.lostTemple.grid = nil
  551. makeGrid(human)
  552. end
  553. --
  554. local function makeGridNet(human, net)
  555. if not human.lostTemple then return end
  556. local startX = human.lostTemple.x + 1
  557. local endX = human.lostTemple.x + QUEUE_LEN
  558. local layer = human.lostTemple.layer
  559. local random = human.lostTemple.random
  560. local LostTempleConfig = LostTempleExcel[layer]
  561. if not LostTempleConfig then return end
  562. local LostTemple = LostTempleConfig[random]
  563. if not LostTemple then return end
  564. net[0] = 0
  565. local len = 0
  566. for x = startX, endX do
  567. if human.lostTemple.grid[x] then
  568. for y = 1, LostTemple.vertical do
  569. if human.lostTemple.grid[x][y] then
  570. len = len + 1
  571. local grid = human.lostTemple.grid[x][y]
  572. local element = ElementExcel[grid.id]
  573. if not element then
  574. assert(nil, "lostTemple element error = " .. grid.id)
  575. end
  576. net[len].id = grid.id
  577. net[len].name = element.name
  578. net[len].type = element.type
  579. net[len].desc = element.desc
  580. net[len].x = x
  581. net[len].y = y
  582. net[len].body = 0
  583. if grid.monsterOutID then
  584. if not MonsterOutExcel[grid.monsterOutID] then
  585. assert(nil, "lostTemple monsterOutID error = " .. grid.monsterOutID)
  586. end
  587. local monsterConfig = MonsterExcel.monster[MonsterOutExcel[grid.monsterOutID].member[1][1]]
  588. if not monsterConfig then
  589. assert(nil, "lostTemple monsterOutID error = " .. MonsterOutExcel[grid.monsterOutID].member[1][1])
  590. end
  591. net[len].body = monsterConfig.body
  592. end
  593. end
  594. end
  595. end
  596. end
  597. net[0] = len
  598. return true
  599. end
  600. --通关
  601. function IsPass(human)
  602. -- initDB(human)
  603. if not human.lostTemple then return false end
  604. if human.lostTemple.oneClickSweep then
  605. return true
  606. end
  607. local startX = human.lostTemple.x + 1
  608. local endX = human.lostTemple.x + QUEUE_LEN
  609. local layer = human.lostTemple.layer
  610. local random = human.lostTemple.random
  611. local LostTempleConfig = LostTempleExcel[layer]
  612. if not LostTempleConfig then return end
  613. local LostTemple = LostTempleConfig[random]
  614. if not LostTemple then return end
  615. local type = 0
  616. local len = 0
  617. for x = startX, endX do
  618. if human.lostTemple.grid[x] then
  619. for y = 1, LostTemple.vertical do
  620. if human.lostTemple.grid[x][y] then
  621. len = len + 1
  622. local grid = human.lostTemple.grid[x][y]
  623. local element = ElementExcel[grid.id]
  624. if not element then
  625. return false
  626. end
  627. type = element.type
  628. end
  629. end
  630. end
  631. end
  632. if len == 1 and type == 6 and layer >= 3 then
  633. return true
  634. end
  635. return false
  636. end
  637. -- 查询
  638. function query(human)
  639. if not isOpen(human) then
  640. return
  641. end
  642. -- 没有共鸣
  643. local db = human.db.xingYaoGongMing
  644. if not db or not db.defList then
  645. return
  646. end
  647. initDB(human)
  648. local leftTime = getLeftTime()
  649. local msgRet = Msg.gc.GC_LOST_TEMPLE_QUERY
  650. msgRet.leftTime = leftTime
  651. if not makeGridNet(human, msgRet.list) then return end
  652. msgRet.playerX = human.lostTemple.x
  653. msgRet.playerY = human.lostTemple.y
  654. msgRet.layer = human.lostTemple.layer
  655. msgRet.leftTime = leftTime
  656. Msg.send(msgRet, human.fd)
  657. sendHeroStatus(human)
  658. end
  659. -- 更新
  660. function update(human)
  661. if not human.lostTemple then
  662. return
  663. end
  664. local msgRet = Msg.gc.GC_LOST_TEMPLE_UPDATE
  665. if not makeGridNet(human, msgRet.list) then
  666. return
  667. end
  668. local leftTime = getLeftTime()
  669. msgRet.leftTime = leftTime
  670. msgRet.playerX = human.lostTemple.x
  671. msgRet.playerY = human.lostTemple.y
  672. msgRet.layer = human.lostTemple.layer
  673. Msg.send(msgRet, human.fd)
  674. end
  675. -- 检测点击格子是否合法
  676. function checkPutByY(human, y)
  677. local startX = human.lostTemple.x + 1
  678. if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
  679. local grid = human.lostTemple.grid[startX][y]
  680. -- 检测点击位置是否合法
  681. return grid
  682. end
  683. -- 检测点击格子是否合法
  684. function checkPut(human, x, y)
  685. local startX = x
  686. if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
  687. local grid = human.lostTemple.grid[startX][y]
  688. local nNowX = human.lostTemple.x
  689. local nNowY = human.lostTemple.y
  690. if nNowX + 1 ~= x then
  691. print("[checkPut] x ="..x.." nNowX="..nNowX.." y="..y.." nNowY="..nNowY)
  692. return
  693. end
  694. -- 检测点击位置是否合法
  695. return grid
  696. end
  697. -- 设置格子
  698. function putSet(human, y, cmd)
  699. local startX = human.lostTemple.x + 1
  700. if not human.lostTemple.grid or not human.lostTemple.grid[startX] or not human.lostTemple.grid[startX][y] then return end
  701. if cmd == "eliteBoss" then
  702. human.lostTemple.grid[startX][y] = { id = makeBoxGrid(human) }
  703. return true
  704. end
  705. if cmd == "summonBox" then
  706. human.lostTemple.grid[startX][y] = { id = makeConverDoorGrid(human) }
  707. return true
  708. end
  709. end
  710. -- 走到下一步
  711. function put(human, op, x, y, arg)
  712. if not isOpen(human) then return end
  713. if not human.lostTemple then return end
  714. if op ~= OP_QUERY and op ~= OP_CONFIRM then return end
  715. local grid = checkPut(human, x, y)
  716. if not grid then return end
  717. local elementConfig = ElementExcel[grid.id]
  718. if not elementConfig then return end
  719. local ret = nil
  720. if Lost_Handle_Func[elementConfig.cmd] then
  721. ret = Lost_Handle_Func[elementConfig.cmd](human, op, y, grid, arg, elementConfig)
  722. end
  723. if ret then
  724. nextGrid(human, y)
  725. dbSave(human)
  726. update(human)
  727. end
  728. end
  729. -- 怪物面板
  730. local function monsterQuery(human, grid, elementConfig)
  731. if not human.lostTemple then return end
  732. if not grid.monsterOutID then return end
  733. local rewardConfig = LostTempleExcel.Drop[elementConfig.arg[1]]
  734. if not rewardConfig then return end
  735. local msgRet = Msg.gc.GC_LOST_TEMPLE_MONSTER
  736. msgRet.gdReward[0] = 0
  737. for _, item in ipairs(rewardConfig.drop) do
  738. msgRet.gdReward[0] = msgRet.gdReward[0] + 1
  739. Grid.makeItem(msgRet.gdReward[msgRet.gdReward[0]], item[1], item[2])
  740. end
  741. msgRet.randomReward[0] = 0
  742. for _, item in ipairs(rewardConfig.randomdrop) do
  743. if type(item) == "table" then
  744. msgRet.randomReward[0] = msgRet.randomReward[0] + 1
  745. Grid.makeItem(msgRet.randomReward[msgRet.randomReward[0]], item[1], item[2])
  746. end
  747. end
  748. local monsterOutConfig = MonsterOutExcel[grid.monsterOutID]
  749. if not monsterOutConfig then return end
  750. local formation = monsterOutConfig.formation
  751. formation = formation == 0 and 1 or formation
  752. local mationConfig = CombatPosExcel.formation[formation]
  753. local posList = mationConfig.pos
  754. if not posList then return end
  755. msgRet.list[0] = 0
  756. for i, member in ipairs(monsterOutConfig.member) do
  757. local monsterID = member[1]
  758. local monsterConfig = MonsterExcel.monster[monsterID]
  759. if posList[i] then
  760. local defPos = CombatLogic.getPos(CombatDefine.DEFEND_SIDE, posList[i])
  761. local monsterLv = member[2]
  762. local obj = grid.objStatus and grid.objStatus[defPos] or nil
  763. local hpRate = obj and obj.hpRate or 1
  764. local hp = math.ceil(INIT_HP_MAX * hpRate)
  765. local hpMax = INIT_HP_MAX
  766. local others = HeroGrid.createOthers(monsterLv, hp, hpMax, monsterConfig.star)
  767. msgRet.list[0] = msgRet.list[0] + 1
  768. HeroGrid.makeHeroSimpleByMonsterID(msgRet.list[msgRet.list[0]], monsterID, others)
  769. end
  770. end
  771. msgRet.showNext = 0
  772. if human.db.zhandouli >= SHOWQUICKPOWER then
  773. msgRet.showNext = 1
  774. end
  775. msgRet.quick = 0
  776. if human.db.combatQuick[CombatDefine.COMBAT_TYPE24] == 1 then
  777. msgRet.quick = 1
  778. end
  779. Msg.send(msgRet, human.fd)
  780. end
  781. -- 英雄列表
  782. function sendHeroStatus(human)
  783. if not human.lostTemple then return end
  784. local msgRet = Msg.gc.GC_LOST_TEMPLE_HERO_STATUS
  785. msgRet.list[0] = 0
  786. msgRet.isEnd = 0
  787. local len = 0
  788. if human.lostTemple.heroStatus then
  789. for k, hpRate in pairs(human.lostTemple.heroStatus) do
  790. local hp = math.ceil(INIT_HP_MAX * hpRate)
  791. local hpMax = INIT_HP_MAX
  792. len = len + 1
  793. local net = msgRet.list[len]
  794. net.hp = hp
  795. net.hpMax = hpMax
  796. net.uuid = k
  797. if len >= 30 then
  798. msgRet.isEnd = 0
  799. msgRet.list[0] = len
  800. Msg.send(msgRet, human.fd)
  801. len = 0
  802. end
  803. end
  804. end
  805. msgRet.isEnd = 1
  806. msgRet.list[0] = len
  807. Msg.send(msgRet, human.fd)
  808. end
  809. -- 推送召唤祭坛英雄列表
  810. function sendSummonHeroList(human)
  811. if not human.lostTemple then return end
  812. if not human.lostTemple.summonHero then return end
  813. local msgRet = Msg.gc.GC_LOST_TEMPLE_SUMMON_LIST
  814. msgRet.list[0] = 0
  815. for index = 1, human.lostTemple.summonHero[0] do
  816. msgRet.list[0] = msgRet.list[0] + 1
  817. HeroGrid.makeHeroSimple(msgRet.list[msgRet.list[0]], human.lostTemple.summonHero[index], index)
  818. end
  819. Msg.send(msgRet, human.fd)
  820. end
  821. -- 推送buff属性
  822. function sendSummonTreeList(human)
  823. if not human.lostTemple then return end
  824. if not human.lostTemple.summonTree then return end
  825. local msgRet = Msg.gc.GC_LOST_TEMPLE_BUFF_LIST
  826. msgRet.list[0] = 0
  827. for k, v in pairs(human.lostTemple.summonTree) do
  828. msgRet.list[0] = msgRet.list[0] + 1
  829. local net = msgRet.list[msgRet.list[0]]
  830. net.attr.key = k
  831. net.attr.value = v
  832. net.name = ""
  833. for i = 1, #LostTempleExcel.Tree do
  834. if LostTempleExcel.Tree[i].icon == k then
  835. net.name = LostTempleExcel.Tree[i].buffname
  836. break
  837. end
  838. end
  839. end
  840. Msg.send(msgRet, human.fd)
  841. end
  842. -- 随机奖励宝箱
  843. function sendRandomBox(human)
  844. if not human.lostTemple then return end
  845. local msgRet = Msg.gc.GC_LOGT_TEMPLE_RANDOM_BOX
  846. local len = 0
  847. if human.lostTemple.randomReward then
  848. for k, v in pairs(human.lostTemple.randomReward) do
  849. len = len + 1
  850. Grid.makeItem(msgRet.randomReward[len], k, v)
  851. end
  852. end
  853. msgRet.randomReward[0] = len
  854. Msg.send(msgRet, human.fd)
  855. end
  856. --
  857. function Lost_Handle_Func.nomalMonster(human, op, y, grid, arg, elementConfig)
  858. if op == OP_QUERY then
  859. monsterQuery(human, grid, elementConfig)
  860. end
  861. end
  862. --
  863. function Lost_Handle_Func.eliteMonster(human, op, y, grid, arg, elementConfig)
  864. if op == OP_QUERY then
  865. monsterQuery(human, grid, elementConfig)
  866. end
  867. end
  868. --
  869. function Lost_Handle_Func.eliteBoss(human, op, y, grid, arg, elementConfig)
  870. if op == OP_QUERY then
  871. monsterQuery(human, grid, elementConfig)
  872. end
  873. end
  874. --
  875. function Lost_Handle_Func.summonHero(human, op, y, grid, arg, elementConfig)
  876. -- 召唤神坛查询
  877. if op == OP_QUERY then
  878. if not grid.summonHero then return end
  879. local msgRet = Msg.gc.GC_LOST_TEMPLE_SUMMON
  880. msgRet.list[0] = 0
  881. for i = 1, #grid.summonHero do
  882. local hero = grid.summonHero[i]
  883. msgRet.list[0] = msgRet.list[0] + 1
  884. local others = HeroGrid.createOthers(hero.lv, INIT_HP_MAX, INIT_HP_MAX, hero.star)
  885. HeroGrid.makeHeroSimpleByID(msgRet.list[msgRet.list[0]], hero.id, i, others)
  886. end
  887. Msg.send(msgRet, human.fd)
  888. return
  889. end
  890. -- 添加召唤英雄
  891. if op == OP_CONFIRM then
  892. local index = tonumber(arg)
  893. if not grid.summonHero then return end
  894. local hero = grid.summonHero[index]
  895. if not hero then return end
  896. local heroGrid = HeroGrid.createHeroGrid(hero.id, hero.star)
  897. if not heroGrid then return end
  898. heroGrid.isLostTemple = 1
  899. -- 初始化属性
  900. local attrConfig = HeroDefine.getAttrConfig(hero.id, heroGrid.star)
  901. if not attrConfig then return end
  902. local quality = HeroGrid.getMaxQualityByLv(heroGrid.star, hero.lv)
  903. local maxLv = HeroGrid.getMaxLv(heroGrid.star, quality)
  904. heroGrid.lv = math.min(maxLv, hero.lv or 0)
  905. heroGrid.quality = math.max(heroGrid.quality, quality or 0)
  906. -- 加入装备
  907. -- 加入到英雄队列
  908. human.lostTemple.summonHero = human.lostTemple.summonHero or { }
  909. human.lostTemple.summonHero[0] = human.lostTemple.summonHero[0] or 0
  910. human.lostTemple.summonHero[0] = human.lostTemple.summonHero[0] + 1
  911. local addIndex = human.lostTemple.summonHero[0]
  912. human.lostTemple.summonHero[addIndex] = heroGrid
  913. heroGrid.bagIndex = addIndex
  914. -- 计算属性
  915. LostTempleCombatLogic.getHeroAttrs(human, addIndex)
  916. -- 通知客户端
  917. sendSummonHeroList(human)
  918. return true
  919. end
  920. end
  921. -- 智慧树
  922. function Lost_Handle_Func.summonTree(human, op, y, grid, arg, elementConfig)
  923. -- 召唤神坛查询
  924. if op == OP_QUERY then
  925. if not grid.summonTree then return end
  926. local msgRet = Msg.gc.GC_LOST_TEMPLE_BUFF
  927. msgRet.list[0] = 0
  928. for i = 1, #grid.summonTree do
  929. local hero = grid.summonTree[i]
  930. msgRet.list[0] = msgRet.list[0] + 1
  931. local config = LostTempleExcel.Tree[grid.summonTree[i]]
  932. local net = msgRet.list[msgRet.list[0]]
  933. net.id = i
  934. net.icon = config.icon
  935. net.name = config.buffname
  936. net.attr[0] = #config.Buffid
  937. for i = 1, #config.Buffid do
  938. net.attr[i].key = config.Buffid[i][1]
  939. net.attr[i].value = config.Buffid[i][2]
  940. end
  941. end
  942. Msg.send(msgRet, human.fd)
  943. return
  944. end
  945. -- 添加召唤英雄
  946. if op == OP_CONFIRM then
  947. local index = tonumber(arg)
  948. if not grid.summonTree then return end
  949. local buffID = grid.summonTree[index]
  950. if not buffID then return end
  951. local config = LostTempleExcel.Tree[buffID]
  952. if not config then return end
  953. human.lostTemple.summonTree = human.lostTemple.summonTree or { }
  954. for i = 1, #config.Buffid do
  955. local key = config.Buffid[i][1]
  956. local value = config.Buffid[i][2]
  957. human.lostTemple.summonTree[key] = human.lostTemple.summonTree[key] or 0
  958. human.lostTemple.summonTree[key] = human.lostTemple.summonTree[key] + value
  959. end
  960. sendSummonTreeList(human)
  961. return true
  962. end
  963. end
  964. -- 炽天使
  965. function Lost_Handle_Func.treatRevive(human, op, y, grid, arg, elementConfig)
  966. if op == OP_QUERY then
  967. return
  968. end
  969. -- 复活治疗
  970. if op == OP_CONFIRM then
  971. local opType = tonumber(arg)
  972. local heroStatus = human.lostTemple.heroStatus
  973. if not heroStatus then return true end
  974. -- 复活
  975. if opType == 1 then
  976. local len = 0
  977. local cnt = 0
  978. local revice = {}
  979. local hpList = {}
  980. for k, hpRate in pairs(heroStatus) do
  981. if hpRate <= 0.0 then
  982. len = len + 1
  983. revice[len]=k
  984. else
  985. if hpRate < 1.0 then
  986. cnt = cnt + 1
  987. hpList[cnt] = k
  988. end
  989. end
  990. end
  991. if #revice > 0 then
  992. local random = math.random(1, #revice)
  993. heroStatus[revice[random]] = nil
  994. elseif #hpList > 0 then
  995. local random = math.random(1, #hpList)
  996. heroStatus[hpList[random]] = nil
  997. end
  998. end
  999. -- 治疗
  1000. if opType == 2 then
  1001. for k, hpRate in pairs(heroStatus) do
  1002. if heroStatus[k] > 0.0 then
  1003. heroStatus[k] = hpRate + 0.5
  1004. if heroStatus[k] >= 1.0 then
  1005. heroStatus[k] = nil
  1006. end
  1007. end
  1008. end
  1009. end
  1010. sendHeroStatus(human)
  1011. return true
  1012. end
  1013. end
  1014. -- 神界商店
  1015. function Lost_Handle_Func.summonShop(human, op, y, grid, arg, elementConfig)
  1016. if op == OP_QUERY then
  1017. if not grid.summonShop then return end
  1018. local msgRet = Msg.gc.GC_LOST_TEMPLE_SHOP
  1019. msgRet.list[0] = 0
  1020. for i = 1, #grid.summonShop do
  1021. msgRet.list[0] = msgRet.list[0] + 1
  1022. local config = LostTempleExcel.LostShop[grid.summonShop[i]]
  1023. local net = msgRet.list[msgRet.list[0]]
  1024. Grid.makeItem(net.item, config.itemid, config.itemnum)
  1025. Grid.makeItem(net.needItem, config.spenditem, config.spendnum)
  1026. net.discount = config.discount
  1027. net.id = i
  1028. end
  1029. Msg.send(msgRet, human.fd)
  1030. return
  1031. end
  1032. -- 购买东西
  1033. if op == OP_CONFIRM then
  1034. local index = tonumber(arg)
  1035. if not grid.summonShop then return end
  1036. local shopID = grid.summonShop[index]
  1037. if not shopID then return end
  1038. local config = LostTempleExcel.LostShop[shopID]
  1039. if not config then return end
  1040. if not BagLogic.checkItemCnt(human, config.spenditem, config.spendnum) then
  1041. return
  1042. end
  1043. BagLogic.delItem(human, config.spenditem, config.spendnum, "lostTemple")
  1044. BagLogic.addItem(human, config.itemid, config.itemnum, "lostTemple")
  1045. return true
  1046. end
  1047. end
  1048. -- -- 宝箱
  1049. function Lost_Handle_Func.summonBox(human, op, y, grid, arg, elementConfig)
  1050. if op == OP_QUERY then
  1051. sendRandomBox(human)
  1052. return
  1053. end
  1054. --
  1055. if op == OP_CONFIRM then
  1056. if human.lostTemple.randomReward then
  1057. local item = { }
  1058. local len = 0
  1059. for k, v in pairs(human.lostTemple.randomReward) do
  1060. len = len + 1
  1061. item[len] = { k, v }
  1062. end
  1063. BagLogic.addItemList(human, item, "lostTemple")
  1064. human.lostTemple.randomReward = nil
  1065. TriggerLogic.PublishEvent(TriggerDefine.LOSTTEMPLE_PASS_LAYER, human.db._id, 1)
  1066. end
  1067. -- 判定有没有下一程
  1068. local nextLayer = human.lostTemple.layer + 1
  1069. local LostTempleConfig = LostTempleExcel[nextLayer]
  1070. if LostTempleConfig then
  1071. -- 变成传送门
  1072. putSet(human, y, elementConfig.cmd)
  1073. end
  1074. dbSave(human)
  1075. update(human)
  1076. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1208)
  1077. end
  1078. end
  1079. -- 传送门
  1080. function Lost_Handle_Func.conveyDoor(human, op, y, grid, arg, elementConfig)
  1081. if op == OP_QUERY then
  1082. return
  1083. end
  1084. -- 进入下一层
  1085. if op == OP_CONFIRM then
  1086. nextDB(human)
  1087. dbSave(human)
  1088. update(human)
  1089. end
  1090. end
  1091. function lostTempleRevice(human)
  1092. if not human.lostTemple then return end
  1093. human.lostTemple.heroStatus = nil
  1094. sendHeroStatus(human)
  1095. end
  1096. -- 查询一键扫荡状态
  1097. function LostTemple_OneClickSweep_Query(human)
  1098. if not isOpen(human) then
  1099. return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
  1100. end
  1101. local msgRet = Msg.gc.GC_LOGT_TEMPLE_ONECLICK_SWEEP_QUERY
  1102. msgRet.state = 0
  1103. if human.lostTemple and human.lostTemple.oneClickSweep then
  1104. msgRet.state = 2
  1105. else
  1106. local isBuyKing = HeroGrowUp.isBuyKing(human)
  1107. if isBuyKing and isBuyKing == 1 then
  1108. msgRet.state = 1
  1109. end
  1110. end
  1111. Msg.send(msgRet, human.fd)
  1112. end
  1113. -- 查询一键扫荡奖励
  1114. function LostTemple_OneClickSweep_Award(human)
  1115. if not isOpen(human) then
  1116. return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
  1117. end
  1118. local msgRet = Msg.gc.GC_LOGT_TEMPLE_ONECLICK_SWEEP_AWARD
  1119. msgRet.awardArr[0] = 0
  1120. local awardCfg = LostTempleExcel.Saodang[1].reward
  1121. msgRet.awardArr[0] = #awardCfg
  1122. for idx, itemTb in ipairs(awardCfg) do
  1123. Grid.makeItem(msgRet.awardArr[idx], itemTb[1], itemTb[2])
  1124. end
  1125. Msg.send(msgRet, human.fd)
  1126. end
  1127. -- 进行一键扫荡
  1128. function LostTemple_OneClickSweep_Do(human)
  1129. if not isOpen(human) then
  1130. return Broadcast.sendErr(human, Lang.COMMOM_NOT_ENABLED)
  1131. end
  1132. local isBuyKing = HeroGrowUp.isBuyKing(human)
  1133. if not isBuyKing or isBuyKing ~= 1 then
  1134. return Broadcast.sendErr(human, Lang.LOST_NO_BUY)
  1135. end
  1136. local lostTempleData = human.lostTemple
  1137. if lostTempleData and lostTempleData.oneClickSweep then
  1138. return Broadcast.sendErr(human, Lang.LOST_HAS_ONECLICKSWEEP)
  1139. end
  1140. if isChallenge(human) then
  1141. return Broadcast.sendErr(human, Lang.LOST_HAS_CHALLENGE)
  1142. end
  1143. -- 更新数据
  1144. --human.lostTemple = { layer = lostLayer, x = lostX, y = lostY, random = lostRandom, box = nil, grid = nil }
  1145. initDB(human)
  1146. -- lostTempleData = human.lostTemple
  1147. -- lostTempleData.layer = 3
  1148. -- lostTempleData.x = 10
  1149. -- lostTempleData.y = 4
  1150. for i=1, 2 do
  1151. nextDB(human)
  1152. end
  1153. human.lostTemple.oneClickSweep = true
  1154. dbSave(human)
  1155. update(human)
  1156. local awardArr = {}
  1157. local awardCfg = LostTempleExcel.Saodang[1].reward
  1158. for idx, itemTb in ipairs(awardCfg) do
  1159. awardArr[idx] = {itemTb[1], itemTb[2]}
  1160. end
  1161. BagLogic.addItemList(human, awardArr, "lostTemple")
  1162. YunYingLogic.onCallBack(human, "lostTempleCombat", 1)
  1163. LostTemple_OneClickSweep_Query(human)
  1164. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1208)
  1165. end