BagLogic.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt, nil,nil,nil, Grid.getOpflagAtBag(itemID))
  280. end
  281. end
  282. if cnt > 0 then
  283. msgRet.list[0] = cnt
  284. Msg.send(msgRet,human.fd)
  285. end
  286. end
  287. -- 通用道具获得面板2 list = {[id]=cnt,[id2]=cnt2}
  288. function sendItemGetList2(human, list, logStr)
  289. if not list or not next(list) then return end
  290. local msgRet = Msg.gc.GC_ITEM_GET_LIST
  291. msgRet.popupType = ItemDefine.checkIsWave(LogDefine.DEFINE[logStr]) and 1 or 0
  292. msgRet.list[0] = 0
  293. local cnt = 0
  294. cnt = EquipLogic.makeEquipItem(human, msgRet.list, cnt)
  295. for itemID, itemCnt in pairs(list) do
  296. if cnt >= #msgRet.list then
  297. break
  298. end
  299. if not ItemDefine.isEquip(itemID) then
  300. cnt = cnt + 1
  301. --Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
  302. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt, nil,nil,nil, Grid.getOpflagAtBag(itemID))
  303. end
  304. end
  305. --Msg.trace(msgRet)
  306. if cnt > 0 then
  307. msgRet.list[0] = cnt
  308. Msg.send(msgRet,human.fd)
  309. end
  310. end
  311. -- 通用道具获得面板2 list = {[id]=cnt,[id2]=cnt2}
  312. function sendItemGetList3(human, list, logStr)
  313. if not list or not next(list) then return end
  314. local msgRet = Msg.gc.GC_ITEM_GET_LIST
  315. msgRet.popupType = ItemDefine.checkIsWave(LogDefine.DEFINE[logStr]) and 1 or 0
  316. msgRet.list[0] = 0
  317. local cnt = 0
  318. cnt = EquipLogic.makeEquipItem(human, msgRet.list, cnt)
  319. for i = 1, #list do
  320. local items = list[i]
  321. for itemID, itemCnt in pairs(items) do
  322. if cnt >= #msgRet.list then
  323. break
  324. end
  325. if not ItemDefine.isEquip(itemID) then
  326. cnt = cnt + 1
  327. Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
  328. end
  329. end
  330. end
  331. if cnt > 0 then
  332. msgRet.list[0] = cnt
  333. Msg.send(msgRet,human.fd)
  334. end
  335. end
  336. -- 相同的道具自动叠加一起
  337. local SAME_ITEMS1 = {}
  338. local SAME_ITEMS2 = {}
  339. function sameItemTogether(list)
  340. if not list or not next(list) then return end
  341. for k in pairs(SAME_ITEMS1) do
  342. SAME_ITEMS1[k] = nil
  343. end
  344. for k in pairs(SAME_ITEMS2) do
  345. SAME_ITEMS2[k] = nil
  346. end
  347. for _, item in ipairs(list) do
  348. local itemID = item[1]
  349. local itemCnt = item[2]
  350. -- 装备符文不能叠加
  351. if not ItemDefine.isEquip(itemID) and not ItemDefine.isFuwen(itemID) then
  352. SAME_ITEMS1[itemID] = (SAME_ITEMS1[itemID] or 0) + itemCnt
  353. end
  354. end
  355. for itemID, itemCnt in pairs(SAME_ITEMS1) do
  356. SAME_ITEMS2[#SAME_ITEMS2 + 1] = {itemID, itemCnt}
  357. end
  358. return SAME_ITEMS2, SAME_ITEMS1
  359. end
  360. -- 背包道具出售
  361. function itemSell(human, itemID, itemCnt)
  362. if itemCnt < 1 then return end
  363. local itemConfig = ItemDefine.getConfig(itemID)
  364. if not itemConfig then return end
  365. if not itemConfig.price then return end
  366. local saleItemID = itemConfig.price[1]
  367. local saleItemCnt = itemConfig.price[2]
  368. if not saleItemCnt or saleItemCnt < 1 then return end -- 不能出售
  369. local bagCnt = getItemCnt(human, itemID)
  370. if bagCnt < itemCnt then return end
  371. local itemCntAdd = math.floor(saleItemCnt * itemCnt)
  372. delItem(human, itemID, itemCnt, "item_sale")
  373. addItem(human, saleItemID, itemCntAdd, "item_sale")
  374. local list = {}
  375. list[1] = { [1] = saleItemID, [2]= itemCntAdd }
  376. sendItemGetList(human, list)
  377. local msgRet = Msg.gc.GC_BAG_ITEM_SELL
  378. msgRet.id = itemID
  379. msgRet.cnt = itemCnt
  380. Msg.send(msgRet, human.fd)
  381. end
  382. -- 装备道具出售
  383. function equipSell(human, bagIndex)
  384. local equipGrid = human.db.equipBag[bagIndex]
  385. if not equipGrid then return end
  386. local itemConfig = ItemDefine.getConfig(equipGrid.id)
  387. if not itemConfig then return end
  388. if not itemConfig.price then return end
  389. local saleItemID = itemConfig.price[1]
  390. local saleItemCnt = itemConfig.price[2]
  391. if not saleItemCnt or saleItemCnt < 1 then return end
  392. EquipLogic.delEquip(human, bagIndex, "equip_sale")
  393. local itemCntAdd = saleItemCnt
  394. addItem(human, saleItemID, itemCntAdd, "equip_sale")
  395. sendItemGetList(human, {[1]=itemConfig.price})
  396. end
  397. -- 装备道具出售
  398. function equipSellByQuality(human, qualityStr)
  399. local qualityList = Util.split(qualityStr, ",", true)
  400. local len = #qualityList
  401. if len <= 0 or len > 4 then return end
  402. local outItems = {}
  403. for i = 1, #qualityList do
  404. local quality = qualityList[i]
  405. for k, equipGrid in pairs(human.db.equipBag) do
  406. if equipGrid.quality == quality then
  407. local itemConfig = ItemDefine.getConfig(equipGrid.id)
  408. if not itemConfig then assert() end
  409. if not itemConfig.price then assert() end
  410. local saleItemID = itemConfig.price[1]
  411. local saleItemCnt = itemConfig.price[2]
  412. if not saleItemCnt or saleItemCnt < 1 then assert() end
  413. EquipLogic.delEquip(human, k, "equip_sale", true)
  414. local itemCntAdd = saleItemCnt
  415. addItem(human, saleItemID, itemCntAdd, "equip_sale")
  416. outItems[saleItemID] = outItems[saleItemID] or 0
  417. outItems[saleItemID] = outItems[saleItemID] + itemCntAdd
  418. end
  419. end
  420. end
  421. sendItemGetList(human, outItems)
  422. -- 出售成功
  423. local msgRet = Msg.gc.GC_BAG_EQUIP_SELL_QUALITY
  424. Msg.send(msgRet,human.fd)
  425. end
  426. -- 道具购买查询
  427. function queryItemBuy(human, id)
  428. local config = ItemBuyExcel[id]
  429. if not config then return end
  430. local msgRet = Msg.gc.GC_ITEM_BUY_QUERY
  431. msgRet.id = id
  432. msgRet.item[0] = 1
  433. Grid.makeItem(msgRet.item[1], id , 1)
  434. msgRet.canBuy[0] = 2
  435. msgRet.canBuy[1] = config.cnt1
  436. msgRet.canBuy[2] = config.cnt2
  437. msgRet.need[0] = 0
  438. for _, item in ipairs(config.need1) do
  439. msgRet.need[0] = msgRet.need[0] + 1
  440. Grid.makeItem(msgRet.need[msgRet.need[0]], item[1], item[2])
  441. end
  442. msgRet.needTwo[0] = 0
  443. for _, item in ipairs(config.need2) do
  444. msgRet.needTwo[0] = msgRet.needTwo[0] + 1
  445. Grid.makeItem(msgRet.needTwo[msgRet.needTwo[0]], item[1], item[2])
  446. end
  447. --Msg.trace(msgRet)
  448. Msg.send(msgRet,human.fd)
  449. end
  450. -- 购买道具
  451. function buyItem(human, id, buyCnt, cnt)
  452. local config = ItemBuyExcel[id]
  453. if not config then return end
  454. local needList = nil
  455. if config.cnt1 == buyCnt then
  456. needList = config.need1
  457. elseif config.cnt2 == buyCnt then
  458. needList = config.need2
  459. end
  460. if not needList then return end
  461. if cnt < 1 then return end
  462. -- 判断消耗
  463. for _, item in ipairs(needList) do
  464. if not checkItemCnt(human, item[1], item[2] * cnt) then
  465. return
  466. end
  467. end
  468. -- 某些购买日志类型特殊
  469. local logType = "item_buy"
  470. if id == ItemDefine.ITEM_ABS_DRAW_LONGZHU_ID then
  471. logType = "item_buy_dragong"
  472. end
  473. -- 扣除道具
  474. for _, item in ipairs(needList) do
  475. delItem(human, item[1], item[2] * cnt, logType)
  476. end
  477. addItem(human, id, buyCnt * cnt, logType)
  478. Broadcast.sendErr(human, Lang.ITEM_BUY_SUCCESS)
  479. local msgRet = Msg.gc.GC_ITEM_BUY
  480. msgRet.id = id
  481. Msg.send(msgRet, human.fd)
  482. end
  483. function sendCommonBuyQuery(human, itemID)
  484. local config = ItemComonBuyExcel[itemID]
  485. if not config then return end
  486. local msgRet = Msg.gc.GC_ITEM_COMMON_BUY_QUERY
  487. Grid.makeItem(msgRet.item, itemID, 1)
  488. msgRet.price = config.price
  489. Msg.send(msgRet, human.fd)
  490. end
  491. function commonBuy(human, itemID, itemCnt)
  492. if itemCnt < 1 then return end
  493. local config = ItemComonBuyExcel[itemID]
  494. if not config then return end
  495. local cost = config.price * itemCnt
  496. if not ObjHuman.checkRMB(human, cost) then
  497. return
  498. end
  499. ObjHuman.decZuanshi(human, -cost, "item_buy", itemID, itemCnt)
  500. addItem(human, itemID, itemCnt, "item_buy")
  501. local msgRet = Msg.gc.GC_ITEM_COMMON_BUY
  502. msgRet.itemID = itemID
  503. Msg.send(msgRet, human.fd)
  504. end
  505. function isDot(human)
  506. for itemID, itemCnt in pairs(human.db.bag) do
  507. local itemConfig = ItemExcel[itemID]
  508. if itemConfig then
  509. if itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN or
  510. itemConfig.subType == ItemDefine.ITEM_SUBTYPE_SUIPIAN_SKIN then
  511. if itemCnt >= itemConfig.fullCnt then
  512. return true
  513. end
  514. end
  515. end
  516. end
  517. return false
  518. end