CopyLogic.lua 19 KB

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