resAdapt.lua 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- 资源配置
  2. local baseAdapt = require "base.baseAdapt"
  3. local root = {}
  4. -- 获取指定id的资源配置
  5. function root:get_init_conf()
  6. return baseAdapt:getConfig("ResInitConfig")
  7. end
  8. -- 获取物品配置
  9. function root:get_item_conf_list()
  10. return baseAdapt:getConfig("ResItemConfig") or {}
  11. end
  12. -- 获取指定id的资源配置
  13. function root:get_item_conf(id)
  14. if not id then
  15. return nil
  16. end
  17. return baseAdapt:getOneConfig("ResItemConfig", id)
  18. end
  19. -- 获取物品名称
  20. function root:get_item_name(id)
  21. local item = self:get_item_conf(id)
  22. return item and item.name
  23. end
  24. -- 获取物品类型
  25. function root:get_item_type(id)
  26. local item = self:get_item_conf(id)
  27. return item and item.type
  28. end
  29. -- 判断是否是某个类型的资源id
  30. function root:is_type(id, resType)
  31. return self:get_item_type(id) == resType
  32. end
  33. -- 获取道具价值
  34. function root:get_item_price(id)
  35. local item = self:get_item_conf(id)
  36. return item and item.price
  37. end
  38. return root