diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 1b8b64b0..7505aa22 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -10,26 +10,32 @@ local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_bora local ATTR_TYPE = GConst.ATTR_TYPE local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR -function BattleData:init(skillIds, skillPool) +function BattleData:init() self:clear() self.atkTeam = self:initTeam(BattleConst.SIDE_ATK) self.defTeam = self:initTeam(BattleConst.SIDE_DEF) + self:initRogueSkills() +end - --- todo - skillIds = { - 10, 21, 30, 40, 50 - } - for _, skillId in ipairs(skillIds) do - local cfg = SKILL_HERO_CFG[skillId] - self.skillMap[cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId) - end - - ---- skillPool - self.skillPool = skillPool or {} - - for id, info in pairs(ConfigManager:getConfig("skill_rogue")) do - if not info.universal then - table.insert(self.skillPool, id) +function BattleData:initRogueSkills() + self.skillPool = {} + self.skillMap = {} + local skillmap = {} + local formation = DataManager.FormationData:getStageFormation() + for matchType, heroId in pairs(formation) do + if heroId > 0 then + local heroEntity = DataManager.HeroData:getHeroById(heroId) + if heroEntity then + local skillId = heroEntity:getActiveSkill() + local cfg = SKILL_HERO_CFG[skillId] + self.skillMap[cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId) + for _, id in ipairs(heroEntity:getActiveTogueSkills()) do + if not skillmap[id] then + table.insert(self.skillPool, id) + skillmap[id] = true + end + end + end end end end diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 45fda10c..db3368e5 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -209,4 +209,18 @@ function HeroEntity:getRogueSkillList() return self.rogueSkillList end +function HeroEntity:getActiveTogueSkills() + local list = {} + for i = 1, self:getActiveRogueCount() do + local id = self:getRogueSkillList()[i] + if id then + table.insert(list, id) + else + return + end + end + + return list +end + return HeroEntity \ No newline at end of file