|
|
- PowerTurnTableModel = PowerTurnTableModel or BaseClass(BaseVo, true)
- local PowerTurnTableModel = PowerTurnTableModel
-
- PowerTurnTableModel.REQUEST_INFO = "PowerTurnTableModel.REQUEST_INFO"
- PowerTurnTableModel.UPDATE_VIEW_INFO = "PowerTurnTableModel.UPDATE_VIEW_INFO" -- 更新源能转盘红点
- PowerTurnTableModel.OPEN_MAIN_VIEW = "PowerTurnTableModel.OPEN_MAIN_VIEW" -- 打开源能转盘界面
- PowerTurnTableModel.OPEN_EXCHANGE_VIEW = "PowerTurnTableModel.OPEN_EXCHANGE_VIEW"--打开积分兑换界面
- PowerTurnTableModel.START_TURN_ACTION = "PowerTurnTableModel.START_TURN_ACTION"--开始转盘动画
- PowerTurnTableModel.UPDATE_RECORD_INFO = "PowerTurnTableModel.UPDATE_RECORD_INFO"--更新日志
- PowerTurnTableModel.UPDATE_EXCHANGE_VIEW = "PowerTurnTableModel.UPDATE_EXCHANGE_VIEW"--刷新兑换界面
- PowerTurnTableModel.OPEN_EXCHANGE_REQ_VIEW = "PowerTurnTableModel.OPEN_EXCHANGE_REQ_VIEW"--打开兑换请求界面
-
- function PowerTurnTableModel:__init()
- PowerTurnTableModel.Instance = self
- self:Reset()
- end
-
- function PowerTurnTableModel:Reset()
- self.is_skip_turn_table_action = false
- self.server_award_info = {}--界面信息
- self.record_info_list = {}--日志信息
- self.exchange_info = {}--兑换界面信息
- self.buy_toggle = {}--购买确认
- self.login_red_list = {}
- self.time_id_list = {}
- self.time_red_list = {}--倒计时五小时有积分可以兑换就有红点
- self.can_exchange_red_list = {}--可以兑换的红点列表
- end
-
- function PowerTurnTableModel:getInstance()
- if self.Instance == nil then
- self.Instance = PowerTurnTableModel.New()
- end
- return self.Instance
- end
-
- --检查源能转盘开启
- function PowerTurnTableModel:CheckPowerTurnTableIconBoolOpen( sub_type )
- local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
- local sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(base_type)
- local level = RoleManager.Instance.mainRoleInfo.level
- local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
- local is_open = false
- local end_time = 0
- local open_level = 1
- local icon_sub_type = base_type*1000 + sub_type
- if sub_type >= 10001 then
- icon_sub_type = base_type*100000 + sub_type
- end
- if act_list and act_list.etime then
- for l,w in pairs(act_list.condition_list) do
- if type(w) == "table" and w[1] == "role_lv" then
- open_level = tonumber(w[2])
- break
- end
- end
- local have_time = TimeUtil:getServerTime( ) - act_list.stime
- end_time = act_list.etime - TimeUtil:getServerTime()
- is_open = have_time > 0 and end_time > 0 and open_level <= RoleManager.Instance.mainRoleInfo.level
- if GetModuleIsOpen(331,base_type) then
- if is_open then
- self:SetDelayTimeList(sub_type)
- ActivityIconManager:getInstance():addIcon(icon_sub_type, end_time)
- else
- ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
- end
- else
- -- print("huangcong:KfActivityModel [62]: ",key)
- end
- else
- ActivityIconManager:getInstance():deleteIcon(icon_sub_type)
- end
- end
-
- function PowerTurnTableModel:SetDelayTimeList( sub_type )
- if self.time_id_list[sub_type] then
- GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
- self.time_id_list[sub_type] = nil
- end
- if self.time_red_list[sub_type] then
- return
- end
- local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
- local act_list = CustomActivityModel:getInstance():getActList(base_type,sub_type) or {}
- if not act_list then return end
- local end_time = act_list.etime
- local haly_hour = 3600*5
- local sec = end_time - TimeUtil:getServerTime()
- if sec > 0 then
- local function onTimer()
- sec = end_time - TimeUtil:getServerTime()
- if sec < haly_hour then--五小时有可以兑换的要给予红点且所有奖励有未购买完的
- if self.time_id_list[sub_type] then
- GlobalTimerQuest:CancelQuest(self.time_id_list[sub_type])
- self.time_id_list[sub_type] = nil
- end
- self.time_red_list[sub_type] = true
- self:CheckPowerTurnTableMainRedDot(sub_type)
- self:Fire(PowerTurnTableModel.UPDATE_VIEW_INFO,sub_type)
- end
- end
- onTimer()
- if not self.time_id_list[sub_type] then
- self.time_id_list[sub_type] = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
- end
- end
- end
-
- --源能转盘信息
- function PowerTurnTableModel:SetPowerTurnTableInfo( vo )
- local sort_func = function ( a, b )
- return a.id < b.id
- end
- table.sort(vo.pool_list, sort_func)
- for i,v in ipairs(vo.pool_list) do
- v.reward = stringtotable(v.reward)[1]
- end
- self.server_award_info[vo.sub_type] = vo
- self:Fire(PowerTurnTableModel.UPDATE_VIEW_INFO,vo.sub_type)
- self:CheckPowerTurnTableMainRedDot(vo.sub_type)
- end
-
- function PowerTurnTableModel:GetPowerTurnTableInfo( sub_type )
- return self.server_award_info[sub_type]
- end
-
- function PowerTurnTableModel:CheckPowerTurnTableMainRedDot( sub_type )
- local bool = false
- local base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
- if not sub_type then return end
- local icon_sub_type = base_type*1000 + sub_type
- if sub_type >= 10001 then
- icon_sub_type = base_type*100000 + sub_type
- end
- local act_list = CustomActivityModel:getInstance():getActList(base_type, sub_type)
- if not act_list then
- return
- else
- local server_award_info = self:GetPowerTurnTableInfo(sub_type)
- if server_award_info and server_award_info.free_time and server_award_info.free_time > 0 then--免费红点
- bool = true
- end
- if not bool and not self.login_red_list[sub_type] then--每次登陆给一次红点
- bool = true
- end
-
- if not bool and self.time_red_list[sub_type] and self.can_exchange_red_list[sub_type] then--倒计时5小时兑换红点
- bool = true
- end
-
- if not bool then
- local last_time_list = self:GetPowerTTScoreCookie()--积分按钮每日首次红点
- local score = self.server_award_info[sub_type] and self.server_award_info[sub_type].score or 0
- if not last_time_list[sub_type] then
- bool = score > 0
- end
- end
- GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, icon_sub_type, bool)
- end
- end
-
- --设置抽奖记录数据
- function PowerTurnTableModel:SetRecordInfo( scmd )
- self.record_info_list[scmd.sub_type] = scmd.list
- end
-
- function PowerTurnTableModel:GetRecordInfo( sub_type )
- return self.record_info_list[sub_type]
- end
-
- --设置兑换界面数据
- function PowerTurnTableModel:SetExchangeInfoList( scmd )
- self.can_exchange_red_list[scmd.sub_type] = false
- for i,v in ipairs(scmd.swap_list) do
- v.reward = stringtotable(v.reward)[1]
- v.sort_id = v.id + (v.left_times == 0 and 1000 or 0)--兑换完置底
- if v.left_times > 0 and scmd.cur_score >= v.score and not self.can_exchange_red_list[scmd.sub_type] then
- self.can_exchange_red_list[scmd.sub_type] = true
- end
- end
- local sort_func = function ( a, b )
- return a.sort_id < b.sort_id
- end
- table.sort(scmd.swap_list, sort_func)
- self.exchange_info[scmd.sub_type] = scmd.swap_list
- self:CheckPowerTurnTableMainRedDot(scmd.sub_type)
- end
-
- --获得源能转盘兑换界面信息
- function PowerTurnTableModel:GetExchangeInfoList( sub_type )
- return self.exchange_info[sub_type]
- end
-
- --设置源能转盘红点cookie
- function PowerTurnTableModel:SetPowerTTScoreCookie( sub_type,time )
- local list = self:GetPowerTTScoreCookie() or {}
- list[sub_type] = time
- CookieWrapper.Instance:SaveCookie(CookieLevelType.Account,CookieTimeType.TYPE_DAY2,CookieKey.POWER_TURN_TABLE_SCORE_RED,list)
- CookieWrapper.Instance:WriteAll()
- end
-
- --获得源能转盘红点cookie
- function PowerTurnTableModel:GetPowerTTScoreCookie( )
- local bool = CookieWrapper.Instance:GetCookie(CookieLevelType.Account,CookieKey.POWER_TURN_TABLE_SCORE_RED) or {}
- return bool
- end
|