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