1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- -- 箱子配置
- 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
- 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
- return root
|