Sfoglia il codice sorgente

英雄酒馆增加奖励功能

gitxsm 8 mesi fa
parent
commit
69030e7990

+ 4 - 4
script/common/ProtoID.lua

@@ -1606,10 +1606,10 @@ _ENV[1647]="CG_FUWEN_RESET_LOCK"
 
 _ENV[1648]="CG_CYCLMAKEFOOD_GET_5STARfOODLIST"
 _ENV[1649]="GC_CYCLMAKEFOOD_GET_5STARfOODLIST"
--- _ENV[1650]="CG_HEROPUB_REWARD_QUERY"
--- _ENV[1651]="GC_HEROPUB_REWARD_QUERY"
--- _ENV[1652]="CG_HEROPUB_REWARD_GET"
+_ENV[1650]="CG_HEROPUB_REWARD_QUERY"
+_ENV[1651]="GC_HEROPUB_REWARD_QUERY"
+_ENV[1652]="CG_HEROPUB_REWARD_GET"
 
 _ENV[1653]="CG_HUNAGJINGTOWER_ONECLICK_SAPDANG"
 
--- _ENV[1654]="GC_HEROPUB_BOX_REDDOT"
+_ENV[1654]="GC_HEROPUB_BOX_REDDOT"

+ 5 - 3
script/module/bag/BagLogic.lua

@@ -88,7 +88,7 @@ function addItemList(human,  list, logType, noSend)
 		-- 额外道具的处理
 		for _, extraItem in ipairs(extraItemList) do
 			table.insert(list, extraItem)
-			addItem(human, extraItem[1], extraItem[2], logType, noSend, extraItem[3])
+			addItem(human, extraItem[1], extraItem[2], logType, noSend, item[3])
 		end
 
 	else
@@ -111,7 +111,9 @@ function addItemList(human,  list, logType, noSend)
 		end
 
 		if newList then
-			list = newList
+			for itemId, itemInfo in pairs(newList) do
+				list[itemId] = itemInfo
+			end
 		end
 	end
 
@@ -405,7 +407,7 @@ function sendItemGetList2(human, list, logStr)
 		-- 	--Grid.makeItem(msgRet.list[cnt], itemID, itemCnt)
 		-- 	Grid.makeItem(msgRet.list[cnt], itemID, itemCnt, nil,nil,nil, Grid.getOpflagAtBag(itemID))
         -- end
-
+		sourceId = 0
 		local itemNum = 0
 		if type(itemCnt) == "table" then
 			itemNum = itemCnt[2]

+ 8 - 0
script/module/hero/Handler.lua

@@ -258,4 +258,12 @@ end
 
 function CG_HEROPUB_ACTIVATE(human,msg)
     HeroPubLogic.ActivatePubAtrr(human, msg.index)
+end
+
+function CG_HEROPUB_REWARD_QUERY(human,msg)
+    HeroPubLogic.RewardQuery(human)
+end
+
+function CG_HEROPUB_REWARD_GET(human,msg)
+    HeroPubLogic.RewardGet(human)
 end

+ 165 - 33
script/module/hero/HeroPubLogic.lua

@@ -6,7 +6,8 @@
     human.db.heroPubData = nil 
     -- {
     --     activateIdxList = { [idx] = 1, [idx2] = 1,},--当前激活加成属性在配置中的索引列表
-    --     heroList = {}
+    --     heroList = {},
+    --     rewardGetList = {}   -- 酒馆奖励领取列表
     -- }
 ]=]--
 
@@ -22,6 +23,8 @@ local HeroPubCfg = require("excel.heroPub").pub
 local HeroGrid = require("hero.HeroGrid")
 local RoleSystemLogic = require("roleSystem.RoleSystemLogic")
 local RoleSystemDefine = require("roleSystem.RoleSystemDefine")
+local Grid = require("bag.Grid")
+local BagLogic = require("bag.BagLogic")
 
 
 HERO_OP_UPSTAR      = 1     -- 升星/合成
@@ -29,11 +32,18 @@ HERO_OP_DEL         = 2     -- 删除
 HERO_OP_RETURN      = 3     -- 回退
 HERO_OP_ADD         = 4     -- 获得
 
-
+local LOGTAG = "HeroPub"
 
 local function initPubData(human)
-    human.db.heroPubData = {}
-    human.db.heroPubData.activateIdxList = {}
+    human.db.heroPubData = human.db.heroPubData or {}
+    human.db.heroPubData.activateIdxList = human.db.heroPubData.activateIdxList or {}
+    human.db.heroPubData.rewardGetList = human.db.heroPubData.rewardGetList or {}
+
+    -- 新增
+    -- if not human.db.heroPubData.rewardGetList then
+    --     human.db.heroPubData.rewardGetList = {}
+    -- end
+
 end
 
 local function getPubData(human)
@@ -54,6 +64,11 @@ local function updatePubData(human, opType, activateIdx)
     end
 end
 
+local function updateRewardGetList(human, rewardIdx)
+    local heroPubData = getPubData(human)
+    heroPubData.rewardGetList[rewardIdx] = '1'
+end
+
 
 
 -- 数据格式转换
@@ -171,6 +186,34 @@ local function redDotCheck(human)
     RoleSystemLogic.onDot(human, RoleSystemDefine.ROLE_SYS_ID_304)
 end
 
+-- 获取宝箱红点状态
+local function getBoxRedDot(human)
+    local heroPubData = getPubData(human)
+
+    local nowMaxStar = calcAllHeroStar(human.pubHeroList)
+    local rewardGetList = heroPubData and heroPubData.rewardGetList or {}
+
+    for idx, starCfg in ipairs(HeroPubCfg) do
+        if nowMaxStar >= starCfg.activateStar and not rewardGetList[idx] then
+            return true
+        end
+    end
+
+    return false
+end
+
+
+-- 更新酒馆的宝箱红点
+local function updateBoxRedDot(human)
+    local msgRet = Msg.gc.GC_HEROPUB_BOX_REDDOT
+
+    msgRet.redDotState = 0
+    if getBoxRedDot(human) then
+        msgRet.redDotState = 1
+    end
+
+    Msg.send(msgRet, human.fd)
+end
 
 
 -- 英雄升星/合成时的处理函数
@@ -239,7 +282,6 @@ end
 
 
 
-
 local function respondHeroInfo(human)
     local msgMax = 20
     local msgRet = Msg.gc.GC_HEROPUB_HERO_QUERY
@@ -262,7 +304,6 @@ local function respondHeroInfo(human)
             local heroGrid = HeroLogic.getHeroGridByUuid(human, heroInfoTbl[i].uuid)
             HeroGrid.makeHeroSimple(net, heroGrid, nil, human)
 
-
             msgHeroList[len].heroId = net.id
             msgHeroList[len].heroName = net.name
             msgHeroList[len].heroStar = net.star
@@ -285,9 +326,11 @@ local function respondHeroInfo(human)
             end
         end
 
-        msgRet.start = startTag
-        msgRet.isEnd = 1
-        Msg.send(msgRet, human.fd)
+        if len > 0 then
+            msgRet.start = startTag
+            msgRet.isEnd = 1
+            Msg.send(msgRet, human.fd)
+        end
     end
 end
 
@@ -324,10 +367,10 @@ local function respndAttrInfo(human)
         if len >= msgMax then
             msgRet.start = startTag
             msgRet.isEnd = 0
+
             if maxLen - len <= 0 then
                 msgRet.isEnd = 1
             end
-
             Msg.send(msgRet, human.fd)
 
             len = 0
@@ -336,29 +379,32 @@ local function respndAttrInfo(human)
         end
     end
 
-    msgRet.start = startTag
-    msgRet.isEnd = 1
-    Msg.send(msgRet, human.fd)
+    if len > 0 then
+        msgRet.start = startTag
+        msgRet.isEnd = 1
+        Msg.send(msgRet, human.fd)
+    end
+
 end
 
-local function respondUpdateSingleHero(human, updateHerouuid, delHeroId)
-    local msgRet = Msg.gc.GC_HEROPUB_UPDATE_HERO
+-- local function respondUpdateSingleHero(human, updateHerouuid, delHeroId)
+--     local msgRet = Msg.gc.GC_HEROPUB_UPDATE_HERO
 
-    local net = { relic = {}, gemData = {}, general = {}}
-    if updateHerouuid then
-        local heroGrid = HeroLogic.getHeroGridByUuid(human, updateHerouuid)
-        HeroGrid.makeHeroSimple(net, heroGrid, nil, human)
-    end
+--     local net = { relic = {}, gemData = {}, general = {}}
+--     if updateHerouuid then
+--         local heroGrid = HeroLogic.getHeroGridByUuid(human, updateHerouuid)
+--         HeroGrid.makeHeroSimple(net, heroGrid, nil, human)
+--     end
 
-    msgRet.updateHeroInfo.heroId = net.id or delHeroId
-    msgRet.updateHeroInfo.heroName = net.name or ""
-    msgRet.updateHeroInfo.heroStar = net.star or 0
-    msgRet.updateHeroInfo.heroCamp = net.camp or 0
-    msgRet.updateHeroInfo.heroBody = net.body or 0
-    msgRet.updateHeroInfo.heroGrade = net.grade or 0
+--     msgRet.updateHeroInfo.heroId = net.id or delHeroId
+--     msgRet.updateHeroInfo.heroName = net.name or ""
+--     msgRet.updateHeroInfo.heroStar = net.star or 0
+--     msgRet.updateHeroInfo.heroCamp = net.camp or 0
+--     msgRet.updateHeroInfo.heroBody = net.body or 0
+--     msgRet.updateHeroInfo.heroGrade = net.grade or 0
 
-    Msg.send(msgRet, human.fd)
-end
+--     Msg.send(msgRet, human.fd)
+-- end
 
 
 
@@ -419,6 +465,7 @@ function UpdateHero(human, opType, heroId, herouuid)
 
         updatePubAttr(human)
 
+        updateBoxRedDot(human)
         -- respondUpdateSingleHero(human, updateHerouuid, delHeroId)
 
         -- respndAttrInfo(human)
@@ -432,7 +479,7 @@ function isDot(human)
     local nowMaxAttrIdx = getPubAttrIdx(human.pubHeroList)
 
 
-    if not heroPubData  then
+    if not heroPubData then
         if nowMaxAttrIdx <= 0 then
             return false
         else
@@ -444,6 +491,10 @@ function isDot(human)
         return true
     end
 
+    if getBoxRedDot(human) then
+        return true
+    end
+
     return false
 end
 
@@ -479,11 +530,11 @@ end
 
 
 
-
 -- 查询
 function PubQuery(human)
     respondHeroInfo(human)
     respndAttrInfo(human)
+    updateBoxRedDot(human)
 end
 
 --激活属性
@@ -494,9 +545,7 @@ function ActivatePubAtrr(human, targetIdx)
         return Broadcast.sendErr(human, Lang.HEROPUB_STAR_NOT_ENOUGH)
     end
 
-
     local heroPubData = getPubData(human)
-
     if heroPubData and heroPubData.activateIdxList and heroPubData.activateIdxList[targetIdx] then
         return Broadcast.sendErr(human, Lang.BINGSHU_LEARN_ERR_HAD)
     end
@@ -507,11 +556,94 @@ function ActivatePubAtrr(human, targetIdx)
     msgRet.index = targetIdx
     Msg.send(msgRet, human.fd)
 
-
     --更新战力
     updatePower(human)
 
     --红点检测
     redDotCheck(human)
 
+end
+
+-- 奖励查询
+function RewardQuery(human)
+    local msgMax = 10
+    local startTag, len = 1, 0
+    local maxLen = #HeroPubCfg
+    local heroPubData = getPubData(human)
+    local rewardGetList = heroPubData and heroPubData.rewardGetList
+    local nowMaxStar = calcAllHeroStar(human.pubHeroList)
+
+    local msgRet = Msg.gc.GC_HEROPUB_REWARD_QUERY
+    msgRet.nowStar = nowMaxStar
+    msgRet.isEnd = 0
+    local rewardList = msgRet.rewardList
+
+    for idx, starCfg in ipairs(HeroPubCfg) do
+        len = len + 1
+        rewardList[len].reallyIdx = idx
+        rewardList[len].condStar = starCfg.activateStar
+
+        rewardList[len].state = 0
+        if nowMaxStar >= starCfg.activateStar then
+            rewardList[len].state = 1
+        end
+        if rewardGetList and rewardGetList[idx] then
+            rewardList[len].state = 2
+        end
+
+        local itemArray = rewardList[len].itemArray
+        for k, itemCfg in ipairs(starCfg.reward) do
+            itemArray[0] = k
+            Grid.makeItem(itemArray[k], itemCfg[1], itemCfg[2])
+        end
+
+        if len >= msgMax then
+            rewardList[0] = len
+            msgRet.start = startTag
+
+            maxLen = maxLen - len
+            if maxLen <= 0 then
+                msgRet.isEnd = 1
+            end
+            Msg.send(msgRet, human.fd)
+
+            len = 0
+            startTag = 0
+        end
+    end
+
+    if len > 0 then
+        rewardList[0] = len
+        msgRet.start = startTag
+        msgRet.isEnd = 1
+        Msg.send(msgRet, human.fd)
+    end
+end
+
+-- 奖励领取
+function RewardGet(human)
+    local heroPubData = getPubData(human)
+    if not heroPubData or not heroPubData.rewardGetList then
+        initPubData(human)
+        heroPubData = getPubData(human)
+    end
+    local rewardGetList = heroPubData.rewardGetList
+    local nowMaxStar = calcAllHeroStar(human.pubHeroList)
+
+    local itemList = {}
+    for idx, starCfg in ipairs(HeroPubCfg) do
+        if nowMaxStar >= starCfg.activateStar and not rewardGetList[idx] then
+            for _, itemCfg in ipairs(starCfg.reward) do
+                local itemId = itemCfg[1]
+                itemList[itemId] = (itemList[itemId] or 0) + itemCfg[2]
+            end
+
+            updateRewardGetList(human, idx)
+        end
+    end
+
+    BagLogic.addItemList(human, itemList, LOGTAG)
+    RewardQuery(human)
+    redDotCheck(human)
+    updateBoxRedDot(human)
 end

+ 28 - 0
script/module/hero/Proto.lua

@@ -868,6 +868,15 @@ PUB_ATTR_INFO = {
 	{"index",			1,		"int"},     	-- 真实索引
 }
 
+PUB_REWAR_INFO = {
+	{"state",			1,		"byte"},     	-- 状态,0-不可领, 1-可领, 2-已领取
+	{"reallyIdx",		1,		"int"},     	-- 真实索引
+	{"condStar",		1,		"short"},     	-- 领取需要星级
+	{"itemArray",		4,		ItemData}, 		-- 奖励
+}
+
+
+
 --查询
 CG_HEROPUB_QUERY = {}
 
@@ -902,4 +911,23 @@ GC_HEROPUB_ACTIVATE = {
 	{"index",			1,		"byte"}, 			-- 当前激活的索引
 }
 
+--奖励查询
+CG_HEROPUB_REWARD_QUERY = {
+}
+
+GC_HEROPUB_REWARD_QUERY = {
+	{"start",			1,		"byte"},     		-- 分段时,第段次是1,后面是0
+	{"isEnd",			1,		"byte"},     		-- 分段协发完标识,0-未发完, 1-已发完
+	{"nowStar",			1,		"int"},				-- 当前总星级
+	{"rewardList",		10,		PUB_REWAR_INFO}, 	-- 奖励列表
+}
+
+-- 领奖
+CG_HEROPUB_REWARD_GET = {
+}
+
+-- 宝箱红点
+GC_HEROPUB_BOX_REDDOT = {
+	{"redDotState",			1,		"byte"},     		-- 0- 没有红点, 1-有红点
+}
 ------------------------------------------------------------------------------------