CurrencyWishModel = CurrencyWishModel or BaseClass(BaseVo, true)
|
|
local CurrencyWishModel = CurrencyWishModel
|
|
|
|
function CurrencyWishModel:__init()
|
|
CurrencyWishModel.Instance = self
|
|
self:Reset()
|
|
end
|
|
|
|
function CurrencyWishModel:Reset()
|
|
self.view_info = nil
|
|
end
|
|
|
|
function CurrencyWishModel:getInstance()
|
|
if self.Instance == nil then
|
|
self.Instance = CurrencyWishModel.New()
|
|
end
|
|
return self.Instance
|
|
end
|
|
|
|
function CurrencyWishModel:SetBaseInfo(vo)
|
|
self.view_info = vo
|
|
end
|
|
|
|
function CurrencyWishModel:GetBaseInfo()
|
|
return self.view_info
|
|
end
|
|
|
|
-- 获取祈愿总配置
|
|
function CurrencyWishModel:GetCurrencyWishBaseConfig(currency_wish_type)
|
|
if not self.currency_wish_base_config then
|
|
self.currency_wish_base_config = {}
|
|
for key, value in pairs(Config.Currencywishconfig) do
|
|
self.currency_wish_base_config[value.type] = self.currency_wish_base_config[value.type] or {}
|
|
table.insert(self.currency_wish_base_config[value.type], value)
|
|
-- self.currency_wish_base_config[value.type] = {
|
|
-- consume = stringtotable(value.consume),
|
|
-- base_produce = stringtotable(value.base_produce),
|
|
-- level_low = value.level_low,
|
|
-- level_high = value.level_high,
|
|
-- }
|
|
end
|
|
end
|
|
if currency_wish_type then
|
|
return self.currency_wish_base_config[currency_wish_type]
|
|
else
|
|
return self.currency_wish_base_config
|
|
end
|
|
end
|
|
|
|
-- 根据玩家等级以及祈愿次数拿对应单条配置
|
|
function CurrencyWishModel:GetCurrencyWishConfigOne(type)
|
|
if not type then
|
|
return
|
|
end
|
|
local role_lv = RoleManager.Instance.mainRoleInfo.level
|
|
local have_use_num = 0
|
|
local res
|
|
local base_info = self:GetBaseInfo()
|
|
if type == CurrencyWishConst.CURRENCY_WISH_TYPE.SPECIAL then
|
|
have_use_num = base_info.luxury_rest_times
|
|
elseif type == CurrencyWishConst.CURRENCY_WISH_TYPE.EXP then
|
|
have_use_num = base_info.expr_rest_times
|
|
end
|
|
local base_cfg = self:GetCurrencyWishBaseConfig(type)
|
|
for key, value in pairs(base_cfg) do
|
|
if role_lv >= value.level_low
|
|
and role_lv <= value.level_high
|
|
and have_use_num >= value.wish_times_low
|
|
and have_use_num <= value.wish_times_high
|
|
then
|
|
res = value
|
|
end
|
|
end
|
|
return res
|
|
end
|
|
|
|
|
|
function CurrencyWishModel:CheckRedDot(check_new)
|
|
if not check_new then
|
|
return self.is_red
|
|
end
|
|
|
|
self.is_red = self:CheckNormalCurrencyWishRed(check_new)
|
|
-- or self:CheckExpCurrencyWishRed(check_new)
|
|
or self:CheckSpecialCurrencyWishRed(check_new)
|
|
|
|
GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 340, self.is_red)
|
|
return self.is_red
|
|
end
|
|
|
|
function CurrencyWishModel:CheckSpecialCurrencyWishRed(check_new)
|
|
if not check_new then
|
|
return self.is_speacial_currency_wish_red
|
|
end
|
|
|
|
self.is_speacial_currency_wish_red = false
|
|
if not self.view_info then
|
|
return self.is_speacial_currency_wish_red
|
|
end
|
|
self.is_speacial_currency_wish_red = self.view_info.luxurycool <= 0
|
|
return self.is_speacial_currency_wish_red
|
|
end
|
|
|
|
function CurrencyWishModel:CheckNormalCurrencyWishRed(check_new)
|
|
if not check_new then
|
|
return self.is_normal_currency_wish_red
|
|
end
|
|
|
|
self.is_normal_currency_wish_red = false
|
|
local stamp_goods_num = GoodsModel:getInstance():GetTypeGoodsNum(BagModel.StampGoodsId) --已有的交易券数量
|
|
if stamp_goods_num >= 10 and RoleManager.Instance.mainRoleInfo.level >= 105 then
|
|
self.is_normal_currency_wish_red = true
|
|
end
|
|
|
|
return self.is_normal_currency_wish_red
|
|
|
|
end
|
|
|
|
function CurrencyWishModel:SetCurrencyWishCdTime()
|
|
self.cd_time_count = self.view_info.luxurycool
|
|
if self.cd_timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.cd_timer_id)
|
|
self.cd_timer_id = nil
|
|
end
|
|
if self.cd_time_count > 0 then
|
|
local call_back = function ()
|
|
self.cd_time_count = self.cd_time_count - 1
|
|
if self.cd_time_count <= 0 then
|
|
GlobalTimerQuest:CancelQuest(self.cd_timer_id)
|
|
self.cd_timer_id = nil
|
|
self.cd_time_count = 0
|
|
self:Fire(CurrencyWishConst.REQ_CURRENCY_WISH_INFO)
|
|
end
|
|
self:Fire(CurrencyWishConst.UPDATE_CURRENCY_WISH_CD_TIME, self.cd_time_count)
|
|
end
|
|
self.cd_timer_id = GlobalTimerQuest:AddPeriodQuest(call_back, 1)
|
|
call_back()
|
|
end
|
|
end
|
|
|
|
-- function CurrencyWishModel:CheckExplCurrencyWishRed(check_new)
|
|
-- if not check_new then
|
|
-- return self.is_exp_currency_wish_red
|
|
-- end
|
|
|
|
-- self.is_exp_currency_wish_red = self.view_info.expcool <= 0
|
|
-- return self.is_exp_currency_wish_red
|
|
-- end
|