CopyLogic.lua 19 KB

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