添加重复穿戴的宝器的处理,重复穿戴的自动卸下,并自动穿戴在战斗力最大的人身上
parent
b50602d94c
commit
9ff73bfa4c
|
@ -3065,4 +3065,123 @@ function this.ResetHeroChangeId(dynamicloadId,changeId)
|
|||
end
|
||||
end
|
||||
|
||||
-- 检测所有重复穿戴的宝器并卸下
|
||||
function this.CheckRepeatTreasure(func)
|
||||
this._TreasureToTarget = {}
|
||||
this._WearCount = {}
|
||||
this._NoTreasure = {}
|
||||
this._CheckIndex = 0
|
||||
for _, heroData in ipairs(this.heroDataLists) do
|
||||
if heroData and heroData.jewels and #heroData.jewels > 0 then
|
||||
for _, jId in ipairs(heroData.jewels) do
|
||||
local jewel = EquipTreasureManager.GetSingleTreasureByIdDyn(jId)
|
||||
if jewel then
|
||||
-- 重复穿戴
|
||||
if not this._WearCount[jId] then
|
||||
this._WearCount[jId] = 0
|
||||
end
|
||||
this._WearCount[jId] = this._WearCount[jId] + 1
|
||||
|
||||
LogRed(jId.."|"..this._WearCount[jId])
|
||||
-- 判断最终穿戴的人(根据战斗力判断)
|
||||
if not this._TreasureToTarget[jId] then
|
||||
this._TreasureToTarget[jId] = {id = heroData.dynamicId, power = heroData.warPower}
|
||||
end
|
||||
if this._TreasureToTarget[jId].power < heroData.warPower then
|
||||
this._TreasureToTarget[jId] = {id = heroData.dynamicId, power = heroData.warPower}
|
||||
end
|
||||
else
|
||||
-- 没有这件装备
|
||||
this._NoTreasure[jId] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 开始卸下
|
||||
this.UnloadRepeatTreasure(function()
|
||||
-- 开始装备
|
||||
this.EquipRepeatTreasure(func)
|
||||
end)
|
||||
end
|
||||
|
||||
-- 卸下重复和没有的装备
|
||||
function this.UnloadRepeatTreasure(func)
|
||||
this._CheckIndex = this._CheckIndex + 1
|
||||
if this._CheckIndex > #this.heroDataLists then
|
||||
if func then func() end
|
||||
return
|
||||
end
|
||||
-- 计算需要卸载的装备
|
||||
local unloadList = {}
|
||||
local heroData = this.heroDataLists[this._CheckIndex]
|
||||
if heroData and heroData.jewels and #heroData.jewels > 0 then
|
||||
for _, jId in ipairs(heroData.jewels) do
|
||||
if this._WearCount[jId] > 1 -- 重复
|
||||
or this._NoTreasure[jId] == 1 then -- 没有这件装备
|
||||
table.insert(unloadList, jId)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 卸载
|
||||
if #unloadList > 0 then
|
||||
NetManager.EquipUnLoadOptRequest(heroData.dynamicId, unloadList, 2, function ()
|
||||
for i = 1, #unloadList do
|
||||
EquipTreasureManager.SetTreasureUpOrDown(unloadList[i], "")
|
||||
this.RemoveTreasure(heroData.dynamicId, unloadList[i])
|
||||
end
|
||||
this.UnloadRepeatTreasure(func)
|
||||
end)
|
||||
else
|
||||
this.UnloadRepeatTreasure(func)
|
||||
end
|
||||
end
|
||||
|
||||
-- 重复穿戴的装备应该不会太多,所以这里直接同步穿上
|
||||
function this.EquipRepeatTreasure(func)
|
||||
local _EquipIndex = 0
|
||||
local _MaxIndex = 0
|
||||
for jId, heroData in pairs(this._TreasureToTarget) do
|
||||
if this._WearCount[jId] > 1 then -- 重复
|
||||
_MaxIndex = _MaxIndex + 1
|
||||
NetManager.EquipWearRequest(heroData.id, {jId}, 2, function ()
|
||||
_EquipIndex = _EquipIndex + 1
|
||||
EquipTreasureManager.SetTreasureUpOrDown(jId, heroData.id)
|
||||
this.WearTreasure(heroData.id, jId)
|
||||
--对比战力并更新战力值 播放战力变更动画
|
||||
HeroManager.CompareWarPower(heroData.id)
|
||||
if _EquipIndex >= _MaxIndex then
|
||||
if func then func() end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
-- 没有直接结束
|
||||
if _MaxIndex == 0 then
|
||||
if func then func() end
|
||||
end
|
||||
end
|
||||
|
||||
function this.WearTreasure(dId, jId, index)
|
||||
if index and index >= 1 and index <= 2 then
|
||||
table.remove(heroDatas[dId].jewels, index)
|
||||
table.insert(heroDatas[dId].jewels, index, jId)
|
||||
return
|
||||
end
|
||||
if #heroDatas[dId].jewels < 2 then
|
||||
table.insert(heroDatas[dId].jewels, jId)
|
||||
end
|
||||
end
|
||||
|
||||
function this.RemoveTreasure(dId, jId)
|
||||
local removeIndex
|
||||
for i = 1, #heroDatas[dId].jewels do
|
||||
if heroDatas[dId].jewels[i] == jId then
|
||||
removeIndex = i
|
||||
end
|
||||
end
|
||||
if removeIndex then
|
||||
table.remove(heroDatas[dId].jewels, removeIndex)
|
||||
end
|
||||
end
|
||||
|
||||
return this
|
|
@ -468,7 +468,8 @@ function this.ExecuteLoading()
|
|||
--[[[31] =]] function() NetManager.RankFirstRequest({3,22,20,4,21},{0,0,0,0,20},LoadingPanel.OnStep) end, -- 排行榜数据
|
||||
--[[[32] =]] function() NetManager.GetSituationInfoRequest(LoadingPanel.OnStep) end,
|
||||
--[[[33] =]] function() NetManager.RefreshTimeSLRequest(LoadingPanel.OnStep) end,
|
||||
--[[[34] =]] function() -- 登录请求最终接口,所有请求放在此接口之前
|
||||
--[[[34] =]] function() HeroManager.CheckRepeatTreasure(LoadingPanel.OnStep) end,
|
||||
--[[[35] =]] function() -- 登录请求最终接口,所有请求放在此接口之前
|
||||
if AppConst.isGuide then
|
||||
if GuideManager.GetCurId(GuideType.Force) == 1 and PlayerManager.nickName == tostring(PlayerManager.uid) then
|
||||
--创号阶段先进入剧情对话,进入假战斗,然后对话起名,最后进入主界面
|
||||
|
|
|
@ -56,7 +56,7 @@ function this.GetTreasureDataByPos(_pos, _idDyn, PropertyName)
|
|||
local equips = {}
|
||||
for i, v in pairs(allTreasures) do
|
||||
if v.equipType == _pos - 4 then
|
||||
if (v.upHeroDid == "") and v.race == PropertyName then
|
||||
if (v.upHeroDid == "" or v.upHeroDid == 0) and v.race == PropertyName then
|
||||
table.insert(equips, v)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue