CSMainModel = CSMainModel or BaseClass(BaseVo, true)
|
|
local CSMainModel = CSMainModel
|
|
|
|
function CSMainModel:__init()
|
|
CSMainModel.Instance = self
|
|
self:Reset()
|
|
end
|
|
|
|
function CSMainModel:Reset()
|
|
self.legion_kv_cfg = {}--常量配置
|
|
self.task_cfg = {}--任务配置
|
|
self.active_awards_cfg = {}--活跃奖励配置
|
|
self.max_active_cfg_num = 0
|
|
self.exploit_rank_reward_cfg = {}--军功排名奖励配置
|
|
self.military_ranks_cfg = {}--军衔配置
|
|
|
|
self.exploit_can_get_reward_rank = 0--可领取奖励的最大排名
|
|
|
|
self.director_role_data = {}--指挥室人物形象数据
|
|
|
|
self.active_process = 0--活跃进度
|
|
self.active_dot = 0--当前领取进度
|
|
self.arms_num = 0--军备值
|
|
self.military_ranks = 0--军衔
|
|
self.exploit_rank_score = 0--排行军功
|
|
self.active_dot_list = {}--已领的活跃奖励节点列表
|
|
|
|
self.my_country_exploit_rank_num = 0--我的国家军功排行数量
|
|
|
|
self.last_guild_war_rank_data = {}--上期跨服团战排行,登录只请求一次并保存复用
|
|
self.last_military_score_rank_data = {}--上期军功排行
|
|
self.appoint_data_0 = {}--历史任命记录 前三主官
|
|
self.appoint_data_1 = {}--历史任命记录 指挥官员
|
|
|
|
self.click_worship_role_list = {}--已膜拜玩家列表
|
|
self.click_worship_role = 0--已膜拜玩家
|
|
self.my_exploit_last_rank = 0--前天排名
|
|
self.my_day_reward_state = 0--领取状态1已领取
|
|
|
|
self.cs_main_task_data = {}--任务数据
|
|
|
|
self.cs_main_red_info = {}--红点信息
|
|
|
|
self.task_red_by_color = {}--任务品质红点
|
|
|
|
self.advance_notice_reward_data = {}--预告奖励数据
|
|
|
|
self.has_request_60314 = false
|
|
self.has_request_60311 = false
|
|
|
|
self:InitCSMainCfg()
|
|
end
|
|
|
|
--关闭界面后需要重置的数据
|
|
function CSMainModel:ResetDataAfterCloseView( )
|
|
self.director_role_data = {}
|
|
end
|
|
|
|
function CSMainModel:getInstance()
|
|
if CSMainModel.Instance == nil then
|
|
CSMainModel.Instance = CSMainModel.New()
|
|
end
|
|
return CSMainModel.Instance
|
|
end
|
|
|
|
function CSMainModel:InitCSMainCfg( )
|
|
--常量配置
|
|
self.legion_kv_cfg = Config.Legionkv
|
|
|
|
--任务配置
|
|
for k,v in pairs(Config.Legiontask) do
|
|
self.task_cfg[v.color] = self.task_cfg[v.color] or {}
|
|
table.insert(self.task_cfg[v.color],v)
|
|
end
|
|
for k,v in pairs(self.task_cfg) do
|
|
local sort_func = function ( a, b )
|
|
return a.sort < b.sort
|
|
end
|
|
table.sort(v, sort_func)
|
|
end
|
|
|
|
--活跃奖励配置
|
|
self.max_active_cfg_num = 0
|
|
for k,v in pairs(Config.Legionactiveawards) do
|
|
self.active_awards_cfg[v.round] = self.active_awards_cfg[v.round] or {}
|
|
table.insert(self.active_awards_cfg[v.round],v)
|
|
self.max_active_cfg_num = self.max_active_cfg_num + 1
|
|
end
|
|
for k,v in pairs(self.active_awards_cfg) do
|
|
local sort_func = function ( a, b )
|
|
return a.id < b.id
|
|
end
|
|
table.sort(v, sort_func)
|
|
end
|
|
|
|
--军功排名奖励配置
|
|
local max_rank = 0
|
|
for k,v in pairs(Config.Legionrankreward) do
|
|
v.is_top = 0
|
|
table.insert(self.exploit_rank_reward_cfg,v)
|
|
if v.min_rank>max_rank then
|
|
max_rank = v.min_rank
|
|
end
|
|
end
|
|
self.exploit_can_get_reward_rank = max_rank
|
|
|
|
--军衔配置
|
|
self.military_ranks_cfg = Config.Legionpost
|
|
|
|
|
|
end
|
|
|
|
--获取军功排名最大显示数量
|
|
function CSMainModel:GetCSMainHonorMaxRank( )
|
|
return self.legion_kv_cfg["honor_max_rank"].value
|
|
end
|
|
|
|
--获取单次膜拜奖励
|
|
function CSMainModel:GetCSMainWorshipReward( )
|
|
return stringtotable(self.legion_kv_cfg["like_reward"].value)
|
|
end
|
|
|
|
--获取军衔排名最大显示数量
|
|
function CSMainModel:GetCSMainMilitaryMaxRank( )
|
|
-- return self.legion_kv_cfg["military_max_rank"].value
|
|
return 0
|
|
end
|
|
|
|
function CSMainModel:GetCSMainChaimanMaxRank( )
|
|
return self.legion_kv_cfg["chairman_max_rank"].value
|
|
end
|
|
|
|
function CSMainModel:GetCSMainCommanderMaxRank( )
|
|
return self.legion_kv_cfg["commander_max_rank"].value
|
|
end
|
|
|
|
--d_type 1|执政官 2|指挥官
|
|
function CSMainModel:GetCSMainDsgtId(d_type)
|
|
if d_type == 1 then
|
|
return stringtotable(self.legion_kv_cfg["chairman_reward"].value)[1][2]
|
|
elseif d_type == 2 then
|
|
return stringtotable(self.legion_kv_cfg["commander_reward"].value)[1][2]
|
|
end
|
|
return 0
|
|
end
|
|
|
|
--根据任务id获取任务配置
|
|
--品质 cfg.color
|
|
--描述 Trim(cfg.desc)
|
|
--跳转 stringtotable(cfg.link)[1], stringtotable(cfg.link)[2]
|
|
--条件 stringtotable(cfg.content)[3]
|
|
--奖励 stringtotable(cfg.awards)
|
|
function CSMainModel:GetCSMainTaskCfgByTaskId(task_id)
|
|
for k,v in pairs(self.task_cfg) do
|
|
for m,n in pairs(v) do
|
|
if n.id == task_id then
|
|
return n
|
|
end
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
--根据品质获取任务配置列表
|
|
function CSMainModel:GetCSMainTaskCfgByColor(color)
|
|
return self.task_cfg[color] and self.task_cfg[color] or {}
|
|
end
|
|
|
|
--排序后的任务配置列表
|
|
function CSMainModel:GetCSMainTaskCfgAfterSort(color)
|
|
if not self.task_cfg[color] then return {} end
|
|
local final_task = DeepCopy(self.task_cfg[color])
|
|
for k,v in pairs(final_task) do
|
|
local task_data = self:GetCSMainTaskDataById(v.id)
|
|
if task_data then--0不可领1可领取2已领取
|
|
if task_data.state == 0 then
|
|
v.first_sort = 2
|
|
elseif task_data.state == 1 then
|
|
v.first_sort = 3
|
|
elseif task_data.state == 2 then
|
|
v.first_sort = 0
|
|
else
|
|
v.first_sort = 1
|
|
end
|
|
else
|
|
v.first_sort = 1
|
|
end
|
|
end
|
|
local arg = {"first_sort", "sort"}
|
|
local condition = {Array.UPPER, Array.LOWER}
|
|
SortTools.MoreKeysSorter(final_task, arg, condition)
|
|
return final_task
|
|
end
|
|
|
|
--根据领奖进度获取最新的一组5个活跃配置
|
|
function CSMainModel:GetCSMainActiveRewardsCfgByProgress(progress_id)
|
|
if progress_id%5 == 0 and progress_id ~= 0 and progress_id ~= self.max_active_cfg_num then--要进一位拿下一组配置
|
|
progress_id = progress_id + 1
|
|
end
|
|
local round = 1
|
|
for k,v in pairs(self.active_awards_cfg) do
|
|
for m,n in pairs(v) do
|
|
if n.id == progress_id then
|
|
round = n.round
|
|
return self.active_awards_cfg[round]
|
|
end
|
|
end
|
|
end
|
|
return self.active_awards_cfg[round] and self.active_awards_cfg[round] or nil
|
|
end
|
|
|
|
--获取上一页的活跃配置
|
|
function CSMainModel:GetCSMainLastPageActiveCfg(progress_id)
|
|
-- if progress_id%5 == 0 and progress_id ~= 0 then--要进一位拿下一组配置
|
|
-- progress_id = progress_id + 1
|
|
-- end
|
|
local round = 0
|
|
for k,v in pairs(self.active_awards_cfg) do
|
|
for m,n in pairs(v) do
|
|
if n.id == progress_id then
|
|
round = n.round
|
|
return self.active_awards_cfg[round]
|
|
end
|
|
end
|
|
end
|
|
return self.active_awards_cfg[round] and self.active_awards_cfg[round] or nil
|
|
end
|
|
|
|
--根据军衔等级获取军衔配置
|
|
function CSMainModel:GetCSMainLegionMilitaryRanksCfg(military_ranks_lv)
|
|
return self.military_ranks_cfg[military_ranks_lv] and self.military_ranks_cfg[military_ranks_lv] or nil
|
|
end
|
|
|
|
|
|
------------------红点----start
|
|
function CSMainModel:IsNeedRedAll( )
|
|
for k,v in pairs(CSMainConst.RedType) do
|
|
self:IsNeedRed(v)
|
|
end
|
|
end
|
|
|
|
function CSMainModel:IsNeedRed(tab_id)
|
|
local bool = false
|
|
if GetModuleIsOpen(603) and self:IsCSMainKfNumEnough() then
|
|
if tab_id == CSMainConst.RedType.Task then--完成任务1
|
|
bool = self:CheckTaskRed()
|
|
elseif tab_id == CSMainConst.RedType.Active then--可领活跃奖励2
|
|
bool = self:CheckActiveRed()
|
|
elseif tab_id == CSMainConst.RedType.DailyReward then--每日奖励可领取3
|
|
bool = self:CheckDailyRewardRed()
|
|
elseif tab_id == CSMainConst.RedType.MilitaryRanks then--军衔可晋升4
|
|
bool = self:CheckMilitaryRanksRed()
|
|
elseif tab_id == CSMainConst.RedType.SandTable then--跨服沙盘总红点5
|
|
bool = self:CheckSandTableRed()
|
|
elseif tab_id == CSMainConst.RedType.WorShip then--膜拜红点
|
|
bool = self:CheckWorShipRed()
|
|
end
|
|
else
|
|
if tab_id == CSMainConst.RedType.NoticeReward then--预告奖励红点
|
|
bool = self:CheckNoticeRewardRed()
|
|
end
|
|
end
|
|
self.cs_main_red_info[tab_id] = bool
|
|
self:Fire(CSMainConst.ANS_UPDATE_RED_DOT,tab_id)
|
|
end
|
|
|
|
function CSMainModel:GetMainRed( )
|
|
local bool = false
|
|
for i,v in pairs(self.cs_main_red_info) do
|
|
if v then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
return bool
|
|
end
|
|
|
|
--完成任务红点1
|
|
function CSMainModel:GetTaskRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.Task]
|
|
end
|
|
|
|
--获取相应品质的任务完成红点
|
|
function CSMainModel:GetTaskRedByColor(color)
|
|
return self.task_red_by_color[color] and self.task_red_by_color[color] or false
|
|
end
|
|
|
|
function CSMainModel:CheckTaskRed( )
|
|
local bool = false
|
|
for k,v in pairs(self.task_cfg) do
|
|
self.task_red_by_color[k] = false
|
|
for m,n in pairs(v) do
|
|
local task_data = self:GetCSMainTaskDataById(n.id)
|
|
if task_data and task_data.state == 1 then--可领取
|
|
bool = true
|
|
self.task_red_by_color[n.color] = true
|
|
end
|
|
end
|
|
end
|
|
return bool
|
|
end
|
|
|
|
--可领活跃奖励红点2
|
|
function CSMainModel:GetActiveRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.Active]
|
|
end
|
|
|
|
function CSMainModel:CheckActiveRed( )
|
|
local bool = false
|
|
for k,v in pairs(self.active_awards_cfg) do
|
|
for m,n in pairs(v) do
|
|
if self.active_process >= n.active then
|
|
if not self:IsCSMainActiveDotRewardGet(n.id) then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return bool
|
|
end
|
|
|
|
--每日奖励可领取红点3
|
|
function CSMainModel:GetDailyRewardRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.DailyReward]
|
|
end
|
|
|
|
function CSMainModel:CheckDailyRewardRed( )
|
|
local bool = false
|
|
--上榜,且领奖状态为0 可以给红点
|
|
if self.my_exploit_last_rank ~= 0 and self.my_day_reward_state == 0 then
|
|
bool = true
|
|
end
|
|
return bool
|
|
end
|
|
|
|
--军衔可晋升红点4
|
|
function CSMainModel:GetMilitaryRanksRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.MilitaryRanks]
|
|
end
|
|
|
|
function CSMainModel:CheckMilitaryRanksRed( )
|
|
local bool = false
|
|
local military_ranks = self:GetCSMainMilitaryRanks()
|
|
local now_military_cfg = self:GetCSMainLegionMilitaryRanksCfg(military_ranks)
|
|
local next_military_cfg = self:GetCSMainLegionMilitaryRanksCfg(military_ranks+1)
|
|
local have_next = next_military_cfg and true or false
|
|
if not have_next then return false end
|
|
|
|
--战力达标
|
|
local enough_power = RoleManager.Instance.mainRoleInfo.fighting >= now_military_cfg.need
|
|
|
|
--晋升令
|
|
local cost_goods_data = stringtotable(now_military_cfg.cost)
|
|
if not cost_goods_data[1] or (cost_goods_data[1] and cost_goods_data[1][3] == 0)then
|
|
cost_goods_data[1] = {0,100019,0}
|
|
end
|
|
local goods_type_id = cost_goods_data[1][2]
|
|
local cost_need_num = cost_goods_data[1][3]
|
|
local cost_have_num = GoodsModel:getInstance():GetTypeGoodsNum(goods_type_id)
|
|
local enough_cost = cost_have_num >= cost_need_num
|
|
|
|
bool = enough_cost and enough_power
|
|
return bool
|
|
end
|
|
|
|
--跨服沙盘总红点5
|
|
function CSMainModel:GetSandTableRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.SandTable]
|
|
end
|
|
|
|
function CSMainModel:CheckSandTableRed( )
|
|
local bool = false
|
|
bool = SandTableModel:getInstance():GetRedDot(false)
|
|
return bool
|
|
end
|
|
|
|
--膜拜红点
|
|
function CSMainModel:GetWorShipRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.WorShip]
|
|
end
|
|
|
|
function CSMainModel:CheckWorShipRed( )
|
|
local bool = false
|
|
--膜拜列表不足五人且排行榜有人可以给红点
|
|
if self.my_country_exploit_rank_num > 5 then
|
|
if #self.click_worship_role_list < 5 then
|
|
bool = true
|
|
end
|
|
else
|
|
if #self.click_worship_role_list < self.my_country_exploit_rank_num then
|
|
bool = true
|
|
end
|
|
end
|
|
|
|
return bool
|
|
end
|
|
|
|
--预告奖励红点
|
|
function CSMainModel:GetNoticeRewardRed( )
|
|
return self.cs_main_red_info[CSMainConst.RedType.NoticeReward]
|
|
end
|
|
|
|
function CSMainModel:CheckNoticeRewardRed( )
|
|
local bool = false
|
|
--处于预告阶段且有奖励可领可以给红点
|
|
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
|
|
local _,cfg = GetModuleIsOpen(603)
|
|
local left_day = cfg.open_day-openDay
|
|
local open_lv = GetModuleOpenLevel(603)
|
|
local is_kf_num_enough, is_kf_state = CSMainModel:getInstance():IsCSMainKfNumEnough()
|
|
if open_lv <= RoleManager.Instance.mainRoleInfo.level and left_day <= 0 and is_kf_state and is_kf_num_enough then
|
|
bool = false
|
|
else
|
|
local now_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
|
|
for i=1,now_day do
|
|
local can_get_reward = self:CanDayGetCSMainAdvanceNoticeReward(i)
|
|
if can_get_reward then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return bool and RoleManager.Instance.mainRoleInfo.level >= 96
|
|
end
|
|
|
|
------------------红点----end
|
|
|
|
--晋升指令道具数量刷新
|
|
function CSMainModel:UpdateCSMainMilitaryAdvanceCostNum( )
|
|
self:Fire(CSMainConst.UPDATE_CS_MAIN_GOODS_NUM)
|
|
end
|
|
|
|
|
|
--60300 指挥室人物figure信息
|
|
function CSMainModel:SetCSMainDirectorData(vo)
|
|
for i=1,7 do
|
|
self.director_role_data[i] = {}
|
|
self.director_role_data[i].pos = i
|
|
self.director_role_data[i].rid = 0
|
|
end
|
|
for k,v in pairs(vo.director_role) do
|
|
self.director_role_data[v.pos] = v
|
|
end
|
|
end
|
|
|
|
--60306 主动请求刷新的人物figure信息
|
|
function CSMainModel:UpdateCSMainDirectorData(vo)
|
|
local change_pos = 0
|
|
for k,v in pairs(self.director_role_data) do
|
|
if v.rid == vo.role_id then
|
|
change_pos = v.pos
|
|
break
|
|
end
|
|
end
|
|
if change_pos ~= 0 then
|
|
self.director_role_data[change_pos] = vo
|
|
self.director_role_data[change_pos].pos = change_pos
|
|
self.director_role_data[change_pos].rid = vo.role_id
|
|
end
|
|
end
|
|
|
|
--根据位置获取人物figure信息
|
|
function CSMainModel:GetCSMainDirectorDataByPos(pos)
|
|
return self.director_role_data[pos]
|
|
end
|
|
|
|
--60301 任务单数据
|
|
function CSMainModel:SetCSMainTaskData(vo)
|
|
self.active_process = vo.process--活跃进度
|
|
self.arms_num = vo.arms--军备值
|
|
self.active_dot_list = vo.dot_list
|
|
local sort_func = function ( a, b )
|
|
return a.hot < b.hot
|
|
end
|
|
table.sort(self.active_dot_list, sort_func)
|
|
|
|
self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--当前领取进度
|
|
|
|
self.military_ranks = vo.post--军衔
|
|
self.exploit_rank_score = vo.rank_score--排行军功
|
|
|
|
self:ChangeVar("active_process", self.active_process, false, true)
|
|
self:ChangeVar("active_dot", self.active_dot, false, true)
|
|
self:ChangeVar("arms_num", self.arms_num, false, true)
|
|
self:ChangeVar("exploit_rank_score", self.exploit_rank_score, false, true)
|
|
|
|
for k,v in pairs(vo.missions) do
|
|
self.cs_main_task_data[v.id] = v
|
|
end
|
|
end
|
|
|
|
function CSMainModel:TestActiveDotList( )
|
|
self.active_dot_list = {
|
|
{hot = 1},
|
|
{hot = 2},
|
|
{hot = 3},
|
|
{hot = 4},
|
|
{hot = 5},
|
|
{hot = 6},
|
|
-- {hot = 8},
|
|
-- {hot = 10},
|
|
}
|
|
self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--当前领取进度
|
|
Message.show(self.active_dot)
|
|
self:ChangeVar("active_dot", self.active_dot, false, true)
|
|
end
|
|
|
|
--计算活跃奖励领取进度(用于判断是哪一页活跃)
|
|
function CSMainModel:SetCSMainActiveDot(vo)
|
|
local last_dot = 0
|
|
|
|
for i,v in ipairs(vo) do
|
|
if last_dot == v.hot - 1 then
|
|
last_dot = v.hot
|
|
else
|
|
return last_dot
|
|
end
|
|
end
|
|
|
|
return last_dot
|
|
end
|
|
|
|
--60304 领取任务奖励、活跃奖励后刷新数据
|
|
function CSMainModel:SetCSMainGetRewardData(vo)
|
|
if vo.opty == 0 then--活跃
|
|
local have_same = false
|
|
for k,v in pairs(self.active_dot_list) do
|
|
if v.hot == vo.args then
|
|
have_same = true
|
|
end
|
|
end
|
|
if not have_same then
|
|
local temp = {hot = vo.args}
|
|
table.insert(self.active_dot_list,temp)
|
|
end
|
|
local sort_func = function ( a, b )
|
|
return a.hot < b.hot
|
|
end
|
|
table.sort(self.active_dot_list, sort_func)
|
|
self.active_dot = self:SetCSMainActiveDot(self.active_dot_list)--当前领取进度
|
|
self:ChangeVar("active_dot", self.active_dot, false, true)
|
|
|
|
elseif vo.opty == 1 then--任务
|
|
|
|
end
|
|
end
|
|
|
|
--判断该活跃节点奖励是否已经领取过
|
|
function CSMainModel:IsCSMainActiveDotRewardGet(dot)
|
|
local bool = false
|
|
for k,v in pairs(self.active_dot_list) do
|
|
if dot == v.hot then
|
|
bool = true
|
|
end
|
|
end
|
|
return bool
|
|
end
|
|
|
|
--60302 任务更新
|
|
function CSMainModel:UpdateCSMainTaskData(vo)
|
|
self.cs_main_task_data[vo.id] = self.cs_main_task_data[vo.id] or {}
|
|
self.cs_main_task_data[vo.id].id = vo.id
|
|
self.cs_main_task_data[vo.id].bar = vo.bar
|
|
self.cs_main_task_data[vo.id].state = vo.state
|
|
end
|
|
|
|
function CSMainModel:Test60303( )
|
|
local vo = {
|
|
updatas = {
|
|
[1] = {kdata=1,vdata=550},
|
|
}
|
|
}
|
|
self:UpdateCSMainKeyValue(vo)
|
|
end
|
|
|
|
--60303 指定值更新
|
|
function CSMainModel:UpdateCSMainKeyValue(vo)
|
|
for k,v in pairs(vo.updatas) do
|
|
if v.kdata == 1 then--process活跃进度
|
|
self.active_process = v.vdata
|
|
self:ChangeVar("active_process", self.active_process, false, true)
|
|
-- elseif v.kdata == 2 then--dot当前领取进度
|
|
-- self.active_dot = v.vdata
|
|
-- self:ChangeVar("active_dot", self.active_dot, false, true)
|
|
elseif v.kdata == 3 then--arms军备值
|
|
self.arms_num = v.vdata
|
|
self:ChangeVar("arms_num", self.arms_num, false, true)
|
|
-- elseif v.kdata == 4 then--score军功(没这玩意了)
|
|
-- self.exploit_score = v.vdata
|
|
-- self:ChangeVar("exploit_score", self.exploit_score, false, true)
|
|
elseif v.kdata == 5 then--score排行军功
|
|
self.exploit_rank_score = v.vdata
|
|
self:ChangeVar("exploit_rank_score", self.exploit_rank_score, false, true)
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取当前活跃进度
|
|
function CSMainModel:GetCSMainActiveProcess( )
|
|
return self.active_process
|
|
end
|
|
|
|
--获取当前活跃领取进度
|
|
function CSMainModel:GetCSMainActiveDot( )
|
|
return self.active_dot
|
|
end
|
|
|
|
--获取当前军备值
|
|
function CSMainModel:GetCSMainArmsNum( )
|
|
return self.arms_num
|
|
end
|
|
|
|
--获取当前军衔
|
|
function CSMainModel:GetCSMainMilitaryRanks( )
|
|
return self.military_ranks
|
|
end
|
|
|
|
--根据军衔判断大军衔等级,用于获取大军衔图标
|
|
function CSMainModel:GetCSMainHighMilitaryRanks(ranks)
|
|
if ranks == 0 then return 1 end
|
|
return math.floor((ranks-1)/5)+1
|
|
end
|
|
|
|
--获取当前排行军功
|
|
function CSMainModel:GetCSMainExploitRankScore( )
|
|
return self.exploit_rank_score
|
|
end
|
|
|
|
--获取指定id的任务
|
|
function CSMainModel:GetCSMainTaskDataById(task_id)
|
|
return self.cs_main_task_data[task_id] and self.cs_main_task_data[task_id] or nil
|
|
end
|
|
|
|
--60305 军衔进阶更新数据
|
|
function CSMainModel:UpdateCSMainMilitaryRanksData(vo)
|
|
self.military_ranks = vo.post
|
|
end
|
|
|
|
--60308 榜单界面相关数据更新 膜拜玩家、前日排名、每日奖励领取状态等
|
|
function CSMainModel:UpdateCSMainExploitData(vo)
|
|
-- self.click_worship_role = vo.click_role--已膜拜玩家
|
|
|
|
self.click_worship_role_list = vo.click_list--已膜拜玩家列表
|
|
-- self.click_worship_role_list = {}
|
|
|
|
self.my_exploit_last_rank = vo.last_rank--前天排名
|
|
self.my_day_reward_state = vo.day_award--领取状态1已领取
|
|
|
|
for i,v in ipairs(self.exploit_rank_reward_cfg) do
|
|
v.is_top = 0
|
|
if v.min_rank <= self.my_exploit_last_rank and v.max_rank >= self.my_exploit_last_rank then
|
|
if self.my_day_reward_state == 0 then
|
|
v.is_top = 1
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--60310 刷新奖励领取状态为领取完
|
|
function CSMainModel:UpdateRankRewardState( )
|
|
for i,v in ipairs(self.exploit_rank_reward_cfg) do
|
|
v.is_top = 0
|
|
end
|
|
self.my_day_reward_state = 1
|
|
end
|
|
|
|
--获取排序的排行奖励配置
|
|
function CSMainModel:GetCSMainSortExploitRankRewardCfg( )
|
|
local arg = {"is_top","id"}
|
|
local condition = {Array.UPPER,Array.LOWER}
|
|
SortTools.MoreKeysSorter(self.exploit_rank_reward_cfg, arg, condition)
|
|
return self.exploit_rank_reward_cfg
|
|
end
|
|
|
|
--获取到当前已膜拜的玩家id
|
|
function CSMainModel:GetCSMainClickWorshipRole( )
|
|
return self.click_worship_role
|
|
end
|
|
|
|
--判断当前玩家是否可以膜拜
|
|
function CSMainModel:CanPlayerWorship(role_id)
|
|
local can_worship = true
|
|
local max_worship_num = 5
|
|
if self.my_country_exploit_rank_num < 5 then
|
|
max_worship_num = self.my_country_exploit_rank_num
|
|
end
|
|
if #self.click_worship_role_list >= max_worship_num then
|
|
return false
|
|
end
|
|
for k,v in pairs(self.click_worship_role_list) do
|
|
if v.click_role == role_id then
|
|
can_worship = false
|
|
end
|
|
end
|
|
return can_worship
|
|
end
|
|
|
|
--获取自己前日的军功排名
|
|
function CSMainModel:GetCSMainMyExploitLastRank( )
|
|
return self.my_exploit_last_rank
|
|
end
|
|
|
|
--前日军功排名奖励是否已领取
|
|
function CSMainModel:CanGetCSMainExploitDailyReward( )
|
|
return self.my_day_reward_state == 1
|
|
end
|
|
|
|
--60309 膜拜后刷新
|
|
function CSMainModel:UpdateCSMainClickWorshipRole(vo)
|
|
local can_join = true
|
|
for k,v in pairs(self.click_worship_role_list) do
|
|
if v.click_role == vo.aim then
|
|
can_join = false
|
|
end
|
|
end
|
|
if can_join then
|
|
local temp = {click_role = vo.aim}
|
|
table.insert(self.click_worship_role_list,temp)
|
|
end
|
|
end
|
|
|
|
--60314 保存上期跨服团战成绩排行
|
|
function CSMainModel:SetLastGuildWarScoreRankData(vo)
|
|
self.last_guild_war_rank_data = vo.ranks
|
|
local max_rank_num = self:GetCSMainChaimanMaxRank()
|
|
--如果不足50条,补满他
|
|
for i=#self.last_guild_war_rank_data+1, max_rank_num do
|
|
local temp = {rank = i, empty_data = true}
|
|
table.insert(self.last_guild_war_rank_data,temp)
|
|
end
|
|
local sort_func = function ( a, b )
|
|
return a.rank < b.rank
|
|
end
|
|
table.sort(self.last_guild_war_rank_data, sort_func)
|
|
self.has_request_60314 = true
|
|
end
|
|
|
|
--获取上期跨服团战成绩排行
|
|
function CSMainModel:GetLastGuildWarScoreRankData( )
|
|
return self.last_guild_war_rank_data
|
|
end
|
|
|
|
--60311 保存上期军功成绩排行
|
|
function CSMainModel:SetLastMilitaryScoreRankData(vo)
|
|
self.last_military_score_rank_data = vo.ranks
|
|
local max_rank_num = self:GetCSMainCommanderMaxRank()
|
|
--如果不足50条,补满他
|
|
for i=#self.last_military_score_rank_data+1, max_rank_num do
|
|
local temp = {rank = i, empty_data = true}
|
|
table.insert(self.last_military_score_rank_data,temp)
|
|
end
|
|
local sort_func = function ( a, b )
|
|
return a.rank < b.rank
|
|
end
|
|
table.sort(self.last_military_score_rank_data, sort_func)
|
|
self.has_request_60311 = true
|
|
end
|
|
|
|
--获取上期跨服团战成绩排行
|
|
function CSMainModel:GetLastMilitaryScoreRankData( )
|
|
return self.last_military_score_rank_data
|
|
end
|
|
|
|
--60312 历史任命名单
|
|
function CSMainModel:SetAppointData(vo)
|
|
local final_time_logs = {}
|
|
for k,v in pairs(vo.time_logs) do
|
|
local can_join = true
|
|
for m,n in pairs(v.servers) do
|
|
if #n.directors == 0 then
|
|
can_join = false
|
|
end
|
|
end
|
|
if can_join then
|
|
table.insert(final_time_logs,v)
|
|
end
|
|
end
|
|
self["appoint_data_"..vo.opty] = final_time_logs
|
|
|
|
local sort_func = function ( a, b )
|
|
return a.issue > b.issue
|
|
end
|
|
table.sort(self["appoint_data_"..vo.opty], sort_func)
|
|
end
|
|
|
|
--获取任命名单
|
|
function CSMainModel:GetAppointData(appoint_type)
|
|
return self["appoint_data_"..appoint_type] and self["appoint_data_"..appoint_type] or {}
|
|
end
|
|
|
|
--60307 记录我的国家军功排行数量
|
|
function CSMainModel:SetMyCountryExploitRankNum(vo)
|
|
local my_contray_id = KfWorldModel:GetInstance():GetMyCountryId()
|
|
if my_contray_id and my_contray_id == vo.fact then
|
|
if vo and vo.ranks then
|
|
self.my_country_exploit_rank_num = #vo.ranks
|
|
end
|
|
end
|
|
end
|
|
|
|
--是否达到世界等级
|
|
function CSMainModel:IsCSMainKfNumEnough( )
|
|
-- local world_lv = RoleManager.Instance.mainRoleInfo.worldLv
|
|
-- local need_world_lv = 999
|
|
-- return world_lv >= need_world_lv
|
|
|
|
local tip_info = KfWorldModel:GetInstance():GetKfWorldTipInfo()
|
|
if not tip_info or TableSize(tip_info) < 1 then return false end
|
|
local kf_num = math.pow(2, tip_info.next_stage-1)
|
|
|
|
local enough_kf_num = kf_num >= 4
|
|
|
|
local is_kf_state = true
|
|
local info = KfWorldModel:GetInstance():GetKfWorldInfo()
|
|
if IsTableEmpty(info) then
|
|
is_kf_state = false
|
|
end
|
|
if info.stage and info.stage == 0 then
|
|
is_kf_state = false
|
|
end
|
|
|
|
return enough_kf_num, is_kf_state
|
|
end
|
|
|
|
--60315 预告奖励领取数据
|
|
function CSMainModel:SetCSMainAdvanceNoticeRewardData(vo)
|
|
self.advance_notice_reward_data = vo.lists
|
|
end
|
|
|
|
--60316 更新预告奖励领取数据
|
|
function CSMainModel:UpdateCSMainAdvanceNoticeRewardData(vo)
|
|
local has_same_day = false
|
|
for k,v in pairs(self.advance_notice_reward_data) do
|
|
if v.day == vo.day then
|
|
has_same_day = true
|
|
break
|
|
end
|
|
end
|
|
if not has_same_day then
|
|
local temp = {day = vo.day}
|
|
table.insert(self.advance_notice_reward_data,temp)
|
|
end
|
|
end
|
|
|
|
--获取预告奖励数据
|
|
function CSMainModel:GetCSMainAdvanceNoticeRewardData( )
|
|
return self.advance_notice_reward_data
|
|
end
|
|
|
|
--判断某天的奖励是否可以领取
|
|
function CSMainModel:CanDayGetCSMainAdvanceNoticeReward(day)
|
|
if day <= 0 then return false end
|
|
local _,cfg = GetModuleIsOpen(603)
|
|
if cfg.open_day == day then return false end
|
|
local can_get_reward = true
|
|
for k,v in pairs(self.advance_notice_reward_data) do
|
|
if v.day == day then
|
|
can_get_reward = false
|
|
break
|
|
end
|
|
end
|
|
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
|
|
local enough_day = day <= openDay
|
|
return can_get_reward and enough_day
|
|
end
|
|
|
|
--判断某天之前或之后是否有奖励可以领取 day_type 1|之前 2|之后
|
|
function CSMainModel:CanDayGetCSMainAdvanceNoticeRewardBeforeOrAfter(day,day_type)
|
|
local openDay = ServerTimeModel:getInstance():GetOpenServerDay()
|
|
local _,cfg = GetModuleIsOpen(603)
|
|
local max_show_day = openDay <= cfg.open_day-1 and openDay or cfg.open_day-1
|
|
local bool = false
|
|
if day_type == 1 then
|
|
for i=1,day-1 do
|
|
if self:CanDayGetCSMainAdvanceNoticeReward(i) then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
elseif day_type == 2 then
|
|
for i=day+1,max_show_day do
|
|
if self:CanDayGetCSMainAdvanceNoticeReward(i) then
|
|
bool = true
|
|
break
|
|
end
|
|
end
|
|
end
|
|
return bool
|
|
end
|