--[[ Descripttion: version: Author: Neo,Huang Date: 2023-11-17 22:23:09 LastEditors: Neo,Huang LastEditTime: 2023-11-17 23:23:51 --]] -- 箱子配置 local baseAdapt = require "base.baseAdapt" local root = {} ---------------------------------------- -- 盲盒 ---------------------------------------- -- 箱子物品列表 function root:blind_get_box_item_list(boxId) local confList = {} local conf = baseAdapt:getConfig("BlindBoxAwardConfig") for _, v in ipairs(conf) do if v.boxId == boxId then table.insert(confList, table.copy(v)) end end return confList end -- 获取箱子信息 function root:blind_get_box_key_info(boxId, key) local conf = baseAdapt:getConfig("BlindBoxConfig") for _, v in ipairs(conf) do if v.boxId == boxId then if is_empty(key) then return v else return v[key] end end end end ---------------------------------------- -- 战斗 ---------------------------------------- -- 获取箱子配置 function root:battle_get_box_key_info(boxId, key) if is_empty(boxId) then return end local conf = baseAdapt:getConfig("BattleBoxConfig") for _, v in ipairs(conf) do if v.boxId == boxId then if is_empty(key) then return v else return v[key] end end end end -- 参加战斗消耗 function root:battle_get_box_price(boxIdList) if is_empty(boxIdList) then return 0 end local price = 0 for _, v in ipairs(boxIdList) do local boxPrice = self:battle_get_box_key_info(v, "price") if not is_empty(boxPrice) then price = price + boxPrice end end return price end -- 检查战斗箱子 function root:battle_is_box_list_valid(boxIdList) if is_empty(boxIdList) then return false end -- 数量 local minCount = self:battle_const("battle_box_min") local maxCount = self:battle_const("battle_box_max") if #boxIdList < minCount or #boxIdList > maxCount then return false end for _, v in ipairs(boxIdList) do local conf = self:battle_get_box_key_info(v) if is_empty(conf) or is_empty(conf.price) then return false end end return true end -- 常量 function root:battle_const(key) if is_empty(key) then return end local conf = baseAdapt:getConfig("BattleConstConfig") for _, v in ipairs(conf) do if v.main_key == key then return v.value end end end -- 箱子物品列表 function root:battle_get_box_item_list(boxId) local confList = {} local conf = baseAdapt:getConfig("BattleBoxAwardConfig") for _, v in ipairs(conf) do if v.boxId == boxId then table.insert(confList, table.copy(v)) end end return confList end return root