CopyLogic.lua 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. local Lang = require("common.Lang")
  2. local Msg = require("core.Msg")
  3. local ObjHuman = require("core.ObjHuman")
  4. local Util = require("common.Util")
  5. local CopyExcel = require("excel.copy")
  6. local Grid = require("bag.Grid")
  7. local RoleDefine = require("role.RoleDefine")
  8. local BagLogic = require("bag.BagLogic")
  9. local CombatDefine = require("combat.CombatDefine")
  10. local CombatLogic = require("combat.CombatLogic")
  11. local DailyTaskLogic = require("dailyTask.DailyTaskLogic")
  12. local ItemDefine = require("bag.ItemDefine")
  13. local Broadcast = require("broadcast.Broadcast")
  14. local Log = require("common.Log")
  15. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  16. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  17. local VipLogic = require("vip.VipLogic")
  18. local CombatPosLogic = require("combat.CombatPosLogic")
  19. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  20. local DragonNestLogic = require("copy.DragonNestLogic")
  21. local MengxinLogic = require("present.MengxinLogic")
  22. local YunYingLogic = require("yunying.YunYingLogic")
  23. local TalismanLogic = require("talisman.TalismanLogic")
  24. -- local RoleStorageBox = require("roleSystem.RoleStorageBox")
  25. COPY_TYPE_JINBI = 1 --金币挑战
  26. COPY_TYPE_EXP = 2 --经验挑战
  27. COPY_TYPE_SUIPIAN = 3 --英雄挑战
  28. COPY_TYPE_MOSHENG = 4 --魔神挑战
  29. COPY_TYPE_FUWEN = 5 --符文挑战
  30. COPY_TYPE_MAX = 5
  31. COPY_SAODANG_CAN = 1 --可扫荡
  32. local SAODANG_COND_LEVEL = 80 -- 女巫副本一键扫荡需要达到的等级
  33. --获取秘宝方面的加成
  34. local function getTalismanAdd(human)
  35. local jinbiAdd = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.NW_JB) or 0) / 100
  36. local heroExpAdd = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.NW_HERO_EXP) or 0) / 100
  37. local longhunshiAdd = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.NW_LHS) or 0) / 100
  38. local fuwenJinghuaAdd = (TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.NW_FWJH) or 0) / 100
  39. return jinbiAdd, heroExpAdd, longhunshiAdd, fuwenJinghuaAdd
  40. end
  41. --获取秘宝方面的加成
  42. local function getTalismanChallengeleAdd(human)
  43. local challengeAdd = TalismanLogic.getTalismanAdd(human, TalismanLogic.OTHER_EFFECT_TBL.NW_CHALLENGE_TIMES) or 0
  44. return challengeAdd
  45. end
  46. function updateDaily(human)
  47. DragonNestLogic.updateDaily(human)
  48. if not human.db.copy then return end
  49. for i = COPY_TYPE_JINBI , COPY_TYPE_MAX do
  50. if human.db.copy[i] then
  51. human.db.copy[i].cnt = 0
  52. human.db.copy[i].buyCnt = 0
  53. end
  54. end
  55. end
  56. -- 挑战查询
  57. function isOpenByType(human,copyType,noSend)
  58. local copyConfig = CopyExcel.richang[copyType]
  59. if not copyConfig then return end
  60. if human.db.lv < copyConfig.lv then
  61. return
  62. end
  63. return true
  64. end
  65. function getMinZDLByType(copyType)
  66. for _,config in ipairs(CopyExcel.copy ) do
  67. if config.type == copyType then
  68. return config.zhandouliNeed
  69. end
  70. end
  71. return 0
  72. end
  73. local function isDotByType(human,copyType)
  74. if not isOpenByType(human, copyType, true) then
  75. return
  76. end
  77. local copyConfig = CopyExcel.copy[copyType]
  78. local zhandouli = CombatPosLogic.getCombatHeroZDL(human, CombatDefine.COMBAT_TYPE1)
  79. local minZDL = getMinZDLByType(copyType)
  80. if zhandouli < minZDL then
  81. return
  82. end
  83. local leftCnt = getLeftCnt(human, copyType)
  84. if leftCnt > 0 then
  85. return true
  86. end
  87. end
  88. local function getMaxID(human, copyType)
  89. local copyDB = human.db.copy
  90. if not copyDB then return 0 end
  91. return copyDB[copyType] and copyDB[copyType].maxID or 0
  92. end
  93. local function canSaoDang(human,copyType, id)
  94. return getMaxID(human, copyType) >= id and COPY_SAODANG_CAN or 0
  95. end
  96. -- 根据副本类型和等级获取copyID
  97. local TYPE_2_COPYLIST = nil
  98. local function getCopyIDByLv(copyType, level)
  99. if not TYPE_2_COPYLIST then
  100. TYPE_2_COPYLIST = {}
  101. for copyID, config in pairs(CopyExcel.copy) do
  102. if not TYPE_2_COPYLIST[config.type] then
  103. TYPE_2_COPYLIST[config.type] = {}
  104. end
  105. TYPE_2_COPYLIST[config.type][config.level] = copyID
  106. end
  107. end
  108. if not TYPE_2_COPYLIST[copyType] then
  109. return
  110. end
  111. return TYPE_2_COPYLIST[copyType][level]
  112. end
  113. function challengeQuery(human, copyType)
  114. local config = CopyExcel.richang[copyType]
  115. if not config then return end
  116. ObjHuman.updateDaily(human)
  117. local msgRet = Msg.gc.GC_COPY_CHALLENGE_QUERY
  118. msgRet.copyType = copyType
  119. msgRet.leftCnt = getLeftCnt(human, copyType)
  120. msgRet.maxCnt = getCurMaxCnt(human, copyType)
  121. msgRet.vipBuy = getCanBuyCnt(human, copyType)
  122. msgRet.vipNeed = config.zuanshi
  123. msgRet.vipBuyUpLv = VipLogic.getUpPowerNeedLv(human, VipLogic.VIP_POWER13) or 0
  124. msgRet.redList[0] = #CopyExcel.richang
  125. msgRet.copyList[0] = #CopyExcel.richang
  126. for i=1,#CopyExcel.richang do
  127. msgRet.redList[i] = isDotByType(human,i) and 1 or 0
  128. msgRet.copyList[i] = CopyExcel.richang[i].lv
  129. end
  130. local now = os.time()
  131. local ts1 = Util.getDayStartTime(now)
  132. msgRet.nextRefreshTime = 24 * 60 * 60 - (now - ts1)
  133. --秘宝加成
  134. local jinbiAdd, heroExpAdd, longhunshiAdd, fuwenJinghuaAdd = getTalismanAdd(human)
  135. local j = 0 -- 存储相同副本类型的数量
  136. for i=1, #CopyExcel.copy do
  137. local copyConfig = CopyExcel.copy[i]
  138. if copyConfig and copyType == copyConfig.type then
  139. j = j + 1
  140. msgRet.list[j].id = i
  141. msgRet.list[j].level = copyConfig.level
  142. msgRet.list[j].lvNeed = copyConfig.lvNeed
  143. msgRet.list[j].zhandouliNeed = copyConfig.zhandouliNeed
  144. msgRet.list[j].reward[0] = #copyConfig.reward
  145. msgRet.list[j].saodang = canSaoDang(human,copyType,i) or 0
  146. for key,value in ipairs (copyConfig.reward) do
  147. local itemID = value[1]
  148. local itemCnt = value[2]
  149. if itemID == ItemDefine.ITEM_JINBI_ID and jinbiAdd > 0 then
  150. itemCnt = itemCnt + math.ceil(itemCnt * jinbiAdd)
  151. elseif itemID == ItemDefine.ITEM_GREEN_EXP_ID and heroExpAdd > 0 then
  152. itemCnt = itemCnt + math.ceil(itemCnt * heroExpAdd)
  153. elseif itemID == ItemDefine.ITEM_LONGHUNSHI_ID and longhunshiAdd > 0 then
  154. itemCnt = itemCnt + math.ceil(itemCnt * longhunshiAdd)
  155. elseif itemID == ItemDefine.ITEM_FUWEN_JINGHUA and fuwenJinghuaAdd > 0 then
  156. itemCnt = itemCnt + math.ceil(itemCnt * fuwenJinghuaAdd)
  157. end
  158. Grid.makeItem(msgRet.list[j].reward[key], itemID, itemCnt)
  159. end
  160. end
  161. end
  162. msgRet.list[0] = j
  163. Msg.send(msgRet, human.fd)
  164. --Msg.trace(msgRet)
  165. end
  166. -- 挑战
  167. function fight(human, args)
  168. local isok, id, copyConfig = checkCombatPos(human, args)
  169. if not isok then return end
  170. -- 调用战斗接口
  171. CombatLogic.combatBegin(human, copyConfig.mapID, args, CombatDefine.COMBAT_TYPE7, id)
  172. end
  173. -- 获取当前地图ID
  174. function getMapID(human, args)
  175. local isok, id, copyConfig = checkCombatPos(human, args)
  176. if not isok then return end
  177. return copyConfig.mapID
  178. end
  179. function doFightEnd(human,copyID,combatInfo, touch)
  180. local copyConfig = CopyExcel.copy[copyID]
  181. if not copyConfig then return end
  182. ObjHuman.updateDaily(human)
  183. local copyType = copyConfig.type
  184. touch = tonumber(touch or 0)
  185. -- 金币挑战
  186. if copyType == COPY_TYPE_JINBI then
  187. --Log.write(Log.LOGID_OSS_BATTLE_GOLD, human.db._id, human.db.account, human.db.name, human.db.lv)
  188. Log.write(Log.LOGID_OSS_BATTLE_GOLD, human.db._id, human.db.newUniqueTag, human.db.name, human.db.lv)
  189. end
  190. -- 经验挑战
  191. if copyType == COPY_TYPE_EXP then
  192. --Log.write(Log.LOGID_OSS_BATTLE_EXP, human.db._id, human.db.account, human.db.name, human.db.lv)
  193. Log.write(Log.LOGID_OSS_BATTLE_EXP, human.db._id, human.db.newUniqueTag, human.db.name, human.db.lv)
  194. end
  195. -- 碎片挑战
  196. if copyType == COPY_TYPE_SUIPIAN then
  197. --Log.write(Log.LOGID_OSS_BATTLE_HERO, human.db._id, human.db.account, human.db.name, human.db.lv)
  198. Log.write(Log.LOGID_OSS_BATTLE_HERO, human.db._id, human.db.newUniqueTag, human.db.name, human.db.lv)
  199. end
  200. local leftCnt = getLeftCnt(human, copyType)
  201. local canBuy = getCanBuyCnt(human, copyType)
  202. local fightCnt = touch == 0 and 1 or leftCnt
  203. -- 改db
  204. human.db.copy = human.db.copy or {}
  205. human.db.copy[copyType] = human.db.copy[copyType] or {}
  206. local cnt = human.db.copy[copyType].cnt or 0
  207. human.db.copy[copyType].cnt = cnt + fightCnt
  208. local maxCopy = human.db.copy[copyType].maxID or 0
  209. if copyID > maxCopy then
  210. human.db.copy[copyType].maxID = copyID --实现成功挑战一次可扫荡逻辑
  211. end
  212. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1206)
  213. --秘宝加成
  214. local jinbiAdd, heroExpAdd, longhunshiAdd, fuwenJinghuaAdd = getTalismanAdd(human)
  215. -- 给奖励
  216. local rewardRate = double and 2 or 1
  217. local itemList = {}
  218. for i = 1, #copyConfig.reward do
  219. local itemID = copyConfig.reward[i][1]
  220. local itemCnt = copyConfig.reward[i][2]
  221. local finalCnt = itemCnt * rewardRate * fightCnt
  222. if itemID == ItemDefine.ITEM_JINBI_ID and jinbiAdd > 0 then
  223. finalCnt = finalCnt + math.ceil(finalCnt * jinbiAdd)
  224. elseif itemID == ItemDefine.ITEM_GREEN_EXP_ID and heroExpAdd > 0 then
  225. finalCnt = finalCnt + math.ceil(finalCnt * heroExpAdd)
  226. elseif itemID == ItemDefine.ITEM_LONGHUNSHI_ID and longhunshiAdd > 0 then
  227. finalCnt = finalCnt + math.ceil(finalCnt * longhunshiAdd)
  228. elseif itemID == ItemDefine.ITEM_FUWEN_JINGHUA and fuwenJinghuaAdd > 0 then
  229. finalCnt = finalCnt + math.ceil(finalCnt * fuwenJinghuaAdd)
  230. end
  231. -- local sourceId = 0
  232. -- finalCnt, sourceId = RoleStorageBox.GetFinalItemCnt(human, itemID, finalCnt, "copy_win")
  233. BagLogic.addItem(human, itemID, finalCnt, "copy_win")
  234. local index = #itemList+1
  235. itemList[index] = {}
  236. itemList[index][1] = itemID
  237. itemList[index][2] = finalCnt
  238. -- itemList[index][4] = sourceId
  239. if combatInfo and combatInfo.rewardItem then --为nil时是扫荡调用这个方法
  240. for j = 1, rewardRate do
  241. local nowTotalCnt = #combatInfo.rewardItem
  242. combatInfo.rewardItem[nowTotalCnt + 1] = {}
  243. combatInfo.rewardItem[nowTotalCnt + 1][1] = itemID
  244. if itemID == ItemDefine.ITEM_JINBI_ID or itemID == ItemDefine.ITEM_GREEN_EXP_ID
  245. or itemID == ItemDefine.ITEM_LONGHUNSHI_ID or itemID == ItemDefine.ITEM_FUWEN_JINGHUA then
  246. combatInfo.rewardItem[nowTotalCnt + 1][2] = finalCnt
  247. else
  248. combatInfo.rewardItem[nowTotalCnt + 1][2] = itemCnt * rewardRate * fightCnt
  249. end
  250. combatInfo.rewardItem[nowTotalCnt + 1][4] = sourceId
  251. end
  252. combatInfo.double = double and 2 or 0
  253. end
  254. end
  255. DailyTaskLogic.recordDailyTaskFinishCnt(human, DailyTaskLogic.DAILY_TASK_ID_10, fightCnt)
  256. MengxinLogic.onCallBack(human,MengxinLogic.MX_TASK_TYPE_9,1)
  257. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1206)
  258. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1201)
  259. YunYingLogic.onCallBack(human, "onCopyFight", fightCnt)
  260. YunYingLogic.onCallBack(human, "onCopyChallenge",fightCnt)
  261. return itemList
  262. end
  263. -- 挑战结束
  264. function onFightEnd(human, result, combatType, copyID, combatInfo)
  265. local copyConfig = CopyExcel.copy[copyID]
  266. if not copyConfig then return end
  267. -- todo 太难打了,先改成必定打赢,晚点改回去
  268. if CombatDefine.RESULT_WIN == result then
  269. doFightEnd(human,copyID,combatInfo)
  270. end
  271. local copyTypeConfig = CopyExcel.richang[copyConfig.type]
  272. if copyTypeConfig then
  273. combatInfo.defender.name = copyTypeConfig.name
  274. combatInfo.panelID = copyTypeConfig.panelID
  275. end
  276. YunYingLogic.onCallBack(human, "onCopyChallenge",1)
  277. end
  278. -- 查询购买次数
  279. function buyChallengeQuery(human, copyType)
  280. do return end
  281. --[[
  282. local vipLv = VipLogic.getVipLv(human)
  283. if vipLv < 1 then
  284. return Broadcast.sendErr(human, Lang.COPY_BUY_CNT_ERR_VIP)
  285. end
  286. -- 次数判断
  287. local leftBuyCnt = getMaxBuyCnt(human) - getCurBuyCnt(human, copyType)
  288. if leftBuyCnt < 1 then
  289. return Broadcast.sendErr(human, Lang.COPY_BUY_CNT_ERR_CNT)
  290. end
  291. local msgRet = Msg.gc.GC_COPY_BUY_CHALLENGE_QUERY
  292. msgRet.copyType = copyType
  293. msgRet.needItemID = ItemDefine.ITEM_ZUANSHI_ID
  294. msgRet.needItemCnt = CopyExcel.richangDefine[1].zuanshi
  295. msgRet.curBuyCnt = getCurBuyCnt(human, copyType)
  296. msgRet.maxBuyCnt = getMaxBuyCnt(human)
  297. Msg.send(msgRet, human.fd)
  298. ]]
  299. end
  300. -- 购买挑战次数
  301. function buyChallengeCnt(human, copyType, buyCnt)
  302. do return end
  303. --[[
  304. if buyCnt < 1 then return end
  305. ObjHuman.updateDaily(human)
  306. -- 条件判断
  307. local maxBuyCnt = getMaxBuyCnt(human)
  308. local curBuyCnt = getCurBuyCnt(human, copyType)
  309. -- 最大购买次数判断
  310. if maxBuyCnt - curBuyCnt < buyCnt then
  311. return Broadcast.sendErr(human, Lang.COPY_BUY_CNT_ERR_CNT)
  312. end
  313. -- 钻石判断
  314. local needZuanshi = buyCnt * CopyExcel.richangDefine[1].zuanshi
  315. if not ObjHuman.checkRMB(human, needZuanshi) then
  316. return
  317. end
  318. local oldRed = isDotByType(human,copyType)
  319. -- 扣钻石
  320. ObjHuman.decZuanshi(human, -needZuanshi, "buy_challenge_cnt")
  321. -- 改db
  322. human.db.copy = human.db.copy or {}
  323. human.db.copy[copyType] = human.db.copy[copyType] or {}
  324. human.db.copy[copyType].buyCnt = curBuyCnt + buyCnt
  325. -- 通知客户端
  326. local msgRet = Msg.gc.GC_COPY_BUY_CHALLENGE_CNT
  327. msgRet.copyType = copyType
  328. msgRet.leftCnt = getLeftCnt(human, copyType)
  329. msgRet.maxCnt = getMaxCnt(human, copyType)
  330. Msg.send(msgRet, human.fd)
  331. local nowRed = isDotByType(human,copyType)
  332. if oldRed ~= nowRed then
  333. refreshRed(human,copyType,nowRed)
  334. end
  335. ]]
  336. end
  337. function getLeftCnt(human, copyType)
  338. local maxCnt = getMaxCnt(human, copyType)
  339. local nowCnt = 0
  340. if human.db.copy and human.db.copy[copyType] then
  341. nowCnt = human.db.copy[copyType].cnt or 0
  342. end
  343. return maxCnt - nowCnt
  344. end
  345. function getCurMaxCnt(human, copyType)
  346. local challengeCnt = CopyExcel.richang[copyType].challengeCnt
  347. local buyCnt = getMaxBuyCnt(human, copyType)
  348. local talismanAdd = getTalismanChallengeleAdd(human)
  349. local nowCnt = 0
  350. if human.db.copy and human.db.copy[copyType] then
  351. nowCnt = human.db.copy[copyType].cnt or 0
  352. end
  353. return buyCnt + challengeCnt + talismanAdd - nowCnt
  354. end
  355. function getMaxCnt(human, copyType)
  356. local curBuyCnt = getCurBuyCnt(human, copyType)
  357. local challengeCnt = CopyExcel.richang[copyType].challengeCnt
  358. local talismanAdd = getTalismanChallengeleAdd(human)
  359. return challengeCnt + curBuyCnt + talismanAdd
  360. end
  361. function getCanBuyCnt(human, copyType)
  362. return getMaxBuyCnt(human, copyType) - getCurBuyCnt(human, copyType)
  363. end
  364. function getCurBuyCnt(human, copyType)
  365. if human.db.copy == nil or human.db.copy[copyType] == nil or
  366. human.db.copy[copyType].buyCnt == nil then
  367. return 0
  368. end
  369. return human.db.copy[copyType].buyCnt
  370. end
  371. function getMaxBuyCnt(human, copyType)
  372. return VipLogic.getPowerArgs(human, VipLogic.VIP_POWER13) or 0
  373. end
  374. -- 副本列表日常副本红点
  375. function isDot(human)
  376. for i=1,#CopyExcel.richang do
  377. if isOpenByType(human,i,true) and isDotByType(human, i) then
  378. return true
  379. end
  380. end
  381. end
  382. function CG_COPY_CHALLENGE_SAODANG(human,copyID,touch)
  383. local copyConfig = CopyExcel.copy[copyID]
  384. if not copyConfig then return end
  385. local copyType = copyConfig.type
  386. if not canSaoDang(human,copyType,copyID) then return end
  387. local oldRed = isDotByType(human,copyType)
  388. if touch ~= 0 then
  389. if human.db.lv < SAODANG_COND_LEVEL then return end
  390. end
  391. local args = {}
  392. args[1] = copyID
  393. args[2] = touch or 0
  394. local isok, id, copyConfig = checkCombatPos(human, args)
  395. if not isok then return end
  396. if args[2] ~= 0 then
  397. local canBuy = getCanBuyCnt(human, copyType)
  398. if canBuy >= 1 then
  399. -- 改db
  400. human.db.copy = human.db.copy or {}
  401. human.db.copy[copyType] = human.db.copy[copyType] or {}
  402. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt or 0
  403. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt + canBuy
  404. end
  405. end
  406. local itemList = doFightEnd(human,copyID, nil, args[2])
  407. local double = RoleSystemLogic.isDouble(human, RoleSystemDefine.ROLE_SYS_ID_1206)
  408. local msgRet = Msg.gc.GC_COPY_CHALLENGE_SAODANG
  409. msgRet.copyType = copyType
  410. msgRet.copyID = copyID
  411. msgRet.double = double and 1 or 0
  412. msgRet.leftCnt = getLeftCnt(human, copyType)
  413. Msg.send(msgRet,human.fd)
  414. BagLogic.sendItemGetList(human,itemList, "copy_win")
  415. local nowRed = isDotByType(human,copyType)
  416. if oldRed ~= nowRed then
  417. refreshRed(human,copyType,nowRed)
  418. end
  419. challengeQuery(human, copyType)
  420. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1206)
  421. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1201)
  422. end
  423. function refreshRed(human,copyType,nowRed)
  424. local msgRet = Msg.gc.GC_COPY_CHALLENGE_RED
  425. msgRet.copyType = copyType
  426. msgRet.isRed = nowRed and 1 or 0
  427. Msg.send(msgRet,human.fd)
  428. end
  429. --------------------------------------------- combat ----------------------------------------------
  430. function getCombatMonsterOutID(human, side, args)
  431. if side ~= CombatDefine.DEFEND_SIDE then return end
  432. local id = tonumber(args[1] or 0)
  433. local copyConfig = CopyExcel.copy[id]
  434. if not copyConfig then return end
  435. return copyConfig.monsterOutID
  436. end
  437. function checkCombatPos(human, args)
  438. local id = tonumber(args[1] or 0)
  439. local touch = tonumber(args[2] or 0)
  440. local copyConfig = CopyExcel.copy[id]
  441. if not copyConfig then return end
  442. -- 等级判断
  443. if human.db.lv < copyConfig.lvNeed then
  444. return Broadcast.sendErr(human, Util.format(Lang.COMMON_SYSTEM_OPENTIP, copyConfig.lvNeed))
  445. end
  446. --获取全身 最高战力 6人组
  447. if human.db.zhandouli < copyConfig.zhandouliNeed then
  448. return Broadcast.sendErr(human, Util.format(Lang.COMMON_SYSTEM_OPENZHANLI, copyConfig.zhandouliNeed))
  449. end
  450. -- 前置副本要先打过
  451. local preCopyID = getCopyIDByLv(copyConfig.type, copyConfig.level - 1)
  452. if preCopyID and getMaxID(human, copyConfig.type) < preCopyID then
  453. return Broadcast.sendErr(human, Lang.COPY_FIGHT_ERR_PREID)
  454. end
  455. ObjHuman.updateDaily(human)
  456. local copyType = copyConfig.type
  457. local leftCnt = getLeftCnt(human, copyType)
  458. if touch == 0 then
  459. if leftCnt < 1 then
  460. local canBuy = getCanBuyCnt(human, copyType)
  461. if canBuy < 1 then
  462. return Broadcast.sendErr(human, Lang.COPY_FIGHT_ERR_NO_CNT)
  463. end
  464. -- 钻石判断
  465. local needZuanshi = CopyExcel.richang[copyType].zuanshi
  466. if not ObjHuman.checkRMB(human, needZuanshi) then
  467. return Broadcast.sendErr(human, Lang.COMMON_NO_ZUANSHI)
  468. end
  469. -- 扣钻石
  470. ObjHuman.decZuanshi(human, -needZuanshi, "buy_challenge_cnt")
  471. -- 改db
  472. human.db.copy = human.db.copy or {}
  473. human.db.copy[copyType] = human.db.copy[copyType] or {}
  474. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt or 0
  475. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt + 1
  476. end
  477. else
  478. if leftCnt < 1 then
  479. local canBuy = getCanBuyCnt(human, copyType)
  480. if canBuy < 1 then
  481. return Broadcast.sendErr(human, Lang.COPY_FIGHT_ERR_NO_CNT)
  482. end
  483. -- 钻石判断
  484. local needZuanshi = CopyExcel.richang[copyType].zuanshi * canBuy
  485. if not ObjHuman.checkRMB(human, needZuanshi) then
  486. return Broadcast.sendErr(human, Lang.COMMON_NO_ZUANSHI)
  487. end
  488. -- 扣钻石
  489. ObjHuman.decZuanshi(human, -needZuanshi, "buy_challenge_cnt")
  490. -- 改db
  491. human.db.copy = human.db.copy or {}
  492. human.db.copy[copyType] = human.db.copy[copyType] or {}
  493. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt or 0
  494. human.db.copy[copyType].buyCnt = human.db.copy[copyType].buyCnt + canBuy
  495. end
  496. end
  497. return true, id, copyConfig
  498. end
  499. function onUpdatePos(human)
  500. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1206)
  501. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_1201)
  502. end