|
|
@@ -72,6 +72,7 @@ local function TreasureChestLogic_CreateDB(human)
|
|
|
human.db.TreasureChest = {
|
|
|
nPoint = 0,
|
|
|
tPointPrize = {},
|
|
|
+ tItem = {}, -- 宝箱数量
|
|
|
}
|
|
|
|
|
|
TreasureChestLogic_ResetDBPointPrize(human)
|
|
|
@@ -167,9 +168,32 @@ local function TreasureChestLogic_OpenBox(nType, nBoxNum)
|
|
|
return tOpenPrize
|
|
|
end
|
|
|
|
|
|
+-- 获取宝箱数量
|
|
|
+local function TreasureChestLogic_GetGoodsNum(human, nGoodsID)
|
|
|
+ if not human.db.TreasureChest.tItem[nGoodsID] then
|
|
|
+ human.db.TreasureChest.tItem[nGoodsID] = 0
|
|
|
+ end
|
|
|
+
|
|
|
+ return human.db.TreasureChest.tItem[nGoodsID]
|
|
|
+end
|
|
|
+
|
|
|
+-- 添加宝箱物品
|
|
|
+local function TreasureChestLogic_AddGoods(human, nGoodsID, nGoodsNum)
|
|
|
+ if not human.db.TreasureChest.tItem[nGoodsID] then
|
|
|
+ human.db.TreasureChest.tItem[nGoodsID] = 0
|
|
|
+ end
|
|
|
+
|
|
|
+ human.db.TreasureChest.tItem[nGoodsID] = human.db.TreasureChest.tItem[nGoodsID] + nGoodsNum
|
|
|
+end
|
|
|
+
|
|
|
-- 删除物品
|
|
|
local function TreasureChestLogic_DelGoods(human, nGoodsID, nGoodsNum)
|
|
|
- BagLogic.delItem(human, nGoodsID, nGoodsNum, "treasurechest")
|
|
|
+ human.db.TreasureChest.tItem[nGoodsID] = human.db.TreasureChest.tItem[nGoodsID] - nGoodsNum
|
|
|
+ if 0 > human.db.TreasureChest.tItem[nGoodsID] then
|
|
|
+ human.db.TreasureChest.tItem[nGoodsID] = 0
|
|
|
+ end
|
|
|
+
|
|
|
+ TreasureChestLogic_WriteLog(human, "减少了宝箱道具 nItemID "..nGoodsID.." nDelNum "..nGoodsNum)
|
|
|
end
|
|
|
|
|
|
----------------------------------------- 客户端请求 -------------------------------------
|
|
|
@@ -214,7 +238,7 @@ function TreasureChestLogic_Query(human)
|
|
|
local tData = tMsgData.tList[nLen]
|
|
|
tData.nType = nType
|
|
|
local nGoodsID = v.nItemID
|
|
|
- local nGoodsNum = BagLogic.getItemCnt(human, nGoodsID)
|
|
|
+ local nGoodsNum = TreasureChestLogic_GetGoodsNum(human, nGoodsID)
|
|
|
Grid.makeItem(tData.tItemData, nGoodsID, nGoodsNum)
|
|
|
end
|
|
|
|
|
|
@@ -266,7 +290,7 @@ function TreasureChestLogic_Open(human, nBoxType, nBoxNum)
|
|
|
end
|
|
|
|
|
|
local nGoodsID = tBoxTypeConf[nBoxType].nItemID
|
|
|
- local nGoodsNum = BagLogic.getItemCnt(human, nGoodsID)
|
|
|
+ local nGoodsNum = TreasureChestLogic_GetGoodsNum(human, nGoodsID)
|
|
|
if nBoxNum > nGoodsNum then
|
|
|
print("[TreasureChestLogic_Open] 玩家拥有宝箱数量不足 nBoxType = "
|
|
|
..nBoxType.." nBoxNum = "..nBoxNum.." nGoodsNum = "..nGoodsNum)
|
|
|
@@ -384,4 +408,18 @@ end
|
|
|
|
|
|
function TreasureChestLogic_GmClear(human)
|
|
|
TreasureChestLogic_CreateDB(human)
|
|
|
+end
|
|
|
+
|
|
|
+-- 增加道具
|
|
|
+function TreasureChestLogic_AddItem(human, nItemID, nAddNum)
|
|
|
+ if not human.db.TreasureChest then
|
|
|
+ TreasureChestLogic_CreateDB(human)
|
|
|
+ end
|
|
|
+
|
|
|
+ if 0 >= nAddNum then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ TreasureChestLogic_AddGoods(human, nItemID, nAddNum)
|
|
|
+ TreasureChestLogic_WriteLog(human, "增加了宝箱道具 nItemID "..nItemID.." nAddNum "..nAddNum)
|
|
|
end
|