From 0d2e914210d94989f56117364110df29b648fd9c Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Thu, 13 Apr 2023 21:30:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=96=97rogue=E6=8A=80=E8=83=BD?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E4=B8=8A=E9=98=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/userdata/battle/battle_data.lua | 38 ++++++++++++++----------- lua/app/userdata/hero/hero_entity.lua | 14 +++++++++ 2 files changed, 36 insertions(+), 16 deletions(-) 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