源战役客户端
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.
 
 
 
 
 

1776 lines
67 KiB

DailyModel = DailyModel or BaseClass(BaseModel)
local table_insert = table.insert
local stringtotable = stringtotable
local tonumber = tonumber
DailyModel.OPEN_DAILY_BASE_VIEW = "DailyModel.OPEN_DAILY_BASE_VIEW"--打开日常界面
DailyModel.CLOSE_DAILY_BASE_VIEW = "DailyModel.CLOSE_DAILY_BASE_VIEW"--打开日常界面
DailyModel.OPEN_ALL_ACTIVITY_VIEW = "DailyModel.OPEN_ALL_ACTIVITY_VIEW"--打开活动日历界面
DailyModel.OPEN_DAILY_COMMON_TIP_VIEW = "DailyModel.OPEN_DAILY_COMMON_TIP_VIEW"
DailyModel.OPEN_RECOVERY_ALL_TIP = "DailyModel.OPEN_RECOVERY_ALL_TIP"-- 一键找回Tip
DailyModel.OPEN_RECOVERY_ONE_TIP = "DailyModel.OPEN_RECOVERY_ONE_TIP"-- 找回Tip
DailyModel.OPEN_HOSTING_RECORD_VIEW = "DailyModel.OPEN_HOSTING_RECORD_VIEW"-- 托管记录
DailyModel.OPEN_HOSTING_REWARD_VIEW = "DailyModel.OPEN_HOSTING_REWARD_VIEW"-- 托管奖励
DailyModel.HOSTING_SETTING_INFO = "DailyModel.HOSTING_SETTING_INFO"-- 托管信息
DailyModel.HOSTING_SETTING_UPDATE = "DailyModel.HOSTING_SETTING_UPDATE"-- 托管设置更新
DailyModel.HOSTING_RECORE_UPDATE = "DailyModel.HOSTING_RECORE_UPDATE"-- 托管记录
DailyModel.OPEN_UP_SUCCESS_VIEW = "DailyModel.OPEN_UP_SUCCESS_VIEW"--学位升级成功界面
DailyModel.CHANGE_RECOVERY_TYPE = "DailyModel.CHANGE_RECOVERY_TYPE"--广播更改资源找回类型
DailyModel.CHECK_DAILY_RED_DOT = "DailyModel.CHECK_DAILY_RED_DOT"--广播红点
DailyModel.REQUEST_CCMD_EVENT = "DailyModel.REQUEST_CCMD_EVENT"
DailyModel.ANS_DAILY_BASE = "DailyModel.ANS_DAILY_BASE"--基础信息返回
DailyModel.ANS_ACTIVITY_OPEN_STATUS = "DailyModel.ANS_ACTIVITY_OPEN_STATUS"--单独查询活动状态
DailyModel.ANS_LIVENESS_INFO = "DailyModel.ANS_LIVENESS_INFO"--查询活跃度信息
DailyModel.ANS_LIVENESS_FIGURE_INFO = "DailyModel.ANS_LIVENESS_FIGURE_INFO"--查询活跃度形象信息
DailyModel.ANS_RECOVERY_LIST = "DailyModel.ANS_RECOVERY_LIST"--资源找回界面信息
DailyModel.ANS_RECOVERY = "DailyModel.ANS_RECOVERY"--资源找回
DailyModel.OPEN_DAILY_ORDER_REWARD_VIEW = "DailyModel.OPEN_DAILY_ORDER_REWARD_VIEW"--日常预约界面
DailyModel.UPDATE_DAILY_ORDER_ALL_DATA = "DailyModel.UPDATE_DAILY_ORDER_ALL_DATA"--刷新日常预约所有数据
DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA = "DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA"--刷新日常预约个别数据
DailyViewType = {
Recovery = 419,--找回
Common = 2,--日常
Activity = 3,--今日活动
ActivityAll = 4,--活动日历
HostingSetting = 1,--托管设置
Achieve = 5, -- 成就
}
DailyActivityType = {
UnLimit = 1, --非限时
Limit = 2, --限时
}
ActivityState = {
Opening = 1, --开启中
Today = 2, --今日开启
Unopened = 3, --未开启
LvLimit = 4, --等级不足
Closed = 5, --已关闭
}
TodayType = {
Yes = 1,
No = 2,
}
ActiveTimeType = {
StartTime = 1,
EndTime = 2,
}
TimeType = {
None = 0,
Week = 1,
Month = 2,
Date = 3,
}
--开合服类型
ServerTimeType = {
MergeDay = 1, --合服
OpenDay = 2, --开服
Normal = 3, --正常
}
--日常预约状态
DailyOrderStatus =
{
UN_ORDER = 0,
UN_JOIN = 1,
UN_GET = 2,
DONE = 3,
}
function DailyModel:__init()
DailyModel.Instance = self
self:ResetData( )
end
function DailyModel:getInstance()
if DailyModel.Instance == nil then
DailyModel.New()
end
return DailyModel.Instance
end
function DailyModel:GetInstance()
return DailyModel:getInstance()
end
function DailyModel:ResetData( )
self.parse_cache_list = nil
self.resact_list = nil
self.daily_base_info = nil--基础信息,日常界面item列表信息
self.ac_open_status = nil--活动的开启状态
self.liveness_info = nil--活跃度信息
self.liveness_figure_info = nil--玩家活跃度形象
self.resource_recovery_list = {}--找回信息
-------------------------
self.red_today_reward = {}--今日活跃奖励
self.red_liveness_up = false--今日活跃度升级
self.mask_recover_red = false--一次性的找回红点
self.hosting_time_cfg = false --托管设置配置
self.hosting_time_string_list = false --托管设置时间字符串缓存
self.hosting_time_day_list = false --托管设置开放日期缓存
self.hosting_info = {} --托管信息
self.hosting_is_request_record = false --托管奖励请求
self.hosting_red_dot = false --托管红点
self.daily_order_info = {} --日常预约数据
self.daily_order_red_dot = false --日常预约红点
end
--解析配置
function DailyModel:GetParseList(key)
if self.parse_cache_list == nil then
self.parse_cache_list = {}
end
local cache_vo = self.parse_cache_list[key]
if cache_vo then
return cache_vo
else
cache_vo = ErlangParser:GetInstance():Parse(key)
self.parse_cache_list[key] = cache_vo
return cache_vo
end
end
--获得活动日历配置
function DailyModel:GetAcConfig(_module, module_sub, ac_sub)
local str = _module .. "@" .. module_sub .. "@" .. ac_sub
return Config.Ac[str]
end
--获得配置表里开合服对应的天数
function DailyModel:GetOpenOrMergeDayByCfg(dayList, day)
local dayData
for i, v in ipairs(dayList) do
local startDay = tonumber(v[1])
local endDay = tonumber(v[2])
if day <= startDay or (day > startDay and day <= endDay) then
dayData = v
break
end
end
return dayData
end
--[[
*获得活跃度配置
* @param module_id 功能ID
* @param module_sub_id 子功能ID
]]
function DailyModel:GetActLivenessConfig(module_id, module_sub_id)
return Config.Activityliveness[module_id.."@"..module_sub_id]
end
--[[
*获得活跃度外形激活配置
* @param id 活跃度外形Id
]]
function DailyModel:GetLivenessActiveConfig(id)
if not self.conf_liveness_active then
self.conf_liveness_active = {}
for k,v in pairs(DailyConst.Livenessactive) do
local have = false
for a,b in pairs(Config.Livenesslv) do
if b.figure == v.figure_id then
have = true
break
end
end
if have then
self.conf_liveness_active[#self.conf_liveness_active+1] = DeepCopy(v)
end
end
-------------------------
for k,v in pairs(self.conf_liveness_active) do
v.lv = 999
for a,b in pairs(Config.Livenesslv) do
if b.figure == v.figure_id then
v.lv = v.lv < b.lv and v.lv or b.lv
end
end
end
local function sort_call( a,b )
return a.lv < b.lv
end
table.sort( self.conf_liveness_active, sort_call )
end
if id then
return self.conf_liveness_active[id]
else
return self.conf_liveness_active
end
end
--[[
*获得活跃度外形升级配置
* @param level 活跃度外形等级
]]
function DailyModel:GetLivenessLvConfig(level)
if not level then return end
for k,v in pairs(Config.Livenesslv) do
if v.lv == level then
return v
end
end
end
--[[
*奖励找回配置
* @param act_id 活动id
* @param act_sub 活动子类
]]
function DailyModel:GetResactConfig(act_id, act_sub)
local type = Config.Resacttype[act_id .. "@" .. act_sub] and Config.Resacttype[act_id .. "@" .. act_sub].type or 1
local cur_key = act_id .. "@" .. act_sub
if not self.resact_list then
self.resact_list = {}
for _,v in pairs(Config.Resact) do
local key = v.act_id.."@"..v.act_sub
local list = self.resact_list[key]
if not list then
list = {}
self.resact_list[key] = list
end
table_insert(list,v)
end
end
local cur_list = self.resact_list[cur_key]
local cfg = nil
if cur_list then
local role_lv = RoleManager.Instance:GetMainRoleLevel2()
local world_lv = RoleManager.Instance:GetMainRoleVo().worldLv
for _,v in pairs(cur_list) do
if type == 1 then --玩家等级
if role_lv >= v.level and role_lv <= v.level_max then
cfg = v
break
end
elseif type == 2 then --世界等级
if world_lv >= v.server_min_lv and world_lv <= v.server_max_lv then
cfg = v
break
end
end
end
end
return cfg
end
--获取找回活动经验配置系数
function DailyModel:GetBackAwardPer( act_id, act_sub )
local lv = RoleManager.Instance.mainRoleInfo.level
for k,v in pairs(Config.Awardexp) do
if v.mid == act_id and v.sid == act_sub then
if lv >= v.lv_min and lv <= v.lv_max then
return v.extra/10000
end
end
end
return 0
end
--获取活动开始时间的秒数和开始等级
function DailyModel:GetActivityStartSecAndStartLv(vo, now_time)
local time = os.date("*t", now_time)
local now_sec = time.hour * 3600 + time.min * 60
local start_second, end_second, now_second = 0, 0, 0
local start_lv = 0
local state = ActivityState.Unopened
local ac_cfg = self:GetAcConfig(vo.module, vo.module_sub, vo.ac_sub)
local temp_start_second, temp_end_second, temp_now_second = 0, 0, 0
if ac_cfg then
local active_time_list = self:GetParseList(ac_cfg.time_region)
table.sort(active_time_list, function (a, b)
return tonumber(a[1][1]) < tonumber(b[1][1])
end)
for i, v in ipairs(active_time_list) do
local start_hour = v[ActiveTimeType.StartTime][1]
local start_min = v[ActiveTimeType.StartTime][2]
local end_hour = v[ActiveTimeType.EndTime][1]
local end_min = v[ActiveTimeType.EndTime][2]
local activity_start_sec = start_hour * 3600 + start_min * 60
local activity_end_sec = end_hour * 3600 + end_min * 60
start_second = activity_start_sec
end_second = activity_end_sec
now_second = now_sec
if now_sec < activity_start_sec then
state = ActivityState.Unopened
break
elseif now_sec >= activity_end_sec then
state = ActivityState.Closed
else
state = ActivityState.Opening
break
end
end
start_lv = ac_cfg.start_lv
end
local isToday = self:EstimateActivityIsToday(vo, now_time)
if isToday == TodayType.No then
state = ActivityState.Unopened
elseif isToday and state ~= ActivityState.Closed then
state = ActivityState.Today
end
return start_second, start_lv, state, end_second, now_second
end
--判断活动是否是今天开启
function DailyModel:EstimateActivityIsToday(vo, time)
local result = TodayType.No
local nowDate = os.date("*t", time)
local weekday = tonumber(os.date("%w", time))--0-6 = Sunday-Saturday
if weekday == 0 then
weekday = 7
end
local ac_cfg = self:GetAcConfig(vo.module, vo.module_sub, vo.ac_sub)
if ac_cfg then
local dateList = self:GetParseList(ac_cfg.time)
local monthList = self:GetParseList(ac_cfg.month)
local weekList = self:GetParseList(ac_cfg.week)
local openDayList = self:GetParseList(ac_cfg.open_day)
local mergeDayList = self:GetParseList(ac_cfg.merge_day)
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
local mergeDay = ServerTimeModel:getInstance():GetMergeServerDay()
local isToday = false
if mergeDay > 0 and #mergeDayList > 0 then
local dayData = self:GetOpenOrMergeDayByCfg(mergeDayList, mergeDay)
if dayData then
local startDay = tonumber(dayData[1])
local endDay = tonumber(dayData[2])
if mergeDay >= startDay and mergeDay <= endDay then
if endDay - startDay <= 7 then
isToday = true
else
if #weekList > 0 then
for i, v in ipairs(weekList) do
if tonumber(v) == tonumber(weekday) then
isToday = true
break
end
end
elseif #weekList == 0 then
isToday = true
end
end
end
end
elseif #openDayList > 0 then
local dayData = self:GetOpenOrMergeDayByCfg(openDayList, openDay)
if dayData then
local startDay = tonumber(dayData[1])
local endDay = tonumber(dayData[2])
if openDay >= startDay and openDay <= endDay then
if #weekList > 0 then
for i, v in ipairs(weekList) do
if tonumber(v) == tonumber(weekday) then
isToday = true
break
end
end
elseif #weekList == 0 then
isToday = true
end
end
end
elseif #weekList ~= 0 then
for i, v in ipairs(weekList) do
if tonumber(v) == tonumber(weekday) then
isToday = true
break
end
end
elseif #monthList ~= 0 then
for i, v in ipairs(monthList) do
if nowDate.day == tonumber(v) then
isToday = true
break
end
end
elseif #dateList ~= 0 then
for i, v in ipairs(dateList) do
if tonumber(v[1]) == nowDate.year and tonumber(v[2]) == nowDate.month and tonumber(v[3]) == nowDate.day then
isToday = true
break
end
end
elseif #weekList == 0 and #monthList == 0 and #dateList == 0 then
isToday = true
end
if isToday then
result = TodayType.Yes
else
result = TodayType.No
end
end
return result
end
--根据等级区间获得挂机配置 -- 1 为随机配置的一个点 2 为选中配置的点
function DailyModel:GetOnhookConfig(type)
type = type or 1
if type == 2 then
local level = RoleManager:getInstance():GetMainRoleVo().level
local data
for _, v in pairs(Config.Onhook) do
--只有野外的才选择
if level >= v.min_lv and level < v.max_lv and v.onhook_type == 0 then
data = v
break
end
end
return data
else
local level = RoleManager:getInstance():GetMainRoleVo().level
local min_lv,max_lv,scene_id
for _, v in pairs(Config.Onhook) do
--只有野外的才选择
if level >= v.min_lv and level < v.max_lv and v.onhook_type == 0 then
min_lv = v.min_lv
max_lv = v.max_lv
scene_id = v.scene_id
break
end
end
if min_lv then
local list = {}
for _, v in pairs(Config.Onhook) do
--取配置表的前后 两条跟当前的一条数据
if ((v.max_lv == min_lv) or (min_lv == v.min_lv and max_lv == v.max_lv) or (v.min_lv == max_lv)) and v.onhook_type == 0 and v.scene_id == scene_id then
table_insert(list,v)
end
end
if #list > 0 then
local index = math.random(1,#list)
return list[index]
end
end
return false
end
end
function DailyModel:GetCommonShowList( )
-------------------------
--有个需求,几个副本要合并到一起去显示,这时候要前端编一个假条目
-------------------------
local special_dungeon_list = {
module = 610,
module_sub = 9999,
ac_sub = 1,
num = 0,
live = 0,
state = 1,
conf_data = DeepCopy(self:GetAcConfig(610, 1001, 1)),
-------------------------
max_times = 0,
}
special_dungeon_list.conf_data.ac_icon = 610999
special_dungeon_list.conf_data.about = DailyConst.CommonDungeonDes or ""
special_dungeon_list.conf_data.reward = {}
special_dungeon_list.base_num = 0--统计一下有几个要计算基础的总数
special_dungeon_list.base_success_num = 0--统计一下完成了几个计算基础
special_dungeon_list.can_buy_num = 0--统计一下还可以买几次
special_dungeon_list.have_buy_num = 0--统计一下已经买了几次
-------------------------
local data = {}
local base_data = self:GetDailyBaseInfo( )
if not base_data then return data end
for i=1,2 do
if base_data.ac_list[i] then
for ii,vv in ipairs(base_data.ac_list[i]) do
local temp_live_cfg = self:GetActLivenessConfig(vv.module, vv.module_sub)
if temp_live_cfg and temp_live_cfg.hidden ~= 0 then
--部分不需要显示啦
else
local str_id = vv.module .. "@" .. vv.module_sub .. "@" .. vv.ac_sub
if DailyConst.CommonDungeonList[str_id] then
if vv.state == 1 and GetModuleIsOpen(vv.module,vv.module_sub) then
-------------------------
--后端发来的次数包含了可购买的次数,那么这边需要减掉这些次数,而且沉底表现也用到了
local left_can_buy_time,left_gold_can_buy_time = BaseDungeonModel:GetInstance():GetDunVipBuyLeftTimes(tonumber(vv.module_sub))
-------------------------
--如果是贵族,当天第二次打本是免费的,那么在通关次数小于二的时候,可购买次数就要减一
local dungeon_type = BaseDungeonModel:GetInstance():GetDunTypeByDunId(tonumber(vv.module_sub))
local dungeon_data = BaseDungeonModel:GetInstance():GetDunProtoInfoByDunId( dungeon_type,tonumber(vv.module_sub) )
local today_pass_count = dungeon_data and (dungeon_data.day_pass_count + dungeon_data.vip_count) or 0
if RoleManager.Instance.mainRoleInfo.sup_vip_type ~= 0 and today_pass_count <= 1 then
left_can_buy_time = left_can_buy_time - 1
end
-------------------------
--要在分母加一个已购买次数
local max_buy_time = BaseDungeonModel:GetInstance():GetDunVipBuyMaxTimes( tonumber(vv.module_sub) )
local have_buy_time = max_buy_time - left_can_buy_time
local left_gold_can_buy_time = (left_gold_can_buy_time > have_buy_time ) and (left_gold_can_buy_time - have_buy_time) or 0--剩余的红钻购买次数
special_dungeon_list.num = special_dungeon_list.num + vv.num--通关次数
special_dungeon_list.live = special_dungeon_list.live + vv.live--活跃度
special_dungeon_list.max_times = special_dungeon_list.max_times + vv.max_times - left_can_buy_time + left_gold_can_buy_time--最大次数(如果还有红钻购买次数,则加起来)
special_dungeon_list.can_buy_num = special_dungeon_list.can_buy_num + left_can_buy_time--可买次数
special_dungeon_list.have_buy_num = special_dungeon_list.have_buy_num + have_buy_time--已买次数
local cur_base_num = DailyConst.CommonBaseTime[str_id]
if cur_base_num then
--额外购买次数的任务,基本次数之后,置底
special_dungeon_list.base_num = special_dungeon_list.base_num + cur_base_num
if vv.num >= cur_base_num then
special_dungeon_list.base_success_num = special_dungeon_list.base_success_num + cur_base_num
else
special_dungeon_list.base_success_num = special_dungeon_list.base_success_num + vv.num
end
end
if type(vv.conf_data.reward) == "string" then
for k,v in pairs(stringtotable(vv.conf_data.reward)[1][2]) do
local have = false
for a,b in pairs(special_dungeon_list.conf_data.reward) do
if b[1] == v[1] and b[2] == v[2] then
have = true
-- b[3] = b[3] + v[3]
b[3] = 0
end
end
if not have then
table.insert( special_dungeon_list.conf_data.reward, v )
end
end
end
end
elseif vv.module == 280 and vv.module_sub == 0 and DailyConst.CommonBaseTime[str_id] then
--竞技场,要做购买次数的额外显示
local conf_max_buy = PkRankModel:getInstance():GetVipCanBuyTime(RoleManager.Instance.mainRoleInfo.vip_flag)--配置的最大可购买次数
local can_buy_num = PkRankModel:getInstance().times_info.can_buy_num
-------------------------
vv.base_num = DailyConst.CommonBaseTime[str_id]--统计一下有几个要计算基础的总数
vv.base_success_num = math.min( vv.num , vv.base_num )--统计一下完成了几个计算基础
vv.can_buy_num = PkRankModel:getInstance().times_info.can_buy_num
vv.show_max_times = math.max(0, vv.max_times - can_buy_num)
vv.have_buy_num = conf_max_buy - can_buy_num
table.insert( data, vv )
else
--装备副本最大次数,读配置
if vv.module == 215 and vv.module_sub == 1 then
vv.max_times = DunManyModel:GetEquipDunMaxCount( )
end
table.insert( data, vv )
end
end
end
end
end
table.insert( data, 1, special_dungeon_list )
-------------------------
return data
end
---------------------------------------------------------------------------------------------------------------
--[[获得活动周历信息,返回数据结构:
{
{12:10~12:30,未合服,{name = 活动名1, module_id = xxx, module_sub = xxx},无,无,无,无,无},
{16:00~16:30,未合服,无,无,无,{name = 活动名2, module_id = xxx, module_sub = xxx},无,无},
]]--
--need_combine有的活动时间区间可以并入其它大时间区间,判断十分需要并入
function DailyModel:GetWeekCalendarInfo(need_combine)
--开服天数
local open_day = ServerTimeModel:getInstance():GetOpenServerDay()
--合服天数
local merge_day = ServerTimeModel:getInstance():GetMergeServerDay()
local all_ac_list = {} --活动日历列表
for _, v in pairs(Config.Ac) do
if tonumber(v.ac_type) == DailyActivityType.Limit then
local cfg = DeepCopy(v)
cfg.week_day_list = stringtotable(cfg.week)
cfg.time_region_info = stringtotable(cfg.time_region)
-- cfg.start_time_info = cfg.time_region_info[1]
cfg.start_time_info = cfg.time_region_info
assert(cfg.start_time_info and cfg.start_time_info[1][1], "has no time region setting for limit activity in Config.Ac.lua!")
-- cfg.start_time_info = cfg.start_time_info[1]
cfg.open_day_list = stringtotable(cfg.open_day)
cfg.merge_day_list = stringtotable(cfg.merge_day)
table_insert(all_ac_list, cfg)
end
end
--今天是星期几
local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
-- 2020年6月20日新增,格式跟Config.ConfigDaily.WeekCalendarTime相同,代表活动的开始时间
local event_time_list = self:GetAllAcEventTimeList(all_ac_list,need_combine)
local cale_list = self:InitCalendarList(event_time_list, open_day, merge_day, cur_weekday)
--遍历所有的限时活动
for i,ac_cfg in ipairs(all_ac_list) do
--周1至周日
for week_day=1,7 do
local is_week_day_ok = self:IsEmptyListOrDayInList(ac_cfg.week_day_list, week_day)
--假设今天是周3,周1时的开服天数就是当前开服天数减2
local open_day_for_show = open_day-(cur_weekday-week_day)
local is_open_day_ok = self:IsEmptyListOrDayInList(ac_cfg.open_day_list, open_day_for_show)
local merge_day_for_show = merge_day-(cur_weekday-week_day)
-- 2020年7月24日修改:修复有合服开放情况的配置出现开放时间错误的问题
-- local is_merge_day_ok = merge_day == 0 or self:IsEmptyListOrDayInList(ac_cfg.merge_day_list, merge_day_for_show)
if merge_day == 0 then
--都还没合服,就不用推算后面和之前的合服天数啦
merge_day_for_show = 0
end
--合服天数的配置,[0,0]代表未合服,不填代表无合服天数限制
local is_merge_day_ok = self:IsEmptyListOrDayInList(ac_cfg.merge_day_list, merge_day_for_show > 0 and merge_day_for_show or 0)
if is_week_day_ok and is_open_day_ok and is_merge_day_ok then
-- 开服天数和合服天数都满足就看开启时间段
-- 2020年2月24日新增:对同一活动多时段情况的判断
for k = 1, #ac_cfg.start_time_info do
local time_section_index = self:GetTimeSectionIndex(event_time_list, ac_cfg.start_time_info[k][1])
if time_section_index then
cale_list[time_section_index] = cale_list[time_section_index] or {}
if not cale_list[time_section_index][week_day+1] or cale_list[time_section_index][week_day+1]=="" then
--week_day要加1是因为第1元素是存放时间段的如:12:00~12:30
local ac_table = {
name = Trim(ac_cfg.ac_name),
module_id = ac_cfg.module,
module_sub = ac_cfg.module_sub,
ac_sub = ac_cfg.ac_sub,
}
cale_list[time_section_index][week_day+1] = ac_table
end
end
end
end
end
end
return cale_list, event_time_list
end
-- 2020年6月20日新增,计算获取活动的开始时间
-- 格式为 {活动开始时间h, 活动开始时间m,活动结束时间h,活动结束时间m} h,m分别代表小时和分
-- 例:{12, 0, 12, 20},
function DailyModel:GetAllAcEventTimeList(ac_list, need_combine)
local time_region
-- 用来存放临时的开始时间和结束时间
local temp_tb = {}
local temp_key_tb = {}
local event_time_list = {}
local filter_key
local have_key_list = need_combine and {}--如果要合并,用这个表方便处理记录
for k, cfg in ipairs(ac_list) do
filter_key = cfg.module .. cfg.module_sub
if not Config.ConfigDaily.CalendarFilterAc[filter_key] then -- 如果是不打算显示在活动日历上的限时活动,需要添加相应的配置进行过滤
time_region = stringtotable(cfg.time_region)
for k2, v2 in ipairs(time_region) do
-------------------------
local need_mask = false
if have_key_list then
for index_have_key,data in pairs(have_key_list) do
if (v2[1][1]*60+v2[1][2] >= data[1]*60+data[2]) and (v2[2][1]*60+v2[2][2] <= data[3]*60+data[4]) then
--已经存在较大区间,那么本区间不需要增加
need_mask = true
break
elseif (v2[1][1]*60+v2[1][2] <= data[1]*60+data[2]) and (v2[2][1]*60+v2[2][2] >= data[3]*60+data[4]) then
--我比你大,要把你换掉!把现有区间删掉!
local temp_time_key = data[1] .. "@" .. data[2] .. "@" .. data[3] .. "@" .. data[4]
for temp_k,temp_v in pairs(temp_tb) do
if temp_v.time_key == temp_time_key then
table.remove(temp_tb,temp_k)--抹除旧记录,就当没事发生过
table.remove(have_key_list,index_have_key)--抹除旧记录,就当没事发生过
break
end
end
temp_key_tb[temp_time_key] = nil
break
end
end
end
-------------------------
if not need_mask then
local time_key = v2[1][1] .. "@" .. v2[1][2] .. "@" .. v2[2][1] .. "@" .. v2[2][2]
if not temp_key_tb[time_key] then
-- 使用活动时间组成键值之后,使用活动开始的时间计算分钟数作为排序sort_id
temp_tb[#temp_tb + 1] = {time_key = time_key, sort_id = v2[1][1] * 60 + v2[1][2]}
temp_key_tb[time_key] = true
if have_key_list then
table.insert( have_key_list, {v2[1][1], v2[1][2], v2[2][1], v2[2][2]} )
end
end
end
end
end
end
-- 根据特殊键值排序
local sort_func = function ( a, b )
return a.sort_id < b.sort_id
end
table.sort(temp_tb, sort_func)
-- 解析time_key,组成{12, 0, 12, 20}这样的格式
local new_time_list
for k, v in ipairs(temp_tb) do
new_time_list = Split(v.time_key, "@")
-- 处理成数字
new_time_list[1] = tonumber(new_time_list[1])
new_time_list[2] = tonumber(new_time_list[2])
new_time_list[3] = tonumber(new_time_list[3])
new_time_list[4] = tonumber(new_time_list[4])
event_time_list[#event_time_list+1] = new_time_list
end
return event_time_list
end
function DailyModel:InitCalendarList( event_time_list, open_day, merge_day, cur_weekday )
local cale_list = {}
for i, v in ipairs(event_time_list) do --多少行
cale_list[i] = cale_list[i] or {}
local time_str = (v[1] .. ":" .. (v[2] < 10 and "0" .. v[2] or v[2]).."~"..v[3]..":"..(v[4] < 10 and "0" .. v[4] or v[4]))
cale_list[i][1] = time_str
for week_day=1,7 do
local show_str = ""
if merge_day > 0 and merge_day < 7 then
local merge_day_for_show = merge_day-(cur_weekday-week_day)
if merge_day_for_show <= 0 then
show_str = "未合服"
end
elseif open_day < 7 then
local open_day_for_show = open_day-(cur_weekday-week_day)
if open_day_for_show <= 0 then
show_str = "未开服"
end
end
cale_list[i][week_day+1] = show_str
end
end
return cale_list
end
function DailyModel:GetTimeSectionIndex( event_time_list, start_time_info )
for i,v in ipairs(event_time_list) do
local start_hour = start_time_info[1]
local start_min = start_time_info[2]
if v[1] == start_hour and v[2] == start_min then
return i
end
end
return nil
end
function DailyModel:IsEmptyListOrDayInList( list, day )
if #list <= 0 then
--列表为空时代表哪一天都可以
return true
end
for i,v in ipairs(list) do
if type(v) == "number" then
--周列表的格式是{1,5,7}
if v==day then
return true
end
else
--开服或合服列表格式是{{1,1},{5,9999}}
local start_day = v[1]
local end_day = v[2]
if day >= start_day and day <= end_day then
return true
end
end
end
return false
end
---------------------------------------------------------------------------------------------------------------
--获取活动奖励列表
function DailyModel:GetRewardList(module,module_sub,ac_sub)
local cfg_data = Config.Ac[module.."@"..module_sub.."@"..ac_sub]
local rewardList = {}
if not cfg_data then return rewardList end
rewardList = stringtotable(cfg_data.reward)[1][2]
return rewardList
end
-------------------------
--活动活跃度基础信息
function DailyModel:GetDailyBaseInfo( )
return self.daily_base_info
end
function DailyModel:SetDailyBaseInfo( value )
if not value then return end
-------------------------
for k,v in pairs(value.ac_list) do
v.conf_data = self:GetAcConfig(v.module, v.module_sub, v.ac_sub)
local liveness_conf = self:GetActLivenessConfig(v.module, v.module_sub)
v.conf_max = liveness_conf and liveness_conf.conf_max or 0
end
-------------------------
self.daily_base_info = self.daily_base_info or {}
self.daily_base_info.time = value.time
self.daily_base_info.power_live = value.power_live
self.daily_base_info.collect_coin = value.coin
self.daily_base_info.collect_honor = value.honor
self.daily_base_info.ac_list = self.daily_base_info.ac_list or {}
self.daily_base_info.ac_list[value.act_type] = value.ac_list
end
function DailyModel:GetOneDailyBaseInfo( module_id,module_sub,type_id )
if not self.daily_base_info then return end
if type_id then
if self.daily_base_info.ac_list[type_id] then
for k,v in pairs(self.daily_base_info.ac_list[type_id]) do
if v.module == module_id and v.module_sub == module_sub then
return v
end
end
end
else
for i=1,2 do
if self.daily_base_info.ac_list[i] then
for k,v in pairs(self.daily_base_info.ac_list[i]) do
if v.module == module_id and v.module_sub == module_sub then
return v
end
end
end
end
end
end
function DailyModel:RefreshOutLineHookTime( time )
if (not self.daily_base_info) or (not time) then return end
self.daily_base_info.time = time
end
-------------------------
--查询活动状态
function DailyModel:GetAcOpenStatus( module_id,module_sub )
if (not module_id) or (not module_sub) then return end
self.ac_open_status = self.ac_open_status or {}
return self.ac_open_status[module_id .. "@" .. module_sub]
end
function DailyModel:SetAcOpenStatus( value )
if not value then return end
self.ac_open_status = {}
for k,v in pairs(value) do
self.ac_open_status[v.module .. "@" .. v.module_sub] = v
end
end
function DailyModel:RefreshOneAcOpenStatus( value )
if not value then return end
if self.ac_open_status then
self.ac_open_status[value.module .. "@" .. value.module_sub] = value
return true
end
end
-- 通过活动数据控制活动开放情况
function DailyModel:SetActivityIconShow(act_data)
--双倍护送
if act_data.module == 500 and act_data.status == 1 then
ActivityIconManager:getInstance():addIcon(500, math.max(0,act_data.end_time - TimeUtil:getServerTime()))
GlobalEventSystem:Fire(EventName.OPEN_ACITVITY_TIP,500, 1, true)
end
--本服团战图标开放情况
if act_data.module == 405 and act_data.module_sub == 1 then
GuildModel:getInstance():Fire(GuildModel.GUILD_WAR_OPEN_STATE, act_data.status, act_data.end_time)
end
-- 狂战领域按钮开放
if act_data.module == 415 then
-- 活动状态为1也不稳,再多判断一个过期时间
if act_data.status == 1 and act_data.end_time - TimeUtil:getServerTime() > 0 then
ActivityIconManager:getInstance():addIcon(415, math.max(0, act_data.end_time - TimeUtil:getServerTime()))
-- RageWarModel:getInstance():CheckRageWarEventTipsView()
else
ActivityIconManager:getInstance():deleteIcon(415)
GlobalEventSystem:Fire(EventName.CLOSE_ACITVITY_TIP, 415, nil)
end
end
end
-------------------------
--查询活跃度信息
function DailyModel:GetLivenessInfo( )
return self.liveness_info
end
--查询活跃度
function DailyModel:GetLivenessInfoLive( )
return self.liveness_info and self.liveness_info.live or 0
end
function DailyModel:SetLivenessInfo( value )
self.liveness_info = value
end
-------------------------
--玩家活跃度形象
function DailyModel:GetLivenessFigureInfo( )
return self.liveness_figure_info
end
function DailyModel:SetLivenessFigureInfo( value )
self.liveness_figure_info = value
end
-------------------------
--资源找回界面信息
function DailyModel:GetResourceRecoveryList( )
local result_data = {}
local back_conf = false
local guild_id = RoleManager.Instance.mainRoleInfo.guild_id
for i,v in ipairs(self.resource_recovery_list or {}) do
back_conf = self:GetResactConfig(v.act_id, v.act_sub)
if back_conf then
-- if back_conf.guild_limit == 1 and guild_id == 0 then
-- --社团限制
-- else
local special_recover = self:RetRecoverSpecialReward(v.act_id, v.act_sub)
if special_recover and #special_recover == 0 then
--几个特殊的没有奖励不要显示啦
else
result_data[#result_data+1] = v
end
-- end
end
end
return result_data
end
function DailyModel:SetResourceRecoveryList( value )
self.resource_recovery_list = value or {}
end
function DailyModel:ChangeResourceRecoveryList( data )
if (not self.resource_recovery_list) or (not data) then return end
for k,v in pairs(self.resource_recovery_list or {}) do
if v.act_id == data.act_id and v.act_sub == data.act_sub then
v.lefttimes = value.lefttimes
v.reward_lv = value.reward_lv
return true
end
end
end
-------------------------
function DailyModel:GetTodayRewardIsLock( id )
local my_lv = RoleManager.Instance.mainRoleInfo.level
for k,v in pairs(Config.Activityreward) do
if v.id == id then
return my_lv < v.min_lv
end
end
return true
end
function DailyModel:CanGetTodayReward( check_new,id )
if not id then return false end
local liveness_data = self:GetLivenessInfo()
if not liveness_data then
return false
end
-------------------------
if check_new then
self.red_today_reward[id] = false
local lv_lock = self:GetTodayRewardIsLock(id)--未解锁状态
if lv_lock then
else
for k,v in pairs(liveness_data.reward_list) do
if v.id == id then
self.red_today_reward[id] = v.state == 1
break
end
end
end
end
return self.red_today_reward[id]
end
function DailyModel:CanGetTodayRewardAll( check_new )
if check_new then
local liveness_data = self:GetLivenessInfo()
if not liveness_data then return false end
-------------------------
for k,v in pairs(liveness_data.reward_list) do
self:CanGetTodayReward(true,v.id)
end
end
for k,v in pairs(self.red_today_reward) do
if v then return true end
end
return false
end
function DailyModel:GetCanUpLive( check_new )
if check_new then
self.red_liveness_up = false
if self:IsLivenessMaxLevel() then
else
local data = self:GetLivenessFigureInfo()
if data then
local conf = self:GetLivenessLvConfig(data.lv)
-------------------------
if data.exp >= conf.exp then
self.red_liveness_up = true
end
end
end
end
return self.red_liveness_up
end
function DailyModel:IsLivenessMaxLevel( )
local data = self:GetLivenessFigureInfo()
if not data then return false end
if self:GetLivenessLvConfig(data.lv+1) then
return false
else
return true
end
end
function DailyModel:GetTodayActivityList( )
local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
local data = self:GetWeekCalendarInfo()
local result_data = {}
for i,v in ipairs(data) do
if v[cur_weekday+1] ~= "" then
v[cur_weekday+1].time = v[1]
table.insert( result_data, v[cur_weekday+1] )
end
end
return result_data
end
--传参数判断是否活动时间内以及今天是否已结束以及下一次的开启时间
function DailyModel:GetActivityGoingStatus( time_region ,curTime )
-- local time_region = [[ [{{15,30},{16,0}},{{20,30},{20,40}}] ]]
if not time_region then return end
local time_list = false
if type(time_region) == "string" then
time_list = stringtotable(time_region)
else
time_list = time_region
end
-------------------------
curTime = curTime or TimeUtil:getServerTime()
local date = os.date("*t", curTime)
local date_zero={year=date.year,month=date.month,day=date.day,hour=0,min=0,sec=0}
-------------------------
local today_over = true--今天是否已结束
local is_going = false--是否时间内
local ending_time = false--最后的结束时间
local next_time = false
for i,v in ipairs(time_list) do
local start_time = os.time({year=date.year,month=date.month,day=date.day,hour=tonumber(v[1][1]),min=tonumber(v[1][2]),sec=0})
local end_time = os.time({year=date.year,month=date.month,day=date.day,hour=tonumber(v[2][1]),min=tonumber(v[2][2]),sec=0})
ending_time = ending_time or end_time
ending_time = ending_time > end_time and ending_time or end_time
if curTime >= start_time and curTime <= end_time then
is_going = true
break
end
if start_time > curTime then
next_time = next_time or start_time
next_time = next_time < start_time and next_time or start_time
end
end
if ending_time and ending_time > curTime then
today_over = false
end
return is_going,today_over,next_time
end
--找回红点
function DailyModel:GetRecoverRed( )
-- if self.mask_recover_red then return false end--一次性红点机制去除
local recover_list = self:GetResourceRecoveryList()
if recover_list and TableSize(recover_list) > 0 then
return true
end
return false
end
function DailyModel:RetRecoverSpecialReward( act_id, act_sub )
local function sort_func( data )
local result = {}
for k,v in pairs(data or {}) do
table.insert( result, v )
end
return result
end
if act_id == 610 then
if act_sub == BaseDungeonModel.DUN_TYPE.ONE_TOWER then--单人爬塔4
return sort_func(BaseDungeonModel:GetInstance():GetTowerDailyReward())
elseif act_sub == BaseDungeonModel.DUN_TYPE.IllusoryLight then--幻光副本(波数副本)7
return sort_func(BaseDungeonModel:GetInstance():GetLigthDunSweepAward())
elseif act_sub == BaseDungeonModel.DUN_TYPE.PET then--守卫幼宠8
return sort_func(BaseDungeonModel:GetInstance():GetDunPetHistoryMaxScore())
end
elseif act_id == 215 and act_sub == 2 then--绝地守卫
return sort_func(BaseDungeonModel:GetInstance():GetGuardianRecoveryReward())
end
return false
end
-------------------------------- 托管开始 --------------------------------
--获取托管配置列表
function DailyModel:GetHostingCfg( )
local config = DeepCopy(Config.Offlinehostingact)
local cur_weekday = tonumber(os.date("%w", TimeUtil:getServerTime()))
cur_weekday = cur_weekday ~= 0 and cur_weekday or 7
local list = {}
for k,v in pairs(config) do
local d = self:GetHostingItemCfg(v.module_id)
if d then
local tt = {}
for kk,vv in pairs(d) do
tt = vv
break
end
--今日是否已经开启
if d[cur_weekday] then
v.today_open = 1
else
v.today_open = 0
end
v.time_str = tt.time or "00:00~00:00"
table_insert(list, v)
end
end
--处理活动是否已经结束
local date = os.date("*t", TimeUtil:getServerTime())
local zero_min = date.hour * 60 + date.min -- 当前时区距0点的分钟数
local evt_time_start, evt_start_hour, evt_start_min
for k, v in ipairs(list) do
evt_time_start = Split((Split(v.time_str, "~")[1]),":")
evt_start_hour = evt_time_start[1]
evt_start_min = evt_time_start[2]
v.open_time = evt_start_hour * 60 + evt_start_min
if evt_start_hour * 60 + evt_start_min >= zero_min then
v.is_opened = 0
else
v.is_opened = 1
end
end
table.sort( list, function (a,b)
if a.today_open ~= b.today_open then
return a.today_open > b.today_open
else
return a.open_time < b.open_time
end
end)
return list
end
--获取托管配置列表
function DailyModel:GetHostingCfgItem(module_id, sub_id )
local config = Config.Offlinehostingact
for k,v in pairs(config) do
if v.module_id == module_id and v.mod_sub == sub_id then
return v
end
end
end
--获取托管配置列表
function DailyModel:GetHostingCfgItemBySubId(module_id, sub_id )
local config = Config.Offlinehostingact
for k,v in pairs(config) do
if v.module_id == module_id and v.sub_id == sub_id then
return v
end
end
end
--获取托管日常
function DailyModel:GetHostingItemCfg(module_id)
if not self.hosting_time_cfg then
local config = self:GetWeekCalendarInfo()
local time_cfg = {}
for k,v in pairs(config) do
for i=2,8 do
local tt = v[i]
if type(tt) == "table" then
time_cfg[tt.module_id] = time_cfg[tt.module_id] or {}
time_cfg[tt.module_id][i - 1] = time_cfg[tt.module_id][i - 1] or {}
time_cfg[tt.module_id][i - 1].time = v[1]
time_cfg[tt.module_id][i - 1].name = tt.name
end
end
end
self.hosting_time_cfg = time_cfg
end
return self.hosting_time_cfg[module_id]
end
--获取托管日常描述字符串
function DailyModel:GetHostingTimeString(module_id)
self.hosting_time_string_list = self.hosting_time_string_list or {}
if not self.hosting_time_string_list[module_id] then
local cfg = self:GetHostingItemCfg(module_id)
local str_list = {[1] ="", [2] = ""}
if cfg then
local time_list = {}
local day_list = {}
for day,v in pairs(cfg) do
table.insert(day_list, day)
local exit_time = false
if #time_list > 0 then
for ii,vv in ipairs(time_list) do
if vv == v.time then
exit_time = true
break
end
end
end
if not exit_time then
table.insert(time_list, v.time)
end
end
local time_str = ""
local day_str = ""
if #day_list == 7 then
day_str = "每天"
elseif #day_list == 6 then
local no_in_day = 1
for i,v in ipairs(day_list) do
if v ~= no_in_day or no_in_day == 7 then
break
end
no_in_day = no_in_day + 1
end
day_str = string.format("除周%s外", TimeUtil:GetWeekStrNum(no_in_day))
else
for i,v in ipairs(day_list) do
day_str = day_str == "" and ("".. TimeUtil:GetWeekStrNum(v)) or (day_str .."".. TimeUtil:GetWeekStrNum(v))
end
end
--只需要显示开始时间
local t_list = {}
for i,v in ipairs(time_list) do
local s_list = Split(v, "~")
if s_list and s_list[1] then
table_insert(t_list, s_list[1])
end
end
time_list = t_list
for i,v in ipairs(time_list) do
time_str = time_str == "" and v or (time_str .."".. v)
end
str_list[1] = day_str
str_list[2] = time_str
end
self.hosting_time_string_list[module_id] = str_list
end
return self.hosting_time_string_list[module_id]
end
--获取托管日常
function DailyModel:GetHostingIsOpenToday(module_id, weekday)
self.hosting_time_day_list = self.hosting_time_day_list or {}
if not self.hosting_time_day_list[module_id] then
local cfg = self:GetHostingItemCfg(module_id)
local day_list = {}
if cfg then
for day,v in pairs(cfg) do
day_list[day] = true
end
end
self.hosting_time_day_list[module_id] = day_list
end
if not weekday then
local time = TimeUtil:getServerTime()
local weekday = tonumber(os.date("%w", time))
if weekday == 0 then
weekday = 7
end
end
return self.hosting_time_day_list[module_id] and self.hosting_time_day_list[module_id][weekday]
end
--托管设置信息
function DailyModel:SetHostingInfo(vo)
self.hosting_info.now_value = vo.now_value
self.hosting_info.daily_value = vo.daily_value
self.hosting_info.setting_list = vo.close_list
if #self.hosting_info.setting_list > 0 then
for i,v in ipairs(self.hosting_info.setting_list) do
v.status = 0
end
end
self:Fire(DailyModel.HOSTING_SETTING_INFO)
end
--托管设置
function DailyModel:SetHostingSetting(vo)
local setting = false
self.hosting_info.setting_list = self.hosting_info.setting_list or {}
for i,v in ipairs(self.hosting_info.setting_list) do
if v.module == vo.module and v.sub_id == vo.sub_id then
setting = v
end
end
if not setting then
table.insert(self.hosting_info.setting_list, {module = vo.module, sub_id = vo.sub_id, status = vo.status})
else
setting.status = vo.status
end
self:Fire(DailyModel.HOSTING_SETTING_UPDATE, vo.module, vo.sub_id, vo.status)
end
--获取托管设置
function DailyModel:GetHostingSetting(module_id, sub_id)
local setting = false
self.hosting_info.setting_list = self.hosting_info.setting_list or {}
for i,v in ipairs(self.hosting_info.setting_list) do
if v.module == module_id and v.sub_id == sub_id then
setting = v
end
end
if not setting then
setting = {module = module_id, sub_id = sub_id, status = 1}
table.insert(self.hosting_info.setting_list, setting)
end
return setting and setting.status == 1
end
--获取托管设置
function DailyModel:GetHostingSettingAc(module_id, sub_id)
local ac = false
local cfg = Config.Offlinehostingact
for k,v in pairs(cfg) do
if module_id == v.module_id and sub_id == v.mod_sub then
ac = v
break
end
end
return ac
end
--托管记录
function DailyModel:SetHostingRecord(vo)
self.hosting_info.record_list = vo.list or {}
self:Fire(DailyModel.HOSTING_RECORE_UPDATE)
end
--托管图标
function DailyModel:GetHostingSettingIcon(module_id)
local config = Config.Ac
for k,v in pairs(config) do
if v.module == module_id then
return v.ac_icon
end
end
return ""
end
--托管奖励
function DailyModel:SetHostingReward(vo)
self.hosting_info.reward = {}
if #vo.list > 0 then
local cost = 0
local record_list = {}
local reward_list = {}
----------容错,先清掉没有配置的条目-------
local list = {}
for i,v in ipairs(vo.list) do
local item = self:GetHostingCfgItemBySubId(v.module, v.sub_id)
if item then
table.insert(list, v)
end
end
vo.list = list
----------容错,先清掉没有配置的条目 ------
for i,v in ipairs(vo.list) do
cost = cost + v.cost_value
local item = self:GetHostingCfgItemBySubId(v.module, v.sub_id)
local time_str = TimeUtil:timeConversion(v.time,"mm-dd hh:MM:ss")
local str = string.format("%s 为您托管%s活动", time_str, HtmlColorTxt(Trim(item.desc) , "#f3fcff"))
record_list[i] = {}
record_list[i].record_text = str
local list = v.reward_list or {}
if #list > 1 then
for i,v in ipairs(list) do
local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(v.typeId)
v.color = goodVo.color
end
table.sort(list, function (a,b)
if a.color ~= b.color then
return a.color > b.color
elseif a.typeId ~= b.typeId then
return a.typeId < b.typeId
else
return a.count > b.count
end
end)
end
record_list[i].reward_list = list
end
self.hosting_info.reward.record_list = record_list
self.hosting_info.reward.cost = cost
self:Fire(DailyModel.OPEN_HOSTING_REWARD_VIEW)
end
end
--获取托管红点
function DailyModel:GetHostingRed()
return self.hosting_red_dot
end
--完成托管红点
function DailyModel:SaveHostingRed()
if self.hosting_red_dot then
CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.HOSTING_SETTING_RED_SHOW, false)
CookieWrapper.Instance:WriteAll()
self.hosting_red_dot = false
end
end
--加载托管红点
function DailyModel:LoadHostingRed()
self.hosting_red_dot = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.HOSTING_SETTING_RED_SHOW) == nil and true or false
return self.hosting_red_dot
end
-------------------------------- 托管结束 --------------------------------
-------------------------------- 日常预约开始 --------------------------------
--设置日常预约所有数据
function DailyModel:SetDailyOrderAllData(vo)
self.daily_order_info = vo.reserve_list
local is_red = false
for k,v in pairs(self.daily_order_info ) do
if (v.status == DailyOrderStatus.UN_ORDER and not self:IsInActiviteDailyOrderOver(v.module, v.sub_module, v.ac_sub) or v.status == DailyOrderStatus.UN_GET) then
is_red = true
break
end
end
self.daily_order_red_dot = is_red
if self.daily_order_red_dot then
ActivityIconManager:getInstance():addIcon(1571, -1)
else
ActivityIconManager:getInstance():deleteIcon(1571)
end
GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 1571, is_red)
self:Fire(DailyModel.UPDATE_DAILY_ORDER_ALL_DATA)
end
--获取托管红点
function DailyModel:GetDailyOrderRed()
return self.daily_order_red_dot
end
function DailyModel:SetDailyOrderTargetData(target_vo)
if target_vo and self.daily_order_info then
for k,v in pairs(self.daily_order_info) do
if v.module == target_vo.module and v.sub_module == target_vo.sub_module and v.ac_sub == target_vo.ac_sub then
v.status = target_vo.status
end
end
local is_red = false
for k,v in pairs(self.daily_order_info ) do
if (v.status == DailyOrderStatus.UN_ORDER and not self:IsInActiviteDailyOrderOver(v.module, v.sub_module, v.ac_sub) or v.status == DailyOrderStatus.UN_GET) then
is_red = true
break
end
end
self.daily_order_red_dot = is_red
if self.daily_order_red_dot then
ActivityIconManager:getInstance():addIcon(1571, -1)
else
ActivityIconManager:getInstance():deleteIcon(1571)
end
self:Fire(DailyModel.UPDATE_DAILY_ORDER_TARGET_DATA, target_vo.module, target_vo.sub_module, target_vo.ac_sub)
GlobalEventSystem:Fire(ActivityIconManager.UPDATE_ICON_TIPS, 1571, is_red)
end
end
function DailyModel:GetDailyOrderTargetData(i_module, i_module_sub, i_ac_sub)
if self.daily_order_info then
for k,v in pairs(self.daily_order_info) do
if v.module == i_module and v.sub_module == i_module_sub and v.ac_sub == i_ac_sub then
return v.status
end
end
end
return -1
end
function DailyModel:GetDailyOrderTipsData(i_module, i_module_sub, i_ac_sub)
if not i_module or not i_module_sub or not i_ac_sub then
return false
end
local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
local cfg_ac = Config.Ac[key]
if cfg_ac then
return cfg_ac
end
end
function DailyModel:GetDailyOrderList()
local list = {}
if self.daily_order_info and #self.daily_order_info > 0 then
local cfg =Config.Actreserve
for k,v in pairs(self.daily_order_info) do
local key = v.module .. "@" .. v.sub_module .. "@" .. v.ac_sub
if cfg[key] then
local d = cfg[key]
d.status = v.status
table.insert(list, d)
end
end
if #list > 1 then
for i,v in ipairs(list) do
local is_end = self:IsActiviteDailyOrderEnd(v.module_id, v.module_sub, v.ac_sub)
local is_over = self:IsInActiviteDailyOrderOver(v.module_id, v.module_sub, v.ac_sub)
if v.status == DailyOrderStatus.UN_GET then
v.sort = 2
elseif v.status == DailyOrderStatus.UN_JOIN then
v.sort = 3
else
if is_end then
v.sort = 6
elseif is_over then
v.sort = 5
else
if v.status == DailyOrderStatus.UN_ORDER then
v.sort = 2
elseif v.status == DailyOrderStatus.DONE then
v.sort = 4
else
v.sort = 5
end
end
end
end
table.sort(list, function (a, b)
if a.sort == b.sort then
return a.index < b.index
else
return a.sort < b.sort
end
end)
end
end
return list
end
-- 获取预约活动每天的世界
function DailyModel:GetDailyOrderActiviteOpenTime( evt_time_data, need_week)
local time = false
local key = evt_time_data.module_id .. "@" .. evt_time_data.module_sub .. "@" .. evt_time_data.ac_sub
local cfg = Config.Ac[key]
if cfg then
local weekList = DailyModel.getInstance():GetParseList(cfg.week)
local time_region = stringtotable(cfg.time_region)
local week_time = ""
if #weekList == 7 or #weekList == 0 then
week_time = "每周"
else
for i,v in ipairs(weekList) do
if week_time == "" then
week_time = "" .. TimeUtil:GetWeekStrNum(tonumber(v))
else
week_time = week_time .. "" .. TimeUtil:GetWeekStrNum(tonumber(v))
end
end
end
local start_time
local end_time
if time_region and time_region[1] and time_region[1][1] and time_region[1][2] then
local t1 = time_region[1][1]
local t2 = time_region[1][2]
if t1[2] == 0 then
t1[2] = "00"
end
if t2[2] == 0 then
t2[2] = "00"
end
start_time = t1[1] .. ":" .. t1[2]
end_time = t2[1] .. ":" .. t2[2]
else
return false
end
if need_week then
time = week_time .. start_time .."-"..end_time
else
time = start_time .."-"..end_time
end
end
return time
end
-- 获取活动的每天活跃度
function DailyModel:GetDailyActiviteLive( i_module, i_module_sub)
local live = 0
local key = i_module .. "@" .. i_module_sub
local cfg = Config.Activityliveness[key]
if cfg then
if cfg.max < 100 then
live = cfg.max * cfg.live
else
live = cfg.live
end
end
return live
end
-- 获取预约活动每天的世界
function DailyModel:IsActiviteDailyOrderEnd( i_module, i_module_sub, i_ac_sub)
local is_end = false
local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
local cfg = Config.Ac[key]
if cfg then
local time_region = stringtotable(cfg.time_region)
if time_region and time_region[1] and #time_region[1] > 0 then
local cur_hour, cur_min = TimeUtil:getCurHourMinSce()
local time_table = time_region[1]
local end_hour = tonumber(time_table[#time_table][1])
local end_min = tonumber(time_table[#time_table][2])
if cur_hour > end_hour or (cur_hour == end_hour and cur_min >= end_min) then
is_end = true
end
end
end
return is_end
end
-- 当前是否在活动中(活动中,不让预约)
function DailyModel:IsInActiviteDailyOrderOver( i_module, i_module_sub, i_ac_sub)
local is_over = false
local key = i_module .. "@" .. i_module_sub .. "@" .. i_ac_sub
local cfg = Config.Ac[key]
if cfg then
local time_region = stringtotable(cfg.time_region)
if time_region and time_region[1] and #time_region[1] > 0 then
local cur_hour, cur_min = TimeUtil:getCurHourMinSce()
local time_table = time_region[1]
local end_hour = tonumber(time_table[1][1])
local end_min = tonumber(time_table[1][2])
if cur_hour > end_hour or (cur_hour == end_hour and cur_min >= end_min) then
is_over = true
end
end
end
return is_over
end
-------------------------------- 日常预约结束 --------------------------------
-- 获取指定活动的基本数据
function DailyModel:GetTargetDailyBaseInfo( i_module, i_module_sub)
local target_base_info = nil
local base_data = self:GetCommonShowList( )
if base_data then
-- for i,v in ipairs(base_data.ac_list) do
for ii,vv in ipairs(base_data) do
if vv.module == i_module and vv.module_sub == i_module_sub then
target_base_info = vv
break
end
end
-- end
end
return target_base_info
end
-- 获取指定活动的基本数据
function DailyModel:DailyCommonTipsCurNumAndMaxNum( base_data)
local ret_cur_num, ret_max_num = 0, 0
if base_data then
local cur_num = base_data.num
local max_num = base_data.show_max_times or base_data.max_times
-------------------------
local is_money_collect = base_data.module == 130 and base_data.ac_sub == 1
if is_money_collect then
if base_data.module_sub == 5 then
--交易券收集
max_num = Config.Counterdaily["157@3"].limit
cur_num = self.daily_base_info and self.daily_base_info.collect_coin or 0
elseif base_data.module_sub == 6 then
--名望券收集
max_num = Config.Counterdaily["157@4"].limit
cur_num = self.daily_base_info and self.daily_base_info.collect_honor or 0
end
end
-------------------------
if cur_num > max_num and max_num > 0 then
ret_cur_num = max_num
ret_max_num = max_num
else
local show_max_num = max_num
ret_cur_num = cur_num
ret_max_num = show_max_num
end
end
return ret_cur_num, ret_max_num
end
-- 日常活动前往
function DailyModel:DailyCommomItemGo(daily_data)
if daily_data then
if daily_data.module == 610 and daily_data.module_sub == 5001 and daily_data.ac_sub == 1 then
if ExpDunModel:getInstance():IsPassAllExpDun() then
--经验挂机达到上限之后,转成领取经验奖励
BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61050, 0, 0)
return
end
end
if daily_data.module == 130 and daily_data.ac_sub == 1 then
if daily_data.module_sub == 6 then
UIToolTipMgr:getInstance():AppendGoodsTips(Config.ConfigNotNormalGoods[4].goods_id,nil,nil,nil,nil,nil,nil,true)
return
elseif daily_data.module_sub == 5 then
UIToolTipMgr:getInstance():AppendGoodsTips(Config.ConfigNotNormalGoods[3].goods_id,nil,nil,nil,nil,nil,nil,true)
return
end
end
if daily_data.module == 300 and daily_data.conf_data.jump_id == 2 then
self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
if RoleManager.Instance.mainRoleInfo.guild_id>0 then
OpenFun.Open(daily_data.module,daily_data.conf_data.jump_id)
else
OpenFun.Open(400,0)
Message.show("请先加入社团")
end
elseif daily_data.module == 142 and daily_data.module_sub == 0 then
self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
OpenFun.Open(400,5)
elseif daily_data.module == 500 then
self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
EscortModel:getInstance():FlyToNpc()
else
self:Fire(DailyModel.CLOSE_DAILY_BASE_VIEW)
OpenFun.Open(daily_data.module, daily_data.conf_data.jump_id)
end
end
end