boxAdapt.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. -- 箱子配置
  2. local baseAdapt = require "base.baseAdapt"
  3. local root = {}
  4. ----------------------------------------
  5. -- 盲盒
  6. ----------------------------------------
  7. -- 箱子物品列表
  8. function root:blind_get_box_item_list(boxId)
  9. local confList = {}
  10. local conf = baseAdapt:getConfig("BlindBoxAwardConfig")
  11. for _, v in ipairs(conf) do
  12. if v.boxId == boxId then
  13. table.insert(confList, table.copy(v))
  14. end
  15. end
  16. return confList
  17. end
  18. -- 获取箱子信息
  19. function root:blind_get_box_key_info(boxId, key)
  20. local conf = baseAdapt:getConfig("BlindBoxConfig")
  21. for _, v in ipairs(conf) do
  22. if v.boxId == boxId then
  23. if is_empty(key) then
  24. return v
  25. else
  26. return v[key]
  27. end
  28. end
  29. end
  30. end
  31. ----------------------------------------
  32. -- 战斗
  33. ----------------------------------------
  34. -- 获取箱子配置
  35. function root:battle_get_box_key_info(boxId, key)
  36. if is_empty(boxId) then
  37. return
  38. end
  39. local conf = baseAdapt:getConfig("BattleBoxConfig")
  40. for _, v in ipairs(conf) do
  41. if v.boxId == boxId then
  42. if is_empty(key) then
  43. return v
  44. else
  45. return v[key]
  46. end
  47. end
  48. end
  49. end
  50. -- 参加战斗消耗
  51. function root:battle_get_box_price(boxIdList)
  52. if is_empty(boxIdList) then
  53. return 0
  54. end
  55. local price = 0
  56. for _, v in ipairs(boxIdList) do
  57. local boxPrice = self:battle_get_box_key_info(v, "price")
  58. if not is_empty(boxPrice) then
  59. price = price + boxPrice
  60. end
  61. end
  62. return price
  63. end
  64. -- 检查战斗箱子
  65. function root:battle_is_box_list_valid(boxIdList)
  66. if is_empty(boxIdList) then
  67. return false
  68. end
  69. for _, v in ipairs(boxIdList) do
  70. local conf = self:battle_get_box_key_info(v)
  71. if is_empty(conf) or is_empty(conf.price) then
  72. return false
  73. end
  74. end
  75. return true
  76. end
  77. return root