RoleCount.lua 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. RoleCount = {}
  2. RoleCount.__index = RoleCount
  3. local this = {}
  4. local CountResetType = {
  5. DAY = 1,
  6. LIFE = 2,
  7. WEEK = 3,
  8. MONTH = 4,
  9. }
  10. local BuyLimit = {
  11. NO = 0,
  12. DAY = 1,
  13. WEEK = 2,
  14. MONTH = 3,
  15. LIFE = 4,
  16. }
  17. CountType = {
  18. ITEM_USE_NUM = { CountType = 1001, CountResetType = CountResetType.DAY, Desc = "道具使用次数" },
  19. PARTNER_DISPATCH_FLUSH = { CountType = 1002, CountResetType = CountResetType.DAY, Desc = "伙伴-派遣" },
  20. DISPATCH_VIP_FREE_FLUSH = { CountType = 1003, CountResetType = CountResetType.DAY, Desc = "伙伴-派遣-VIP已使用免费次数" },
  21. ROLE_RECHARGE_DIAMOND_FIRST_COUNT = { CountType = 42, CountResetType = CountResetType.LIFE, Desc = "玩家首次购买钻石" },
  22. USER_ITEM_LIFE = { CountType = 1004, CountResetType = CountResetType.LIFE, Desc = "使用道具-整个周期" },
  23. FIRST_KILL_PERSONAL = { CountType = 1005, CountResetType = CountResetType.LIFE, Desc = "个人怪物首杀" },
  24. BUY_SHOP_MALL_DAY = { CountType = 2001, CountResetType = CountResetType.DAY, Desc = "购买道具次数-每日" },
  25. BUY_SHOP_MALL_WEEK = { CountType = 2002, CountResetType = CountResetType.WEEK, Desc = "购买道具次数-每星期" },
  26. BUY_SHOP_MALL_MONTH = { CountType = 2003, CountResetType = CountResetType.MONTH, Desc = "购买道具次数-每月" },
  27. BUY_SHOP_MALL_LIFE = { CountType = 2004, CountResetType = CountResetType.LIFE, Desc = "购买道具次数-永久" },
  28. ACTIVITY_LEFT_COUNT = { CountType = 3001, CountResetType = CountResetType.LIFE, Desc = "日常活动剩余次数-自定义刷新" },
  29. EQUIP_FEED_COUNT = { CountType = 1006, CountResetType = CountResetType.LIFE, Desc = "装备喂养的次数" }
  30. }
  31. --- func desc 重置指定次数的计数器
  32. ---@param actor any
  33. ---@param countType number 重置类型
  34. ---@param key any 重置键
  35. ---@param count number 重置次数, 负数表示重置所有次数
  36. ---@param time number 时间戳,毫秒值, 不传不更新时间
  37. function RoleCount.resetCount(actor, countType, key, count, time)
  38. for k, v in pairs(CountType) do
  39. local type = v.CountType
  40. if type == tonumber(countType) then
  41. resetrolecount(actor, type, key, count, time)
  42. return
  43. end
  44. end
  45. end
  46. --- func desc 重置指定职业商品终身限购计数器
  47. ---@param actor any
  48. function RoleCount.resetCareerLifeShopCount(actor, career)
  49. local configs = ConfigDataManager.getTable("cfg_shopMall", "limitbuy", BuyLimit.LIFE)
  50. for _, config in ipairs(configs) do
  51. local occupation = config.occupation
  52. if not string.isNullOrEmpty(occupation) then
  53. local info = string.toIntIntMap(occupation,"#","|")
  54. for baseCareer, level in pairs(info) do
  55. if baseCareer == tonumber(career) then
  56. resetrolecount(actor, CountType.BUY_SHOP_MALL_LIFE.CountType, config.id, -1, getbaseinfo(actor, "now"))
  57. end
  58. end
  59. end
  60. end
  61. end
  62. --- func desc
  63. ---@param actor any
  64. function countteset(actor)
  65. -- RoleCount.resetCount(actor, CountType.BUY_SHOP_MALL_LIFE.CountType, 1033018, 1)
  66. RoleCount.resetCareerLifeShopCount(actor, 1)
  67. end