源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 line
4.7 KiB

  1. CurrencyWishModel = CurrencyWishModel or BaseClass(BaseVo, true)
  2. local CurrencyWishModel = CurrencyWishModel
  3. function CurrencyWishModel:__init()
  4. CurrencyWishModel.Instance = self
  5. self:Reset()
  6. end
  7. function CurrencyWishModel:Reset()
  8. self.view_info = nil
  9. end
  10. function CurrencyWishModel:getInstance()
  11. if self.Instance == nil then
  12. self.Instance = CurrencyWishModel.New()
  13. end
  14. return self.Instance
  15. end
  16. function CurrencyWishModel:SetBaseInfo(vo)
  17. self.view_info = vo
  18. end
  19. function CurrencyWishModel:GetBaseInfo()
  20. return self.view_info
  21. end
  22. -- 获取祈愿总配置
  23. function CurrencyWishModel:GetCurrencyWishBaseConfig(currency_wish_type)
  24. if not self.currency_wish_base_config then
  25. self.currency_wish_base_config = {}
  26. for key, value in pairs(Config.Currencywishconfig) do
  27. self.currency_wish_base_config[value.type] = self.currency_wish_base_config[value.type] or {}
  28. table.insert(self.currency_wish_base_config[value.type], value)
  29. -- self.currency_wish_base_config[value.type] = {
  30. -- consume = stringtotable(value.consume),
  31. -- base_produce = stringtotable(value.base_produce),
  32. -- level_low = value.level_low,
  33. -- level_high = value.level_high,
  34. -- }
  35. end
  36. end
  37. if currency_wish_type then
  38. return self.currency_wish_base_config[currency_wish_type]
  39. else
  40. return self.currency_wish_base_config
  41. end
  42. end
  43. -- 根据玩家等级以及祈愿次数拿对应单条配置
  44. function CurrencyWishModel:GetCurrencyWishConfigOne(type)
  45. if not type then
  46. return
  47. end
  48. local role_lv = RoleManager.Instance.mainRoleInfo.level
  49. local have_use_num = 0
  50. local res
  51. local base_info = self:GetBaseInfo()
  52. if type == CurrencyWishConst.CURRENCY_WISH_TYPE.SPECIAL then
  53. have_use_num = base_info.luxury_rest_times
  54. elseif type == CurrencyWishConst.CURRENCY_WISH_TYPE.EXP then
  55. have_use_num = base_info.expr_rest_times
  56. end
  57. local base_cfg = self:GetCurrencyWishBaseConfig(type)
  58. for key, value in pairs(base_cfg) do
  59. if role_lv >= value.level_low
  60. and role_lv <= value.level_high
  61. and have_use_num >= value.wish_times_low
  62. and have_use_num <= value.wish_times_high
  63. then
  64. res = value
  65. end
  66. end
  67. return res
  68. end
  69. function CurrencyWishModel:CheckRedDot(check_new)
  70. if not check_new then
  71. return self.is_red
  72. end
  73. self.is_red = self:CheckNormalCurrencyWishRed(check_new)
  74. -- or self:CheckExpCurrencyWishRed(check_new)
  75. or self:CheckSpecialCurrencyWishRed(check_new)
  76. GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 340, self.is_red)
  77. return self.is_red
  78. end
  79. function CurrencyWishModel:CheckSpecialCurrencyWishRed(check_new)
  80. if not check_new then
  81. return self.is_speacial_currency_wish_red
  82. end
  83. self.is_speacial_currency_wish_red = false
  84. if not self.view_info then
  85. return self.is_speacial_currency_wish_red
  86. end
  87. self.is_speacial_currency_wish_red = self.view_info.luxurycool <= 0
  88. return self.is_speacial_currency_wish_red
  89. end
  90. function CurrencyWishModel:CheckNormalCurrencyWishRed(check_new)
  91. if not check_new then
  92. return self.is_normal_currency_wish_red
  93. end
  94. self.is_normal_currency_wish_red = false
  95. local stamp_goods_num = GoodsModel:getInstance():GetTypeGoodsNum(BagModel.StampGoodsId) --已有的交易券数量
  96. if stamp_goods_num >= 10 and RoleManager.Instance.mainRoleInfo.level >= 105 then
  97. self.is_normal_currency_wish_red = true
  98. end
  99. return self.is_normal_currency_wish_red
  100. end
  101. function CurrencyWishModel:SetCurrencyWishCdTime()
  102. self.cd_time_count = self.view_info.luxurycool
  103. if self.cd_timer_id then
  104. GlobalTimerQuest:CancelQuest(self.cd_timer_id)
  105. self.cd_timer_id = nil
  106. end
  107. if self.cd_time_count > 0 then
  108. local call_back = function ()
  109. self.cd_time_count = self.cd_time_count - 1
  110. if self.cd_time_count <= 0 then
  111. GlobalTimerQuest:CancelQuest(self.cd_timer_id)
  112. self.cd_timer_id = nil
  113. self.cd_time_count = 0
  114. self:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
  115. end
  116. self:Fire(CurrencyWishConst.UPDATE_CURRENCY_WISH_CD_TIME, self.cd_time_count)
  117. end
  118. self.cd_timer_id = GlobalTimerQuest:AddPeriodQuest(call_back, 1)
  119. call_back()
  120. end
  121. end
  122. -- function CurrencyWishModel:CheckExplCurrencyWishRed(check_new)
  123. -- if not check_new then
  124. -- return self.is_exp_currency_wish_red
  125. -- end
  126. -- self.is_exp_currency_wish_red = self.view_info.expcool <= 0
  127. -- return self.is_exp_currency_wish_red
  128. -- end