BagLogic.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. ------------------------------------------------------------
  2. -- 背包
  3. -- addItem 添加道具
  4. -- delItem 删除道具
  5. -- sendItemGetList 通用道具获得界面
  6. -- checkItemCnt 检查道具数量是否足够,否则提示
  7. -- getItemCnt 返回道具数量
  8. ------------------------------------------------------------
  9. local EquipExcel = require("excel.equip").equip
  10. local ItemExcel = require("excel.item").item
  11. local FuwenExcel = require("excel.fuwen").fuwen
  12. local ItemBuyExcel = require("excel.item").buy
  13. local ItemComonBuyExcel = require("excel.item").commonBuy
  14. local Log = require("common.Log")
  15. local LogDefine = require("common.LogDefine")
  16. local Lang = require("common.Lang")
  17. local Util = require("common.Util")
  18. local ObjHuman = require("core.ObjHuman")
  19. local Msg = require("core.Msg")
  20. local Broadcast = require("broadcast.Broadcast")
  21. local Grid = require("bag.Grid")
  22. local ItemLogic = require("bag.ItemLogic")
  23. local ItemDefine = require("bag.ItemDefine")
  24. local ChengjiuDefine = require("chengjiu.ChengjiuDefine")
  25. local ChengjiuLogic = require("chengjiu.ChengjiuLogic")
  26. local FuwenLogic = require("fuwen.FuwenLogic")
  27. local MiddleOption = require("middle.MiddleOption")
  28. local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
  29. local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
  30. local EquipLogic = require("equip.EquipLogic")
  31. local YunYingLogic = require("yunying.YunYingLogic")
  32. local PanelDefine = require("broadcast.PanelDefine")
  33. local HeroGrowUp = require("absAct.HeroGrowUp")
  34. local ITEM_MOMENT_ADD_LIST = {}
  35. ADDITEM_TYPE_1 = 1 --顺序 不整合添加道具 非1 表示整合所有相同的道具数量
  36. ADDITEM_TYPE_2 = 2
  37. function updateMomentItem(type, itemID, itemCnt, quality)
  38. if type == ADDITEM_TYPE_1 then
  39. local len = #ITEM_MOMENT_ADD_LIST + 1
  40. ITEM_MOMENT_ADD_LIST[len] = {}
  41. ITEM_MOMENT_ADD_LIST[len][1] = itemID
  42. ITEM_MOMENT_ADD_LIST[len][2] = itemCnt
  43. ITEM_MOMENT_ADD_LIST[len][3] = quality
  44. else
  45. ITEM_MOMENT_ADD_LIST[itemID] = ITEM_MOMENT_ADD_LIST[itemID] or 0
  46. ITEM_MOMENT_ADD_LIST[itemID] = ITEM_MOMENT_ADD_LIST[itemID] + itemCnt
  47. end
  48. end
  49. -- 防止有报错 导致的 别的玩家 额外获得道具 在使用 通用的 添加之前 清除一次
  50. function cleanMomentItemList()
  51. Util.cleanTable(ITEM_MOMENT_ADD_LIST)
  52. end
  53. function addMomentItemList(human, logType, noSend)
  54. addItemList(human, ITEM_MOMENT_ADD_LIST, logType, noSend)
  55. cleanMomentItemList()
  56. end
  57. -- 通用道具添加 {[1] = {id, cnt}, [2] = {id,cnt}} or {[itemID] = itemCnt} 配表复杂 各自接口下自己for 添加
  58. function addItemList(human, list, logType, noSend)
  59. if not list or next(list) == nil then return end
  60. if list[1] and list[1][1] then
  61. for _, item in ipairs(list) do
  62. addItem(human, item[1], item[2], logType, noSend, item[3])
  63. end
  64. else
  65. for itemID, itemCnt in pairs(list) do
  66. addItem(human, itemID, itemCnt, logType, noSend)
  67. end
  68. end
  69. sendItemGetList(human, list, logType)
  70. end
  71. -- 增加装备,道具
  72. function addItem(human, id, cnt, logType, noSend, otherData)
  73. if cnt < 1 then return end
  74. local itemConfig = ItemDefine.getConfig(id)
  75. if not itemConfig then return end
  76. if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["item"] then
  77. assert()
  78. end
  79. MiddleOption.addItem(human, id, cnt, logType)
  80. if handlerSpObj(human, id, cnt, logType) then
  81. return
  82. end
  83. if handleFuwen(human, id, cnt, logType) then
  84. return
  85. end
  86. -- 装备走另外的逻辑
  87. if handleEquipAdd(human, id, cnt, logType, otherData) then
  88. return
  89. end
  90. local oldCnt = human.db.bag[id] or 0
  91. local newCnt = math.min(oldCnt + cnt, ItemDefine.BAG_ITEM_MAX_CNT)
  92. human.db.bag[id] = newCnt
  93. if not noSend then
  94. sendChange(human, id, oldCnt < 1)
  95. end
  96. Log.write(Log.LOGID_OSS_ITEM, human.db._id, human.db.account, human.db.name, human.db.lv,
  97. LogDefine.DEFINE[logType] + LogDefine.TYPE["item"] , id, cnt, newCnt)
  98. -- 如果道具为公会贡献,记录到当日累计贡献中
  99. if id == ItemDefine.ITEM_UNION_COIN_ID then
  100. human.db.dailyBanggong = human.db.dailyBanggong or 0
  101. human.db.dailyBanggong = human.db.dailyBanggong + cnt
  102. human.db.totalBanggong = human.db.totalBanggong or 0
  103. human.db.totalBanggong = human.db.totalBanggong + cnt
  104. end
  105. -- 根据道具触发红点
  106. checkDotByID(human,id)
  107. return true
  108. end
  109. function checkDotByID(human,id)
  110. local itemConfig = ItemDefine.getConfig(id)
  111. local dotTb = itemConfig.dot
  112. local len = #dotTb
  113. for i = 1,len do
  114. RoleSystemLogic.onDot(human, dotTb[i])
  115. end
  116. end
  117. -- 根据id删除
  118. function delItem(human, id, cnt, logType, noSend, byId, byCnt)
  119. if cnt < 1 then return end
  120. local itemConfig = ItemExcel[id]
  121. if not itemConfig then return end
  122. if not LogDefine.DEFINE[logType] or not LogDefine.TYPE["item"] then
  123. assert()
  124. end
  125. if id == ItemDefine.ITEM_JINBI_ID then
  126. return ObjHuman.updateJinbi(human, -cnt, logType, byId, byCnt)
  127. elseif id == ItemDefine.ITEM_ZUANSHI_ID then
  128. return ObjHuman.decZuanshi(human, -cnt, logType, byId, byCnt)
  129. elseif id == ItemDefine.ITEM_FRIEND_ID then
  130. return ObjHuman.updateFriendHeart(human, -cnt, logType)
  131. end
  132. local newCnt = (human.db.bag[id] or 0) - cnt
  133. if newCnt < 0 then assert(nil) end
  134. if newCnt < 1 then
  135. newCnt = nil
  136. end
  137. human.db.bag[id] = newCnt
  138. if not noSend then
  139. sendChange(human, id)
  140. end
  141. Log.write(Log.LOGID_OSS_ITEM, human.db._id, human.db.account, human.db.name, human.db.lv,
  142. LogDefine.DEFINE[logType] + LogDefine.TYPE["item"] , id, -cnt, newCnt or 0)
  143. if itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN or
  144. itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN_SKIN then
  145. RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_206)
  146. end
  147. if id == ItemDefine.ITEM_GREEN_EXP_ID then
  148. HeroGrowUp.onCallback(human, HeroGrowUp.TASKTYPE18, cnt)
  149. end
  150. return true
  151. end
  152. -- 获得道具数量
  153. function getItemCnt(human, id, isUse)
  154. if id == ItemDefine.ITEM_JINBI_ID and not isUse then
  155. return human.db.jinbi or 0
  156. elseif id == ItemDefine.ITEM_ZUANSHI_ID and not isUse then
  157. return human.db.zuanshi or 0
  158. elseif id == ItemDefine.ITEM_FRIEND_ID and not isUse then
  159. return human.db.friendHeart or 0
  160. end
  161. return human.db.bag[id] or 0
  162. end
  163. -- 判断道具数量
  164. function checkItemCnt(human, id, cnt)
  165. if id == ItemDefine.ITEM_ZUANSHI_ID then
  166. return ObjHuman.checkRMB(human,cnt)
  167. end
  168. if getItemCnt(human, id) < cnt then
  169. local name = ItemDefine.getValue(id,"name")
  170. return Broadcast.sendErr(human,Util.format(Lang.COMMON_NO_ITEM, name))
  171. end
  172. return true
  173. end
  174. -- 特殊不进背包的道具
  175. function handlerSpObj(human, itemID, itemCnt, logType)
  176. local itemConfig = ItemExcel[itemID]
  177. if not itemConfig then return end
  178. if itemConfig.subType ~= ItemDefine.ITEM_SUBTYPE_SPOBJ then
  179. return
  180. end
  181. local cmdstr = itemConfig.cmd and itemConfig.cmd[1]
  182. if cmdstr and ItemLogic.cmd[cmdstr] then
  183. ItemLogic.onlyuse(human, itemID, itemCnt, logType, true)
  184. -- 根据道具触发红点
  185. checkDotByID(human,itemID)
  186. end
  187. if ItemDefine.checkIsWave(LogDefine.DEFINE[logType]) then
  188. sendRoll(human, itemID, itemCnt)
  189. end
  190. return true
  191. end
  192. -- 符文
  193. function handleFuwen(human, itemID, itemCnt, logType)
  194. if not FuwenExcel[itemID] then return end
  195. FuwenLogic.add(human, itemID, itemCnt, logType)
  196. if ItemDefine.checkIsWave(LogDefine.DEFINE[logType]) then
  197. sendRoll(human, itemID, itemCnt)
  198. end
  199. return true
  200. end
  201. -- 装备增加
  202. function handleEquipAdd(human, itemID, itemCnt, logType, otherData)
  203. if not EquipExcel[itemID] then return end
  204. EquipLogic.addEquip(human, itemID, itemCnt, logType, otherData)
  205. if EquipExcel[itemID].mainType == ItemDefine.MAINTYPE_EQUIP then
  206. if EquipExcel[itemID].level == 14 then
  207. ChengjiuLogic.onCallback(human,ChengjiuDefine.CJ_TASK_TYPE_24,itemCnt)
  208. end
  209. end
  210. if ItemDefine.checkIsWave(LogDefine.DEFINE[logType]) then
  211. sendRoll(human, itemID, itemCnt)
  212. end
  213. return true
  214. end
  215. ---------------------------- msg --------------------------------
  216. -- 发送背包道具
  217. function sendBagList(human)
  218. local msgRet = Msg.gc.GC_BAG_LIST
  219. msgRet.list[0] = 0
  220. for itemID, itemCnt in pairs(human.db.bag) do
  221. msgRet.list[0] = msgRet.list[0] + 1
  222. local net = msgRet.list[msgRet.list[0]]
  223. Grid.makeItem(net, itemID, itemCnt, nil,nil,nil, Grid.getOpflagAtBag(itemID))
  224. if msgRet.list[0] >= ItemDefine.PAGE_LIST_COUNT then
  225. Msg.send(msgRet, human.fd)
  226. msgRet.list[0] = 0
  227. end
  228. end
  229. if msgRet.list[0] > 0 then
  230. Msg.send(msgRet, human.fd)
  231. end
  232. end
  233. -- 改变
  234. function sendChange(human, itemID, isAdd)
  235. local msgRet = Msg.gc.GC_ITEM_BAG_CHANGE
  236. local itemCnt = human.db.bag[itemID] or 0
  237. msgRet.itemID = itemID
  238. msgRet.itemCnt = itemCnt
  239. msgRet.itemData[0] = 0
  240. if isAdd == true then
  241. msgRet.itemData[0] = 1
  242. Grid.makeItem(msgRet.itemData[1], itemID, itemCnt, nil,nil,nil, Grid.getOpflagAtBag(itemID))
  243. end
  244. Msg.send(msgRet, human.fd)
  245. end
  246. -- 滚动
  247. function sendRoll(human, itemID, itemCnt)
  248. --[[local msgRet = Msg.gc.GC_ITEM_BAG_ROLL
  249. msgRet.itemData[0] = 1
  250. Grid.makeItem(msgRet.itemData[1], itemID, itemCnt)
  251. Msg.send(msgRet, human.fd)]]
  252. end
  253. -- 通用道具获得面板 list = {...}
  254. function sendItemGetList(human, list, logStr)
  255. if not list or not next(list) then return end
  256. if list[1] and list[1][1] then
  257. sendItemGetList1(human, list, logStr)
  258. else
  259. sendItemGetList2(human, list, logStr)
  260. end
  261. end
  262. -- 通用道具获得面板 list = {[1]={id,cnt},[2]={id2,cnt2}...}
  263. function sendItemGetList1(human, list, logStr)
  264. if not list or not next(list) then return end
  265. local msgRet = Msg.gc.GC_ITEM_GET_LIST
  266. msgRet.popupType = ItemDefine.checkIsWave(LogDefine.DEFINE[logStr]) and 1 or 0
  267. local len = math.min(#list, #msgRet.list)
  268. local cnt = 0
  269. cnt = EquipLogic.makeEquipItem(human, msgRet.list, cnt)
  270. for i=1,len do
  271. if cnt >= #msgRet.list then
  272. break
  273. end
  274. local itemID = list[i][1]
  275. local itemCnt = list[i][2]
  276. if not ItemDefine.isEquip(itemID) then
  277. cnt = cnt + 1
  278. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
  279. end
  280. end
  281. if cnt > 0 then
  282. msgRet.list[0] = cnt
  283. Msg.send(msgRet,human.fd)
  284. end
  285. end
  286. -- 通用道具获得面板2 list = {[id]=cnt,[id2]=cnt2}
  287. function sendItemGetList2(human, list, logStr)
  288. if not list or not next(list) then return end
  289. local msgRet = Msg.gc.GC_ITEM_GET_LIST
  290. msgRet.popupType = ItemDefine.checkIsWave(LogDefine.DEFINE[logStr]) and 1 or 0
  291. msgRet.list[0] = 0
  292. local cnt = 0
  293. cnt = EquipLogic.makeEquipItem(human, msgRet.list, cnt)
  294. for itemID, itemCnt in pairs(list) do
  295. if cnt >= #msgRet.list then
  296. break
  297. end
  298. if not ItemDefine.isEquip(itemID) then
  299. cnt = cnt + 1
  300. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
  301. end
  302. end
  303. --Msg.trace(msgRet)
  304. if cnt > 0 then
  305. msgRet.list[0] = cnt
  306. Msg.send(msgRet,human.fd)
  307. end
  308. end
  309. -- 通用道具获得面板2 list = {[id]=cnt,[id2]=cnt2}
  310. function sendItemGetList3(human, list, logStr)
  311. if not list or not next(list) then return end
  312. local msgRet = Msg.gc.GC_ITEM_GET_LIST
  313. msgRet.popupType = ItemDefine.checkIsWave(LogDefine.DEFINE[logStr]) and 1 or 0
  314. msgRet.list[0] = 0
  315. local cnt = 0
  316. cnt = EquipLogic.makeEquipItem(human, msgRet.list, cnt)
  317. for i = 1, #list do
  318. local items = list[i]
  319. for itemID, itemCnt in pairs(items) do
  320. if cnt >= #msgRet.list then
  321. break
  322. end
  323. if not ItemDefine.isEquip(itemID) then
  324. cnt = cnt + 1
  325. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
  326. end
  327. end
  328. end
  329. if cnt > 0 then
  330. msgRet.list[0] = cnt
  331. Msg.send(msgRet,human.fd)
  332. end
  333. end
  334. -- 相同的道具自动叠加一起
  335. local SAME_ITEMS1 = {}
  336. local SAME_ITEMS2 = {}
  337. function sameItemTogether(list)
  338. if not list or not next(list) then return end
  339. for k in pairs(SAME_ITEMS1) do
  340. SAME_ITEMS1[k] = nil
  341. end
  342. for k in pairs(SAME_ITEMS2) do
  343. SAME_ITEMS2[k] = nil
  344. end
  345. for _, item in ipairs(list) do
  346. local itemID = item[1]
  347. local itemCnt = item[2]
  348. -- 装备符文不能叠加
  349. if not ItemDefine.isEquip(itemID) and not ItemDefine.isFuwen(itemID) then
  350. SAME_ITEMS1[itemID] = (SAME_ITEMS1[itemID] or 0) + itemCnt
  351. end
  352. end
  353. for itemID, itemCnt in pairs(SAME_ITEMS1) do
  354. SAME_ITEMS2[#SAME_ITEMS2 + 1] = {itemID, itemCnt}
  355. end
  356. return SAME_ITEMS2, SAME_ITEMS1
  357. end
  358. -- 背包道具出售
  359. function itemSell(human, itemID, itemCnt)
  360. if itemCnt < 1 then return end
  361. local itemConfig = ItemDefine.getConfig(itemID)
  362. if not itemConfig then return end
  363. if not itemConfig.price then return end
  364. local saleItemID = itemConfig.price[1]
  365. local saleItemCnt = itemConfig.price[2]
  366. if not saleItemCnt or saleItemCnt < 1 then return end -- 不能出售
  367. local bagCnt = getItemCnt(human, itemID)
  368. if bagCnt < itemCnt then return end
  369. local itemCntAdd = math.floor(saleItemCnt * itemCnt)
  370. delItem(human, itemID, itemCnt, "item_sale")
  371. addItem(human, saleItemID, itemCntAdd, "item_sale")
  372. local list = {}
  373. list[1] = { [1] = saleItemID, [2]= itemCntAdd }
  374. sendItemGetList(human, list)
  375. local msgRet = Msg.gc.GC_BAG_ITEM_SELL
  376. msgRet.id = itemID
  377. msgRet.cnt = itemCnt
  378. Msg.send(msgRet, human.fd)
  379. end
  380. -- 装备道具出售
  381. function equipSell(human, bagIndex)
  382. local equipGrid = human.db.equipBag[bagIndex]
  383. if not equipGrid then return end
  384. local itemConfig = ItemDefine.getConfig(equipGrid.id)
  385. if not itemConfig then return end
  386. if not itemConfig.price then return end
  387. local saleItemID = itemConfig.price[1]
  388. local saleItemCnt = itemConfig.price[2]
  389. if not saleItemCnt or saleItemCnt < 1 then return end
  390. EquipLogic.delEquip(human, bagIndex, "equip_sale")
  391. local itemCntAdd = saleItemCnt
  392. addItem(human, saleItemID, itemCntAdd, "equip_sale")
  393. sendItemGetList(human, {[1]=itemConfig.price})
  394. end
  395. -- 装备道具出售
  396. function equipSellByQuality(human, qualityStr)
  397. local qualityList = Util.split(qualityStr, ",", true)
  398. local len = #qualityList
  399. if len <= 0 or len > 4 then return end
  400. local outItems = {}
  401. for i = 1, #qualityList do
  402. local quality = qualityList[i]
  403. for k, equipGrid in pairs(human.db.equipBag) do
  404. if equipGrid.quality == quality then
  405. local itemConfig = ItemDefine.getConfig(equipGrid.id)
  406. if not itemConfig then assert() end
  407. if not itemConfig.price then assert() end
  408. local saleItemID = itemConfig.price[1]
  409. local saleItemCnt = itemConfig.price[2]
  410. if not saleItemCnt or saleItemCnt < 1 then assert() end
  411. EquipLogic.delEquip(human, k, "equip_sale", true)
  412. local itemCntAdd = saleItemCnt
  413. addItem(human, saleItemID, itemCntAdd, "equip_sale")
  414. outItems[saleItemID] = outItems[saleItemID] or 0
  415. outItems[saleItemID] = outItems[saleItemID] + itemCntAdd
  416. end
  417. end
  418. end
  419. sendItemGetList(human, outItems)
  420. -- 出售成功
  421. local msgRet = Msg.gc.GC_BAG_EQUIP_SELL_QUALITY
  422. Msg.send(msgRet,human.fd)
  423. end
  424. -- 道具购买查询
  425. function queryItemBuy(human, id)
  426. local config = ItemBuyExcel[id]
  427. if not config then return end
  428. local msgRet = Msg.gc.GC_ITEM_BUY_QUERY
  429. msgRet.id = id
  430. msgRet.item[0] = 1
  431. Grid.makeItem(msgRet.item[1], id , 1)
  432. msgRet.canBuy[0] = 2
  433. msgRet.canBuy[1] = config.cnt1
  434. msgRet.canBuy[2] = config.cnt2
  435. msgRet.need[0] = 0
  436. for _, item in ipairs(config.need1) do
  437. msgRet.need[0] = msgRet.need[0] + 1
  438. Grid.makeItem(msgRet.need[msgRet.need[0]], item[1], item[2])
  439. end
  440. msgRet.needTwo[0] = 0
  441. for _, item in ipairs(config.need2) do
  442. msgRet.needTwo[0] = msgRet.needTwo[0] + 1
  443. Grid.makeItem(msgRet.needTwo[msgRet.needTwo[0]], item[1], item[2])
  444. end
  445. --Msg.trace(msgRet)
  446. Msg.send(msgRet,human.fd)
  447. end
  448. -- 购买道具
  449. function buyItem(human, id, buyCnt, cnt)
  450. local config = ItemBuyExcel[id]
  451. if not config then return end
  452. local needList = nil
  453. if config.cnt1 == buyCnt then
  454. needList = config.need1
  455. elseif config.cnt2 == buyCnt then
  456. needList = config.need2
  457. end
  458. if not needList then return end
  459. if cnt < 1 then return end
  460. -- 判断消耗
  461. for _, item in ipairs(needList) do
  462. if not checkItemCnt(human, item[1], item[2] * cnt) then
  463. return
  464. end
  465. end
  466. -- 某些购买日志类型特殊
  467. local logType = "item_buy"
  468. if id == ItemDefine.ITEM_ABS_DRAW_LONGZHU_ID then
  469. logType = "item_buy_dragong"
  470. end
  471. -- 扣除道具
  472. for _, item in ipairs(needList) do
  473. delItem(human, item[1], item[2] * cnt, logType)
  474. end
  475. addItem(human, id, buyCnt * cnt, logType)
  476. Broadcast.sendErr(human, Lang.ITEM_BUY_SUCCESS)
  477. local msgRet = Msg.gc.GC_ITEM_BUY
  478. msgRet.id = id
  479. Msg.send(msgRet, human.fd)
  480. end
  481. function sendCommonBuyQuery(human, itemID)
  482. local config = ItemComonBuyExcel[itemID]
  483. if not config then return end
  484. local msgRet = Msg.gc.GC_ITEM_COMMON_BUY_QUERY
  485. Grid.makeItem(msgRet.item, itemID, 1)
  486. msgRet.price = config.price
  487. Msg.send(msgRet, human.fd)
  488. end
  489. function commonBuy(human, itemID, itemCnt)
  490. if itemCnt < 1 then return end
  491. local config = ItemComonBuyExcel[itemID]
  492. if not config then return end
  493. local cost = config.price * itemCnt
  494. if not ObjHuman.checkRMB(human, cost) then
  495. return
  496. end
  497. ObjHuman.decZuanshi(human, -cost, "item_buy", itemID, itemCnt)
  498. addItem(human, itemID, itemCnt, "item_buy")
  499. local msgRet = Msg.gc.GC_ITEM_COMMON_BUY
  500. msgRet.itemID = itemID
  501. Msg.send(msgRet, human.fd)
  502. end
  503. function isDot(human)
  504. for itemID, itemCnt in pairs(human.db.bag) do
  505. local itemConfig = ItemExcel[itemID]
  506. if itemConfig then
  507. if itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN or
  508. itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN_SKIN then
  509. if itemCnt >= itemConfig.fullCnt then
  510. return true
  511. end
  512. end
  513. end
  514. end
  515. return false
  516. end