YjTreasureCombat.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. -- 遗迹探宝 战斗相关
  2. local Msg = require("core.Msg")
  3. local CombatDefine = require("combat.CombatDefine")
  4. local YjTreasureDBLogic = require("yjTreasure.YjTreasureDB")
  5. local YjTreasureLogic = require("yjTreasure.YjTreasureLogic")
  6. local CombatImpl = require("combat.CombatImpl")
  7. local BagLogic = require("bag.BagLogic")
  8. local CombatLogic = require("combat.CombatLogic")
  9. local YjTreasureExcel = require("excel.yjTreasure")
  10. local LiLianLogic = require("dailyTask.LiLianLogic")
  11. local CombatObj = require("combat.CombatObj")
  12. local Broadcast = require("broadcast.Broadcast")
  13. local Lang = require("common.Lang")
  14. local Util = require("common.Util")
  15. local RoleDefine = require("role.RoleDefine")
  16. local MonsterExcel = require("excel.monster")
  17. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  18. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  19. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  20. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  21. local Grid = require("bag.Grid")
  22. local HeroGrowUp = require("absAct.HeroGrowUp")
  23. local MengxinLogic = require("present.MengxinLogic")
  24. local Log = require("common.Log")
  25. local CommonDB = require("common.CommonDB")
  26. --能否上阵
  27. function checkUpdatePos(human)
  28. if not YjTreasureLogic.isOpen(human,true) then return end
  29. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  30. if roleData and roleData.objList then return end
  31. return true
  32. end
  33. --保存上阵
  34. function onUpdatePos(human)
  35. if not YjTreasureLogic.isOpen(human,true) then return end
  36. if not checkUpdatePos(human) then return end
  37. local objList, _, rolebase = CombatLogic.getHumanObjList(human, CombatDefine.COMBAT_TYPE10)
  38. if not objList or not rolebase then return end
  39. local yjTime = CommonDB.getYjTreasureEndTime()
  40. if not yjTime then
  41. YjTreasureDBLogic.initDB() --活动db初始化
  42. end
  43. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  44. if not roleData then
  45. YjTreasureDBLogic.addPlayer(objList,rolebase,human.db._id) --活动db增加玩家信息
  46. else
  47. YjTreasureDBLogic.YJ_Rank2Uuid[#YjTreasureDBLogic.YJ_Rank2Uuid + 1] = human.db._id
  48. roleData.time = os.time()
  49. roleData.objList = Util.copyTable(objList)
  50. roleData.rolebase = Util.copyTable(rolebase)
  51. local creatLayer = 1
  52. if roleData.layerMax then
  53. creatLayer = roleData.layerMax - YjTreasureExcel.define[1].backLayer
  54. if creatLayer <= 0 then
  55. creatLayer = 1
  56. end
  57. end
  58. YjTreasureDBLogic.creatLayerData(roleData,creatLayer)
  59. YjTreasureDBLogic.setFightHero(roleData.objList)
  60. YjTreasureDBLogic.updateUuid2Role(roleData)
  61. YjTreasureDBLogic.sortYJboard()
  62. end
  63. YjTreasureLogic.CG_YJTREASURE_QUERY(human)
  64. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1207)
  65. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1202)
  66. end
  67. --战斗 选择出战
  68. function CG_YJTREASURE_UPDATE_FIGHT(human,pos)
  69. if not YjTreasureLogic.isOpen(human, true) then return end
  70. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  71. if not roleData or not roleData.objList then return end
  72. if not YjTreasureDBLogic.setFightHero(roleData.objList,pos) then return Broadcast.sendErr(human, Lang.YJTREASURE_YAOJI_CURE_ERR2) end
  73. YjTreasureDBLogic.updateUuid2Role(roleData)
  74. local msgRet = Msg.gc.GC_YJTREASURE_UPDATE_FIGHT
  75. msgRet.pos = pos
  76. --Msg.trace(msgRet)
  77. Msg.send(msgRet,human.fd)
  78. end
  79. local function getMonsterFormation(human,gridIndex)
  80. local defCnf = YjTreasureExcel.define[1]
  81. local layerData = YjTreasureDBLogic.getLayerDataByUuid(human.db._id)
  82. local monstersData = YjTreasureExcel.layer[layerData.layer].monsters
  83. local bossData = YjTreasureExcel.layer[layerData.layer].boss
  84. local monsterOutID = nil
  85. if gridIndex == defCnf.bossGrid then
  86. monsterOutID = bossData
  87. else
  88. local monstersGrid = defCnf.monstersGrid
  89. for i=1,#monstersGrid do
  90. if monstersGrid[i] == gridIndex then
  91. monsterOutID = monstersData[i]
  92. end
  93. end
  94. end
  95. if not monsterOutID then return 1 end
  96. return MonsterExcel.monsterOut[monsterOutID].formation
  97. end
  98. -- 获取出战对象列表
  99. function getCombatObjList(human, side, gridIndex)
  100. if not YjTreasureLogic.isOpen(human, true) then return end
  101. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  102. if side == CombatDefine.ATTACK_SIDE then
  103. if not roleData.objList then
  104. return
  105. end
  106. local obj, pos = YjTreasureDBLogic.getFightHeroObj(roleData.objList)
  107. if not obj then return end
  108. local heroList = {[pos] = obj}
  109. local rolebase = CombatLogic.createRoleBaseByDB(human.db, obj.attrs[RoleDefine.ZHANDOULI])
  110. return heroList, nil, rolebase, 5
  111. elseif side == CombatDefine.DEFEND_SIDE then
  112. local gridData = YjTreasureDBLogic.getGridDataByIndex(human.db._id,gridIndex)
  113. if not gridData.monsterObjList then return end
  114. local monsterList = {}
  115. for pos, monsterObj in pairs(gridData.monsterObjList) do
  116. if YjTreasureDBLogic.getCombatObjHp(monsterObj) > 0 then
  117. monsterList[pos] = monsterObj
  118. end
  119. end
  120. local formation = getMonsterFormation(human,gridIndex)
  121. return monsterList, nil, gridData.monsterRBase, formation
  122. end
  123. end
  124. function fight(human,args)
  125. if not YjTreasureLogic.isOpen(human,true) then return end
  126. local gridIndex = tonumber(args[1])
  127. local gridsData = YjTreasureDBLogic.getGridsData(human.db._id)
  128. if not gridsData or not gridsData[gridIndex] then return end
  129. local gridData = gridsData[gridIndex]
  130. local defCnf = YjTreasureExcel.define[1]
  131. local bossGrid = defCnf.bossGrid
  132. if gridIndex == bossGrid then
  133. if gridData.gridType ~= YjTreasureLogic.YJ_TREASURE_GRID_BOSS then
  134. return
  135. end
  136. if not gridData.isOpen then
  137. return Broadcast.sendErr(human,Lang.YJTREASURE_BOSS_NOT_OPEN)
  138. end
  139. else
  140. if gridData.gridType ~= YjTreasureLogic.YJ_TREASURE_GRID_MONSTER then
  141. return
  142. end
  143. end
  144. local objList = YjTreasureDBLogic.getObjList(human.db._id)
  145. if not objList then return end
  146. if not YjTreasureDBLogic.getFightHeroObj(objList) then
  147. return Broadcast.sendErr(human, Lang.YJTREASURE_COMBAT_ERR_ALLDIE)
  148. end
  149. local layerData = YjTreasureDBLogic.getLayerDataByUuid(human.db._id)
  150. local layerConfig = YjTreasureExcel.layer[layerData.layer]
  151. if not layerConfig then return end
  152. local isQuick = human.db.combatQuick[CombatDefine.COMBAT_TYPE10]
  153. CombatLogic.combatBegin(human, layerConfig.mapID, gridIndex, CombatDefine.COMBAT_TYPE10, gridIndex, isQuick == 1)
  154. end
  155. -- 获取当前地图ID
  156. function getMapID(human, args)
  157. local layerData = YjTreasureDBLogic.getLayerDataByUuid(human.db._id)
  158. local layerConfig = YjTreasureExcel.layer[layerData.layer]
  159. if not layerConfig then return end
  160. return layerConfig.mapID
  161. end
  162. -- 附加属性
  163. local function addAttrs(obj, attrs)
  164. if not attrs then return end
  165. obj.isSysAttrChange = true
  166. for key, value in pairs(attrs) do
  167. obj.sysAttr[key] = obj.sysAttr[key] + value
  168. end
  169. end
  170. -- 战前添加属性
  171. function onFightBegin(human, param, combatType)
  172. if not YjTreasureLogic.isOpen(human) then return end
  173. local gridIndex = param.cbParam
  174. local changePos = param.changePos
  175. local buffData = YjTreasureDBLogic.getBuffData(human.db._id)
  176. local objList = YjTreasureDBLogic.getObjList(human.db._id)
  177. local gridData = YjTreasureDBLogic.getGridDataByIndex(human.db._id,gridIndex)
  178. --require("common.Util").printTable(gridData)
  179. local attrs = nil
  180. if buffData then
  181. for key, value in pairs(buffData) do
  182. attrs = attrs or {}
  183. attrs[key] = (attrs[key] or 0) + value
  184. end
  185. end
  186. for i = 1, CombatDefine.COMBAT_HERO_ALL_CNT do
  187. local data = CombatImpl.objList[i]
  188. if data then
  189. local pos = i
  190. if i <= 10 then
  191. pos = changePos
  192. end
  193. local index = CombatLogic.getIndexByPos(data.side, pos)
  194. local obj = nil
  195. if data.side == CombatDefine.ATTACK_SIDE then
  196. addAttrs(data, attrs)
  197. obj = objList[index]
  198. else
  199. obj = gridData.monsterObjList[index]
  200. end
  201. if obj and obj.hp then
  202. data.hp = obj.hp
  203. end
  204. end
  205. end
  206. end
  207. -- 刷新剩余血量
  208. function resetCombatHp(uuid,combatInfo,gridIndex)
  209. local isDie = nil
  210. local gridsData = YjTreasureDBLogic.getGridsData(uuid,gridIndex)
  211. local gridData = gridsData[gridIndex]
  212. local roleData = YjTreasureDBLogic.getRoleDataByUuid(uuid)
  213. local objList = roleData.objList
  214. for i = 1, CombatDefine.COMBAT_HERO_ALL_CNT do
  215. local data = combatInfo.objList[i]
  216. if data then
  217. if data.side == CombatDefine.ATTACK_SIDE and combatInfo.changePos then
  218. data.pos = combatInfo.changePos
  219. end
  220. local index = CombatLogic.getIndexByPos(data.side, data.pos)
  221. local obj = nil
  222. if data.side == CombatDefine.ATTACK_SIDE then
  223. obj = objList[index]
  224. if data.hp <= 0 then isDie = true end
  225. else
  226. obj = gridData.monsterObjList[index]
  227. end
  228. obj.hp = data.hp
  229. obj.hpMax = CombatObj.getHpMax(data)
  230. end
  231. end
  232. if isDie then
  233. YjTreasureDBLogic.setFightHero(objList)
  234. end
  235. roleData.layerData.grids = gridsData
  236. YjTreasureDBLogic.updateUuid2Role(roleData)
  237. end
  238. local function getkillOpenGrids(gridIndex)
  239. local defCnf = YjTreasureExcel.define[1]
  240. local openCnfIndex = nil
  241. for i=1,#defCnf.monstersGrid do
  242. if defCnf.monstersGrid[i] == gridIndex then
  243. openCnfIndex = i
  244. end
  245. end
  246. if not openCnfIndex then return end
  247. return defCnf.killOpenGrids[openCnfIndex],openCnfIndex
  248. end
  249. local function isKill(uuid,needkillIndex)
  250. local defCnf = YjTreasureExcel.define[1]
  251. local needKillGridIndex = defCnf.monstersGrid[needkillIndex]
  252. --print("needkillIndex,needKillGridIndex",needkillIndex,needKillGridIndex)
  253. if not needKillGridIndex then return end
  254. local gridData = YjTreasureDBLogic.getGridDataByIndex(uuid,needKillGridIndex)
  255. if not gridData then return end
  256. --print("gridData.gridType",gridData.gridType)
  257. if gridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_KONGDI then
  258. return true
  259. end
  260. end
  261. function getOpenGrids(uuid,gridIndex)
  262. local defCnf = YjTreasureExcel.define[1]
  263. local killOpenGrids,openCnfIndex = getkillOpenGrids(gridIndex)
  264. if not killOpenGrids then return end
  265. local chongdieOpen = {}
  266. local chongDieGridsCnf = defCnf.chongDieGrids[openCnfIndex]
  267. for i=1,#chongDieGridsCnf do
  268. local needKill = chongDieGridsCnf[i][1]
  269. local isKill = isKill(uuid,needKill)
  270. --print("needKill,isKill",needKill,isKill)
  271. for j=2,#chongDieGridsCnf[i] do
  272. local chongdie = chongDieGridsCnf[i][j]
  273. chongdieOpen[chongdie] = {}
  274. chongdieOpen[chongdie].canOpen = nil
  275. if isKill then
  276. chongdieOpen[chongdie].canOpen = true
  277. end
  278. end
  279. end
  280. local openGrids = {}
  281. for i=1,#killOpenGrids do
  282. local gridIndex = killOpenGrids[i]
  283. if chongdieOpen[gridIndex] then
  284. if chongdieOpen[gridIndex].canOpen then
  285. openGrids[#openGrids + 1] = gridIndex
  286. end
  287. else
  288. openGrids[#openGrids + 1] = gridIndex
  289. end
  290. end
  291. return openGrids
  292. end
  293. -- 战斗结束
  294. function killMonsterOpenGrids(human,gridIndex)
  295. local defCnf = YjTreasureExcel.define[1]
  296. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  297. local layerData = roleData.layerData
  298. if not layerData then return end
  299. local gridsData = layerData.grids
  300. if not gridsData then return end
  301. local gridData = gridsData[gridIndex]
  302. if not gridData then return end
  303. local buff = nil
  304. local itemTb = {}
  305. local msgRet = Msg.gc.GC_YJTREASURE_OPENGRIDS
  306. msgRet.list[0] = 0
  307. if gridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_BOSS then
  308. gridsData[gridIndex] = {}
  309. gridsData[gridIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_DOOR
  310. gridsData[gridIndex].isOpen = 1
  311. roleData.tansuo = (roleData.tansuo or 0) + 1
  312. elseif gridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_MONSTER then
  313. local openGrids = getOpenGrids(human.db._id,gridIndex)
  314. if not openGrids then return end
  315. gridsData[gridIndex] = {}
  316. gridsData[gridIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_KONGDI
  317. gridsData[gridIndex].isOpen = 1
  318. roleData.tansuo = (roleData.tansuo or 0) + #openGrids + 1 --算上怪物格子
  319. --BagLogic.cleanMomentItemList()
  320. for i=1,#openGrids do
  321. local openIndex = openGrids[i]
  322. local data = gridsData[openIndex]
  323. local change = nil
  324. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_ITEM then --道具
  325. local item = data.item
  326. if item then
  327. local itemID = item.itemID
  328. local itemCnt = item.itemCnt
  329. --BagLogic.updateMomentItem(2, itemID, itemCnt)
  330. layerData.getItems = layerData.getItems or {}
  331. layerData.getItems[itemID] = (layerData.getItems[itemID] or 0) + itemCnt
  332. itemTb[itemID] = (itemTb[itemID] or 0 ) + itemCnt
  333. end
  334. change = true
  335. end
  336. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_YJSHOPER then --遗迹商人
  337. roleData.yjShoperCnt = (roleData.yjShoperCnt or 0) + 1
  338. change = true
  339. end
  340. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_TREASURE_SHOP then --商店
  341. YjTreasureDBLogic.makeTreasureShop(human.db._id,openIndex)
  342. end
  343. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_BUFF then --buff
  344. change = true
  345. buff = YjTreasureDBLogic.makeBuff(human.db._id)
  346. local msg = Msg.gc.GC_YJTREASURE_BUFF_GET
  347. msg.buff.key = buff[1]
  348. msg.buff.value = buff[2]
  349. Msg.send(msg,human.fd)
  350. end
  351. gridsData[openIndex].isOpen = 1
  352. if change then
  353. msgRet.list[0] = msgRet.list[0] + 1
  354. local index = msgRet.list[0]
  355. YjTreasureLogic.makeYjGridNet(human,msgRet.list[index],openIndex,data)
  356. gridsData[openIndex] = {}
  357. gridsData[openIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_KONGDI
  358. gridsData[openIndex].isOpen = 1
  359. end
  360. end
  361. --BagLogic.addMomentItemList(human, "yj_treasure")
  362. local msg = Msg.gc.GC_YJTREASURE_GET_ITEM
  363. local msgLen = 0
  364. for itemID,itemCnt in pairs(itemTb) do
  365. BagLogic.addItem(human,itemID,itemCnt,"yj_treasure")
  366. msgLen = msgLen + 1
  367. Grid.makeItem(msg.item[msgLen],itemID,itemCnt)
  368. end
  369. msg.item[0] = msgLen
  370. Msg.send(msg,human.fd)
  371. --BagLogic.cleanMomentItemList()
  372. --四个守卫击败,方可挑战boss
  373. if not gridsData[defCnf.bossGrid].isOpen then
  374. local bossOpen = true
  375. for i=1,#defCnf.monstersGrid do
  376. local monsterGridData = gridsData[defCnf.monstersGrid[i]]
  377. if monsterGridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_MONSTER then
  378. bossOpen = nil
  379. end
  380. end
  381. if bossOpen then
  382. gridsData[defCnf.bossGrid].isOpen = 1
  383. end
  384. end
  385. end
  386. YjTreasureDBLogic.addItem(itemTb,human.db._id)
  387. roleData.killMonster = roleData.killMonster or {}
  388. roleData.killMonster.killCnt = (roleData.killMonster.killCnt or 0) + 1
  389. YjTreasureDBLogic.updateUuid2Role(roleData)
  390. if msgRet.list[0] > 0 then
  391. --Msg.trace(msgRet)
  392. Msg.send(msgRet,human.fd)
  393. end
  394. end
  395. -- 扫荡格子
  396. function sdMonsterOpenGrids(human,gridIndex,itemTb)
  397. local defCnf = YjTreasureExcel.define[1]
  398. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  399. local layerData = roleData.layerData
  400. if not layerData then return end
  401. local gridsData = layerData.grids
  402. if not gridsData then return end
  403. local gridData = gridsData[gridIndex]
  404. if not gridData then return end
  405. local buff = nil
  406. if gridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_BOSS then
  407. gridsData[gridIndex] = {}
  408. gridsData[gridIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_DOOR
  409. gridsData[gridIndex].isOpen = 1
  410. roleData.tansuo = (roleData.tansuo or 0) + 1
  411. elseif gridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_MONSTER then
  412. local openGrids = getOpenGrids(human.db._id,gridIndex)
  413. if not openGrids then return end
  414. gridsData[gridIndex] = {}
  415. gridsData[gridIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_KONGDI
  416. gridsData[gridIndex].isOpen = 1
  417. roleData.tansuo = (roleData.tansuo or 0) + #openGrids + 1 --算上怪物格子
  418. for i=1,#openGrids do
  419. local openIndex = openGrids[i]
  420. local data = gridsData[openIndex]
  421. local change = nil
  422. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_ITEM then --道具
  423. local item = data.item
  424. if item then
  425. local itemID = item.itemID
  426. local itemCnt = item.itemCnt
  427. layerData.getItems = layerData.getItems or {}
  428. layerData.getItems[itemID] = (layerData.getItems[itemID] or 0) + itemCnt
  429. itemTb[itemID] = (itemTb[itemID] or 0) + itemCnt
  430. end
  431. change = true
  432. end
  433. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_YJSHOPER then --遗迹商人
  434. roleData.yjShoperCnt = (roleData.yjShoperCnt or 0) + 1
  435. change = true
  436. end
  437. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_TREASURE_SHOP then --商店
  438. YjTreasureDBLogic.makeTreasureShop(human.db._id,openIndex)
  439. end
  440. if data.gridType == YjTreasureLogic.YJ_TREASURE_GRID_BUFF then --buff
  441. change = true
  442. buff = YjTreasureDBLogic.makeBuff(human.db._id)
  443. end
  444. gridsData[openIndex].isOpen = 1
  445. if change then
  446. gridsData[openIndex] = {}
  447. gridsData[openIndex].gridType = YjTreasureLogic.YJ_TREASURE_GRID_KONGDI
  448. gridsData[openIndex].isOpen = 1
  449. end
  450. end
  451. --四个守卫击败,方可挑战boss
  452. if not gridsData[defCnf.bossGrid].isOpen then
  453. local bossOpen = true
  454. for i=1,#defCnf.monstersGrid do
  455. local monsterGridData = gridsData[defCnf.monstersGrid[i]]
  456. if monsterGridData.gridType == YjTreasureLogic.YJ_TREASURE_GRID_MONSTER then
  457. bossOpen = nil
  458. end
  459. end
  460. if bossOpen then
  461. gridsData[defCnf.bossGrid].isOpen = 1
  462. end
  463. end
  464. end
  465. roleData.killMonster = roleData.killMonster or {}
  466. roleData.killMonster.killCnt = (roleData.killMonster.killCnt or 0) + 1
  467. YjTreasureDBLogic.updateUuid2Role(roleData)
  468. end
  469. function onFightEnd(human, result, type, gridIndex, combatInfo, param, isQuick)
  470. resetCombatHp(human.db._id,combatInfo,gridIndex) --刷新血量
  471. if CombatDefine.RESULT_WIN == result then -- 胜利处理
  472. killMonsterOpenGrids(human,gridIndex)
  473. LiLianLogic.onCallback(human,LiLianLogic.LILIAN_OUTID13,1)
  474. YjTreasureDBLogic.sortYJboard()
  475. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_19,1)
  476. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE20, 1)
  477. end
  478. YjTreasureLogic.CG_YJTREASURE_QUERY(human,1)
  479. end
  480. --扫荡
  481. function CG_YJTREASURE_SAODANG(human)
  482. local roleData = YjTreasureDBLogic.getRoleDataByUuid(human.db._id)
  483. if not roleData or not roleData.rolebase then return end
  484. local layerData = roleData.layerData
  485. if not layerData or not layerData.grids then return end
  486. local gridsData = layerData.grids
  487. local defCnf = YjTreasureExcel.define[1]
  488. local zhandouli = roleData.rolebase.zhandouli
  489. if zhandouli < defCnf.saodangNeed then
  490. local content = Util.format(Lang.YJTREASURE_SANGDAO_ZHANDOULI,defCnf.saodangNeed)
  491. return Broadcast.sendErr(human,content)
  492. end
  493. local dailyExtraSDTimes = YjTreasureLogic.YJ_GetTalismanAdd(human)
  494. local saodangMax = defCnf.saodangMax
  495. saodangMax = saodangMax + dailyExtraSDTimes
  496. local saodangNow = roleData.sangdang or 0
  497. if saodangNow >= saodangMax then
  498. return Broadcast.sendErr(human,Lang.YJTREASURE_SANGDAO_CNT_ERR)
  499. end
  500. local left = saodangMax - saodangNow
  501. local monstersGridCnf = defCnf.monstersGrid
  502. local bossGrid = defCnf.bossGrid
  503. local obj, pos = YjTreasureDBLogic.getFightHeroObj(roleData.objList)
  504. if not obj then
  505. local content = Util.format(Lang.YJTREASURE_SANGDAO_ZHANDOULI,defCnf.saodangNeed)
  506. return Broadcast.sendErr(human,content)
  507. end
  508. local heroZhandouli = obj.attrs[RoleDefine.ZHANDOULI]
  509. local kill = nil
  510. local up = nil
  511. local itemTb = {}
  512. for i=1,YjTreasureLogic.YJ_TREASURE_MONSTERS do
  513. if (roleData.sangdang or 0) >= saodangMax then
  514. break
  515. end
  516. local gridIndex = monstersGridCnf[i]
  517. if not gridIndex then
  518. gridIndex = bossGrid
  519. end
  520. local gridData = gridsData[gridIndex]
  521. local monsterObjList = gridData.monsterObjList
  522. if monsterObjList then
  523. local monsterZhandouli = gridData.monsterRBase.zhandouli
  524. for pos in pairs(monsterObjList) do
  525. if monsterObjList[pos] then
  526. if heroZhandouli > monsterZhandouli then
  527. monsterObjList[pos].hp = 0
  528. kill = true
  529. else
  530. kill = nil
  531. end
  532. end
  533. end
  534. if kill then
  535. sdMonsterOpenGrids(human,gridIndex,itemTb)
  536. LiLianLogic.onCallback(human,LiLianLogic.LILIAN_OUTID13,1)
  537. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE20, 1)
  538. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_19,1)
  539. roleData.sangdang = (roleData.sangdang or 0) + 1
  540. up = true
  541. end
  542. end
  543. end
  544. BagLogic.addItemList(human, itemTb, "yj_treasure")
  545. YjTreasureDBLogic.addItem(itemTb,human.db._id)
  546. if up then
  547. YjTreasureDBLogic.sortYJboard()
  548. YjTreasureDBLogic.updateUuid2Role(roleData)
  549. YjTreasureLogic.CG_YJTREASURE_QUERY(human,1)
  550. else
  551. Broadcast.sendErr(human,Lang.YJTREASURE_SANGDAO_ZHANDOULI_1)
  552. end
  553. end