From 6c9483b1aa40f9abf1ce497ee5f975d8bd180bbf Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 24 Apr 2023 20:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/controller/battle_controller.lua | 48 +++++++++++-------- lua/app/module/hero/hero_manager.lua | 12 +---- lua/app/server/data/server_hero_data.lua | 4 +- .../server/manager/server_hero_manager.lua | 2 +- lua/app/ui/hero/hero_comp.lua | 4 +- lua/app/userdata/formation/formation_data.lua | 14 ++++++ lua/app/userdata/hero/hero_entity.lua | 6 +-- 7 files changed, 51 insertions(+), 39 deletions(-) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 8fb4f732..ec8c53c8 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -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,18 +1423,37 @@ function BattleController:getRandomSkillList(getCount) local count = 0 local newSkillPool = {} local skillWeight = {} - for _, skillId in ipairs(skillPool) do - 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 - map[skillId] = true + 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] + table.insert(newSkillPool, skillId) + table.insert(skillWeight, skillCfg.weight) + count = count + 1 + map[skillId] = true + 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 for _, skillId in ipairs(list) do @@ -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 diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index ea72ee42..fcf5d1ce 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -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 diff --git a/lua/app/server/data/server_hero_data.lua b/lua/app/server/data/server_hero_data.lua index 9267b81e..0225bd65 100644 --- a/lua/app/server/data/server_hero_data.lua +++ b/lua/app/server/data/server_hero_data.lua @@ -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 \ No newline at end of file diff --git a/lua/app/server/manager/server_hero_manager.lua b/lua/app/server/manager/server_hero_manager.lua index 5cef9857..0d9ad23c 100644 --- a/lua/app/server/manager/server_hero_manager.lua +++ b/lua/app/server/manager/server_hero_manager.lua @@ -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) diff --git a/lua/app/ui/hero/hero_comp.lua b/lua/app/ui/hero/hero_comp.lua index d4881bd4..e0fbb248 100644 --- a/lua/app/ui/hero/hero_comp.lua +++ b/lua/app/ui/hero/hero_comp.lua @@ -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()) diff --git a/lua/app/userdata/formation/formation_data.lua b/lua/app/userdata/formation/formation_data.lua index 25a92700..c5a3cc99 100644 --- a/lua/app/userdata/formation/formation_data.lua +++ b/lua/app/userdata/formation/formation_data.lua @@ -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 diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 52edd2cb..71698934 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -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