فهرست منبع

提交宝箱增加道具修改

SCFC 1 سال پیش
والد
کامیت
90d582b550

+ 4 - 1
script/module/bag/BagLogic.lua

@@ -88,22 +88,25 @@ function addItem(human, id, cnt, logType, noSend, otherData)
 
 	MiddleOption.addItem(human, id, cnt, logType)
 	if handlerSpObj(human, id, cnt, logType) then
+		print("[addItem] 不进入背包物品直接返回 id, cnt = ", id, cnt)
 		return
 	end
     	
 	if handleFuwen(human, id, cnt, logType) then
+		print("[addItem] 符文物品不进入背包物品直接返回 id, cnt = ", id, cnt)
 		return
 	end
 
     -- 装备走另外的逻辑
     if handleEquipAdd(human, id, cnt, logType, otherData) then
-
+		print("[addItem] 装备物品其他方式处理 id, cnt = ", id, cnt)
 		return
 	end
 
 	local oldCnt = human.db.bag[id] or 0
 	local newCnt = math.min(oldCnt + cnt, ItemDefine.BAG_ITEM_MAX_CNT)
 	human.db.bag[id] = newCnt
+	print("[addItem] id = "..id .." newCnt = "..newCnt.."\n")
 	
 	if not noSend then
 		sendChange(human, id, oldCnt < 1)

+ 1 - 1
script/module/bag/Grid.lua

@@ -423,7 +423,7 @@ function canUseBatch(itemConfig)
 	if not itemConfig.cmd then return end
 	local cmdstr = itemConfig.cmd[1]
 	if not cmdstr then return end
-	if cmdstr == "box" then
+	if cmdstr == "box" or "UseSkinItem" == cmdstr then
 		return
 	end
 	return true

+ 9 - 0
script/module/bag/ItemLogic.lua

@@ -30,6 +30,7 @@ local BuyExcel = require("excel.buy")
 local LostTempleLogic = require("lostTemple.lostTempleLogic")
 local BattleLogic = require("battle.BattleLogic")
 local HeroSkinLogic = require("present.HeroSkinLogic")
+local TreasureChestLogic = require("treasurechest.TreasureChestLogic")
 
 cmd 		= {}
 
@@ -383,6 +384,14 @@ function cmd.UseSkinItem(data, human, nMoney)
 
     HeroSkinLogic.SendSkinInfoByMoney(human, nMoney)
 end
+
+function cmd.treasurechestadd(data, human)
+    if 0 >= data.left then
+        return
+    end
+
+    TreasureChestLogic.TreasureChestLogic_AddItem(human, data.id, data.cnt)
+end
 -----------------------------------------------------------------------------
 
 -- 仅使用道具,不扣道具

+ 1 - 0
script/module/chat/Gm.lua

@@ -170,6 +170,7 @@ function d3.itemadd(human,val)
 	else
 		-- 分开是因为 常规道具 给不了
 		local cnt= tonumber(string.sub(val,pos+1,#val))
+		print("[itemadd] id, cnt = ", id, cnt)
 		require("bag.BagLogic").addItem(human,id,cnt,"gm")
 	end
 	

+ 0 - 2
script/module/combat/CombatLogic.lua

@@ -445,10 +445,8 @@ function createHeroObjByHeroGrid(human, heroGrid)
 		BeSkill.setBeSkill(obj, attrConfig)
 	end
     if heroGrid.isLostTemple then
-		--print("[createHeroObjByHeroGrid] 进入的这里 111\n")
         obj.attrs = Util.copyTable(LostTempleCombatLogic.getHeroAttrs(human, heroGrid.bagIndex))
     else
-		--print("[createHeroObjByHeroGrid] 进入的这里 222\n")
         obj.attrs = Util.copyTable(ObjHuman.getHeroAttrs(human, obj.bagIndex))
 		--obj.attrs = Util.copyTable(RoleAttr.calcHeroGrid(obj, obj.bagIndex, human))
     end

+ 41 - 3
script/module/treasurechest/TreasureChestLogic.lua

@@ -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