修复一些bug

This commit is contained in:
xiekaidong 2023-04-24 20:18:17 +08:00
parent 4bda42441f
commit 6c9483b1aa
7 changed files with 51 additions and 39 deletions

View File

@ -1414,7 +1414,6 @@ function BattleController:getRandomSkillList(getCount)
return table.remove(fixedList, 1)
end
getCount = getCount or BattleConst.SKILL_SELECT_COUNT
local result = {}
local cfg = ConfigManager:getConfig("skill_rogue")
@ -1424,10 +1423,13 @@ function BattleController:getRandomSkillList(getCount)
local count = 0
local newSkillPool = {}
local skillWeight = {}
for _, skillId in ipairs(skillPool) do
for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
if not self.battleData:isUnlockedSkillElementType(elementType) then
local skillEntity = self.battleData:getSkillEntityByElement(elementType)
if skillEntity then
local skillId = skillEntity:getUnlockId()
if skillId and not map[skillId] then
local skillCfg = cfg[skillId]
if skillCfg and (not skillCfg.limit_times or self.battleData:getSkillCount(skillId) < skillCfg.limit_times) then
if not map[skillId] then
table.insert(newSkillPool, skillId)
table.insert(skillWeight, skillCfg.weight)
count = count + 1
@ -1435,6 +1437,22 @@ function BattleController:getRandomSkillList(getCount)
end
end
end
end
if count >= 3 then -- 如果未解锁的技能大于等于3则直接返回三个解锁技能
for i = 1, 3 do
local index = GFunc.getRandomIndex(skillWeight)
local skillId = table.remove(newSkillPool, index)
table.remove(skillWeight, index)
count = count - 1
table.insert(result, skillId)
if count <= 0 then
break
end
end
return table.shuffle(result)
end
for elementType, list in pairs(skillPool) do
if self.battleData:isUnlockedSkillElementType(elementType) then
@ -1449,18 +1467,6 @@ function BattleController:getRandomSkillList(getCount)
end
end
end
else
local skillEntity = self.battleData:getSkillEntityByElement(elementType)
if skillEntity then
local skillId = skillEntity:getUnlockId()
if skillId and not map[skillId] then
local skillCfg = cfg[skillId]
table.insert(newSkillPool, skillId)
table.insert(skillWeight, skillCfg.weight)
count = count + 1
map[skillId] = true
end
end
end
end

View File

@ -10,17 +10,7 @@ function HeroManager:upgradeHero(heroId, heroEntity)
return
end
local materials = heroEntity:getLvUpMaterials()
if not materials or not materials[2] then
return
end
local fragmentCost = materials[1] or 0
if not GFunc.checkCost(heroEntity:getFragmentId(), fragmentCost, true) then
return
end
if not heroEntity:canLvUp() then
if not heroEntity:canLvUp(true) then
return
end

View File

@ -71,12 +71,12 @@ function ServerHeroData:tryUnlockHeroByChapterId(maxChapterId)
end
end
function ServerHeroData:upgradeHero(heroId)
function ServerHeroData:upgradeHero(heroId, lv)
local idStr = tostring(heroId)
if not self.data.heroes[idStr] then
self:addHero(heroId, 0)
end
self.data.heroes[idStr].lv = self.data.heroes[idStr].lv + 1
self.data.heroes[idStr].lv = lv
end
return ServerHeroData

View File

@ -50,7 +50,7 @@ function ServerHeroManager:onUpgradeHero(params, callback)
}
}
ServerGameData.HeroData:upgradeHero(heroId)
ServerGameData.HeroData:upgradeHero(heroId, lv)
result.heroId = heroId
result.lv = lv
result.costs = ServerGameData:addCosts(costs)

View File

@ -62,6 +62,8 @@ function HeroComp:init()
self.heroBgSpineObj[index]:playAnim("idle", true, false)
end
end
self.uiMap["hero_ui.top_bg.title_bg_img.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_BTN_2))
end
function HeroComp:refresh()
@ -162,7 +164,7 @@ function HeroComp:onClickHero(cell, heroId)
local entity = DataManager.HeroData:getHeroById(heroId)
if entity then
if entity:isActived() then
if entity:isActived() and not DataManager.FormationData:heroInFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, heroId) then
local targetPos = cell:getBaseObject():getTransform().position
local sPoint = UIManager:getUICameraComponent():WorldToScreenPoint(targetPos)
targetPos = CS.BF.Utils.RectTransformScreenPointToLocalPointInRectangle(self.content:getTransform(), sPoint.x, sPoint.y, UIManager:getUICameraComponent())

View File

@ -36,6 +36,20 @@ function FormationData:upHeroToFormation(formationType, matchType, heroId)
self:setDirty()
end
function FormationData:heroInFormation(formationType, heroId)
local formation = self:getFormation(formationType)
if not formation then
return false
end
for matchType, id in pairs(formation) do
if id == heroId then
return true
end
end
return false
end
function FormationData:setDirty()
self.data.dirty = not self.data.dirty
end

View File

@ -138,7 +138,7 @@ function HeroEntity:getMaxLv()
return self.maxLv
end
function HeroEntity:canLvUp()
function HeroEntity:canLvUp(showToast)
if self:isMaxLv() then
return false
end
@ -149,11 +149,11 @@ function HeroEntity:canLvUp()
end
local fragmentCost = cost[1] or 0
if not GFunc.checkCost(self:getFragmentId(), fragmentCost, false) then
if not GFunc.checkCost(self:getFragmentId(), fragmentCost, showToast) then
return false
end
local goldCost = cost[2] or 0
if not GFunc.checkCost(GConst.ItemConst.ITEM_ID_GOLD, goldCost, false) then
if not GFunc.checkCost(GConst.ItemConst.ITEM_ID_GOLD, goldCost, showToast) then
return false
end