[玉虚论道]======保存队伍时添加相同英雄检测

dev_chengFeng
wangzhenxing 2021-11-22 10:18:39 +08:00
parent 8c10c104d8
commit f10d6ee2a1
2 changed files with 18 additions and 1 deletions

View File

@ -314,6 +314,8 @@ function this.On_Btn2_Click()
--检测三个队伍是否有重复英雄
local len = 0
local upHeros={}
local isSame=false
for key, value in pairs(allHeros) do
local newHero={}
newHero.heroId=value.Id
@ -325,13 +327,21 @@ function this.On_Btn2_Click()
elseif value.index==2003 then
table.insert(threeTeam,newHero)
end
if BattleUtil.ChecklistIsContainValue(upHeros,value.Id) then
isSame=true
else
table.insert(upHeros,value.Id)
end
len = len + 1
end
if len <= 0 then
PopupTipPanel.ShowTip(string.format(Language[10699], 1))
return
end
if isSame then
PopupTipPanel.ShowTip("编队中有相同神将")
return
end
table.insert(allTeam,oneTeam)
table.insert(allTeam,twoTeam)
table.insert(allTeam,threeTeam)

View File

@ -101,9 +101,16 @@ local function OnEndDrag(self, Pointgo, data)
self.curFormation[2000 + currIndex] = self.curFormation[2000 + targetIndex]
self.curFormation[2000 + targetIndex] = tempFormation
-- 保存
local upHeros={}
for i = 1, 3 do
local heros = {}
for _, hero in ipairs(self.curFormation[i+2000].teamHeroInfos) do
if BattleUtil.ChecklistIsContainValue(upHeros,hero.heroId) then
PopupTipPanel.ShowTip("编队中有相同神将!!")
return
else
table.insert(upHeros,hero.heroId)
end
table.insert(heros, {heroId = hero.heroId, position = hero.position})
end
FormationManager.SaveFormation(i+2000, heros,