diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index e3af0842..e4a4a498 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -46,6 +46,7 @@ BattleConst.RECOVER_HP_COUNT = 3 BattleConst.RECOVER_HP_INTERVAL = 0.2 BattleConst.RECOVER_HP_PERCENT = 333 BattleConst.EFFECT_NUMBER_DELAY = 0.2 +BattleConst.MAX_CACHE_SKILL_COUNT = 3 BattleConst.BATTLE_ROUND_STEP = { WAIT_BEGIN = 0, -- 等待开始 diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index a842a22a..4d6d2512 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -46,6 +46,7 @@ function BattleUI:_display() self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"] self.boardCacheNode:setVisible(false) self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"] + self.boardCacheBox:setAnchoredPositionX(DEFAULT_X) self.battleRoot = uiMap["battle_ui.battle_root"] self:initBg() self:initSkill() diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 94662af2..9887094e 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -418,9 +418,29 @@ end function BattleData:cacheBoardSkill() self.cacheSkillList = {} self.cacheSkillCount = 0 + local list + local count = 0 for posId, entity in pairs(self:getGridEnties()) do if entity:getSkillId() then - table.insert(self.cacheSkillList, {skillId = entity:getSkillId(), posId = posId}) + if not list then + list = {} + end + table.insert(list, {skillId = entity:getSkillId(), posId = posId}) + count = count + 1 + end + end + + if list then + if count > BattleConst.MAX_CACHE_SKILL_COUNT then + count = BattleConst.MAX_CACHE_SKILL_COUNT + end + + for i = 1, count do + if not list[1] then + break + end + local info = table.remove(list, math.random(1, #list)) + table.insert(self.cacheSkillList, info) self.cacheSkillCount = self.cacheSkillCount + 1 end end