local Guild_Controller = {} local private = {} local TIMEOUTVALUE = DataSheetManager.ConstData:GetDataByID("GuildInvitationExistTime").IntValue local TIMEOUTVALUE_AUTO = DataSheetManager.ConstData:GetDataByID("GuildAutoInviteExistTime").IntValue local timerHandle = nil local showList = {} local cdTime = nil local EventSystem = require('Event/EventSystem') local ENBLEM_FRAME_PATH = ConstAssetPathConfig.ENBLEM_FRAME_PATH local MODEL_FORMAT = "%s·%s" local GUILD_COMMUNITY_OPEN_CN = DataSheetManager.ConstData:GetDataByID("GuildCommunityOpen_CN").IntValue local GUILD_COMMUNITY_OPEN = DataSheetManager.ConstData:GetDataByID("GuildCommunityOpen").IntValue local GUILD_BALANCE_PREVIEW_DAY = DataSheetManager.ConstData:GetDataByID("GuildFirstRankTime").IntValue local GUILD_FAMOUS_COUNT = DataSheetManager.ConstData:GetDataByID("GuildPrestigiousNum").IntValue local GUILD_BALANCE_TIME_ID = DataSheetManager.ConstData:GetDataByID("GuildReputationRankTime").IntListValue local IDS_Guild_Elite = "IDS_Guild_Elite" local IDS_Guild_Populace = "IDS_Guild_Populace" local SAME_GUILD_COLOR = "80A9F5" local DIFF_GUILD_COLOR = "E9D076" local guild_base_pb = require("Proto/guild_base_pb") local ConstLeaderRedKey = "ConstLeaderRedKey" Guild_Controller.UnOpenGuildWelfare = { } Guild_Controller.GuildCommunityType = { All = 1, CN = 2, Oversea = 3, } --暂未开放的活动,显示敬请期待 Guild_Controller.UnOpenGuildActivity = { [998] = 1, } Guild_Controller.GuildLeaderTaskRewardState_UnFinished = -1 --未完成 Guild_Controller.GuildLeaderTaskRewardState_CanGet = 0 --已完成待领取 Guild_Controller.GuildLeaderTaskRewardState_HasGet = 1 --已领取 Guild_Controller.WelfareType = { Contribute = 1, Allies = 2, Shop = 3, Cultivation = 4, Target = 5, Salary = 6, LeaderReward = 7, } function Guild_Controller.OnStartup() EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, Guild_Controller.RefreshRedPoint) EventSystem.Regist(EventID.UI_ChannelChat_OnJoinChannel, Guild_Controller.OnJoinChannel) EventSystem.Regist(EventID.BagItem_Update, Guild_Controller.DonateRed) EventSystem.Regist(EventID.FunctionUnlockUpdate, Guild_Controller.AlliesRed) EventSystem.Regist(EventID.New_Day_Refresh, Guild_Controller.AlliesRed) EventSystem.Regist(EventID.UI_Guild_FamousInfoRefresh, private.RefreshSalaryRed) EventSystem.Regist(EventID.UI_Guild_AuctionShareBonusRefresh, private.RefreshGuildAuctionShareRed) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.CloseSalaryByGMS) EventSystem.Regist(EventID.UI_Guild_FamousInfoRefresh, private.RefreshFamousEntryRed) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.RefreshFamousEntryRed) EventSystem.Regist(EventID.UI_Guild_BeKickOutRefresh, private.OnBeKickOut) end function Guild_Controller.OnShutdown() end --计算邀请列表 超时取消不显示 function Guild_Controller.SetInvitedList(updateList) if not updateList then updateList = showList --原地更新,没有外来数据源 end showList = {} local maxLastTime = -1 if updateList then for _, v in ipairs(updateList) do local timeout = Guild_Controller.GetInviteTimeoutOffset(v) if v.inviteTime + timeout >= UTL.Time.GetServerTimestamp() then table.insert(showList, v) local lastTime = v.inviteTime + timeout - UTL.Time.GetServerTimestamp() if lastTime > maxLastTime then maxLastTime = lastTime end end end if maxLastTime > 0 then if timerHandle then TimerUtil.Remove(timerHandle) timerHandle = nil end timerHandle = TimerUtil.Interval(private.OnLastTimeOut, maxLastTime, 1) end end if #showList > 0 then CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.GuildInvitedIn) else CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.GuildInvitedIn) end EventSystem.Dispatch(EventID.UI_Guild_GuildInvitedList, showList) end function Guild_Controller.TryAddInvite(inviteInfo) for i, v in ipairs(showList) do if inviteInfo.inviteAcid == v.inviteAcid then table.remove(showList,i) break end end table.insert(showList, inviteInfo) Guild_Controller.SetInvitedList() --数据已经更新过了,只触发刷新逻辑 end --包括名门自动邀请和名门手动邀请 function Guild_Controller.IsFamousInvite(inviteData) return inviteData and (inviteData.type == guild_base_pb.Smart or inviteData.type == guild_base_pb.Famous_Manual) end --名门势力自动邀请 function private.IsSmartInvite(inviteData) return inviteData and inviteData.type == guild_base_pb.Smart end function Guild_Controller.GetInviteTimeoutOffset(inviteData) local timeout = private.IsSmartInvite(inviteData) and TIMEOUTVALUE_AUTO or TIMEOUTVALUE return timeout end function Guild_Controller.GetMaxInviteCDTimer() return TIMEOUTVALUE_AUTO > TIMEOUTVALUE and TIMEOUTVALUE_AUTO or TIMEOUTVALUE end function Guild_Controller.NeedShowInviteCDTimer(timeout) return timeout <= TIMEOUTVALUE end function Guild_Controller.GetInvitedList() return showList end function Guild_Controller.OpenSelfFireView(memberData) local roleData = memberData.roleInfo UIManager.OpenView(Const_UI_Lua.UIEnum.UIPlayerInteractionView, {msgResp = {HeadInfo = roleData,offlineBtns = {MDL.PlayerInteract.InteractType.FireStatus}}}) end function Guild_Controller.IsHighJob(scrId,targetId) local scrJob = DataSheetManager.GuildJob:GetDataByID(scrId) local targetJob = DataSheetManager.GuildJob:GetDataByID(targetId) return scrJob.Level> targetJob.Level end function Guild_Controller.OpenAppointPostView(targetData) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildChangePositionPanel,{acid = targetData.HeadInfo.acid}) end function Guild_Controller.RefreshRedPoint() local guildInfo = MDL.Guild.GetMyGuildInfo() if guildInfo.redPoint then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Member_Approval) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Member_Approval) end local warInfo = MDL.GuildWar.GetWarInfo() if warInfo and CTL.GuildWar.IsCanSignup() then local Stages = MDL.GuildWar.Stages if warInfo.Stage == Stages.StageTypeSignUp and not warInfo.isSignUp and MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarSign) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_Sign) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_Sign) end if warInfo.Stage == Stages.StageTypePrepare and not guildInfo.isGuildWarPrepare and warInfo.isSignUp then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_LineUp) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_LineUp) end else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_LineUp) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar_Sign) end -- 军团红包的红点 CTL.RedPacket.RefreshRedPoint() end function Guild_Controller.DonateRed() if Guild_Controller.IsDonateRed() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Donate) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Donate) end end function Guild_Controller.AlliesRed() if not MDL.Guild.IsHasGuild() then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Allies) return end local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildAllies) if not MDL.Unlock.IsUnlock(activityData.FuctionUnlockID) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Allies) return end local state = CTL.Activities.GetState(LuaConst.ActivityType.GuildAllies) if state == CTL.Activities.ActivityState.Opening then if CTL.GuildAllies.IsTimeToRefreshRedPoint() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Allies) end else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_Allies) end EventSystem.Dispatch(EventID.UI_Guild_WelfareRefresh) end function Guild_Controller.IsDonateRed() local isEnough = false if MDL.Guild.IsHasGuild() then for i,data in DataSheetManager.GuildDonate:GetEnumerator() do local count = MDL.Bag.GetItemCount(data.DonateItemId) if count > 0 then isEnough = true end end end return isEnough end function Guild_Controller.OpenAndApply(id) if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Guild) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Formation_RelationShip_Closed) return end if MDL.Guild.IsHasGuild() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildGuildListPanel,{id = id}) else CTL.Guild.OpenGuildMain({ id = id }) end end function Guild_Controller.SetCdTime() cdTime = UTL.Time.GetServerTimestamp() end function Guild_Controller.GetCdTime() return cdTime end function Guild_Controller.GetRedPointById(activityId) if activityId == LuaConst.ActivityType.GuildWar then return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar) elseif activityId == LuaConst.ActivityType.GuildDonate then return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_Donate) elseif activityId == LuaConst.ActivityType.GuildAllies then return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_Allies) elseif activityId == LuaConst.ActivityType.GuildMine then return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_GuildMine) elseif activityId == LuaConst.ActivityType.SlgGvE then return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE) end return false end function private.OnLastTimeOut() CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.GuildInvitedIn) timerHandle = nil end function private.OpenInvitedInPanel() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildInvitedInPanel) end function Guild_Controller.SendRecommend(acid,name) local str = string.FormatByIdsId(Const_IDS.IDS_GuildRecommendConfirm_Label, name) UTL.MessageBox.ShowOKCancelBox(nil, str, function () if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild) return end local leaderAcid = MDL.Guild.GetMyGuildInfo().leaderAcid local diplomatAcid = MDL.Guild.GetMyGuildInfo().diplomatAcid MDL.ChannelChat.SendGuildRecommendChatMsg(acid,name,leaderAcid) if not string.isNilOrEmpty(diplomatAcid) then MDL.ChannelChat.SendGuildRecommendChatMsg(acid,name,diplomatAcid) end CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildRecommend_Succeed1) end, nil) end function Guild_Controller.OnGuildNewMemberNotice(roleInfo) if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIDynamicHintParent) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDynamicHintParent) end EventSystem.Dispatch(EventID.UI_Guild_GuildNewMemberNotice, roleInfo) end function Guild_Controller.GetGuildLevelStr(id) local data = DataSheetManager.GuildReputation:GetDataByID(id)--self.myGuildInfo.listInfo.fameLevel local str = UIUtils.GetLocalizedTxt(Const_IDS[data.Name]) if data.Num > 0 then str = str..data.Num end return UTL.Color.FormatTextByColor(data.Color,str) end function Guild_Controller.GetGuildReputationInfo(fameLevel) fameLevel = fameLevel == 0 and 1 or fameLevel local reputationData = DataSheetManager.GuildReputation:GetDataByID(fameLevel) return UTL.Color.FormatTextByColor(reputationData.Color, UIUtils.GetLocalizedTxt(Const_IDS[reputationData.Name])), reputationData.Num end function Guild_Controller.OnJoinChannel(id,name) if id == MDL.ChannelChat.ChannelCfgId.Legion and name then if MDL.Guild.IsNeedSend() then MDL.Guild.SetIsNeedSend(false) TimerUtil.Interval(function () CTL.ChannelChat.SendTextMsg(MDL.Guild.GetMyGuildInfo().approveTagline, MDL.ChannelChat.GetChannelIdByCfgID(MDL.ChannelChat.ChannelCfgId.Legion)) end, 0.5, 1) end end end function Guild_Controller.BuildingSpeedUpReq(id,level) MDL.Guild.GuildBuildingSpeedUpReq(id, level) end function Guild_Controller.GetActivityList() local list = {} for i,v in DataSheetManager.GuildActivity:GetEnumerator() do local data = DataSheetManager.ActivityData:GetDataByID(v.ActivityId) if data then table.insert(list,v) end end table.sort(list, private.SortActivityList) return list end function Guild_Controller.GetWelfareList() local list = {} for i,v in DataSheetManager.GuildWelfare:GetEnumerator() do if v.ID == Guild_Controller.WelfareType.LeaderReward then --只有管理层才显示入口 if Guild_Controller.CheckGuildManagementEntry() then table.insert(list,v) end else table.insert(list,v) end end table.sort(list, private.SortWelfareList) return list end --IsShowUI暂未开放(合纵连横和助饷特殊处理,活动界面需要不显示,只在势力活动显示) function private.SortActivityList(a, b) local isOpen_a = CTL.Activities.IsShowUI(a.ActivityId) local isOpen_b = CTL.Activities.IsShowUI(b.ActivityId) if a.ActivityId == LuaConst.ActivityType.GuildAllies or a.ActivityId == LuaConst.ActivityType.GuildDonate then isOpen_a = true end if b.ActivityId == LuaConst.ActivityType.GuildAllies or b.ActivityId == LuaConst.ActivityType.GuildDonate then isOpen_b = true end if isOpen_a ~= isOpen_b then return isOpen_a else local isUnlock_a = CTL.Activities.IsOpen(a.ActivityId) local isUnlock_b = CTL.Activities.IsOpen(b.ActivityId) if isUnlock_a ~= isUnlock_b then return isUnlock_a else local aState = CTL.Activities.GetState(a.ActivityId) local bState = CTL.Activities.GetState(b.ActivityId) if aState ~= bState then return aState < bState elseif aState == bState and aState == CTL.Activities.ActivityState.NotOpen then return CTL.Activities.GetTimeToOpen(a.ActivityId) < CTL.Activities.GetTimeToOpen(b.ActivityId) end end end return a.ID > b.ID end function private.SortWelfareList(a, b) local isOpen_a = MDL.Unlock.IsUnlock(a.FunctionId) local isOpen_b = MDL.Unlock.IsUnlock(b.FunctionId) if isOpen_a ~= isOpen_b then return isOpen_a else return a.SortId < b.SortId end end function Guild_Controller.GetGuildDetailParam(emblemFrame, emblemContent, guildName, jobTitle, identity) --徽记框 local has, frame = DataSheetManager.GuildEmblem:TryGetDataByID(emblemFrame) local framePath = "" if not has then if jobTitle ~= -1 then logging.error(LTAG.ERROR, "GuildEmblem表中没有ID为", emblemFrame, "的数据,请检查!!! guildName: ", guildName) end else framePath = string.format(ENBLEM_FRAME_PATH, frame.Image) end --公会名 + 身份 if jobTitle == -1 then return framePath, emblemContent, guildName end local jobIDS local jobData = jobTitle>0 and DataSheetManager.GuildJob:GetDataByID(jobTitle) or nil if jobData == nil then return framePath, emblemContent, guildName end if jobTitle == MDL.Guild.JobEnum.Leader then jobIDS = jobData.JobName else local showIdentity if identity and #identity > 0 then for _, v in ipairs(identity) do --女神优先级最高 if v == MDL.Guild.IdentityEnum.Goddess then showIdentity = v break else showIdentity = v end end local identityData = DataSheetManager.GuildStatus:GetDataByID(showIdentity) jobIDS = identityData.JobName else jobIDS = jobData.JobName end end return framePath, emblemContent, guildName, jobIDS end --获取公会显示参数 function Guild_Controller.GetModelNameShowParam(emblemFrame, emblemContent, guildName, jobTitle, identity) local framePath, emblemContent, guildName, jobIDS = Guild_Controller.GetGuildDetailParam(emblemFrame, emblemContent, guildName, jobTitle, identity) if not jobIDS then return framePath, emblemContent, guildName end return framePath, emblemContent, string.format(MODEL_FORMAT, guildName, UIUtils.GetLocalizedTxt(Const_IDS[jobIDS])) end function Guild_Controller.GetBattleGuildDesc(guildName, jobIDS) if jobIDS ~= IDS_Guild_Elite and jobIDS ~= IDS_Guild_Populace then return string.format("%s·%s", guildName, UIUtils.GetLocalizedTxt(Const_IDS[jobIDS])) else return string.format("%s·%s", guildName, UIUtils.GetLocalizedTxt(Const_IDS[jobIDS])) end end --获取公会显示的框 function Guild_Controller.GetFramePath(emblemFrame, emblemContent) --徽记框 local frame = DataSheetManager.GuildEmblem:GetDataByID(emblemFrame) local framePath = "" if not frame then logging.error(LTAG.ERROR, "GuildEmblem表中没有ID为", emblemFrame, "的数据,请检查!!! ") else framePath = string.format(ENBLEM_FRAME_PATH, frame.Image) end --公会名 return framePath end -- 设置公会标记和内容(通过id) function Guild_Controller.SetGuildEmblem(obj_Bg, obj_txt, emblemFrame, emblemContent) if string.isNilOrEmpty(emblemContent) then UIUtils.SetActive(obj_Bg, false) else UIUtils.SetActive(obj_Bg, true) local guildEmblemCfg if emblemFrame then guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(emblemFrame) end if guildEmblemCfg then UTL.Item.SetAtlasSprite(obj_Bg, "UI_Guild", guildEmblemCfg.Image) end UIUtils.SetLabel(obj_txt, emblemContent) end end --同名显示蓝色 function Guild_Controller.GetColorGuildName(guildId, guildName) if guildId == MDL.Guild.GetMyGuildId() then return UTL.Color.FormatTextByColor(SAME_GUILD_COLOR, guildName) end return UTL.Color.FormatTextByColor(DIFF_GUILD_COLOR, guildName) end function Guild_Controller.OpenGuildBaseNoteView() local NoteParam1 = DataSheetManager.ConstData:GetDataByID("GuildEvaluationTime").IntValue/60 --预创建时间 local NoteParam2 = DataSheetManager.ConstData:GetDataByID("GuildEvaluationMemberNum").IntValue ---预创建人数 local NoteParam4 = DataSheetManager.ConstData:GetDataByID("GuildLeaderChangeLeaderOfflineTimeLimit").IntValue/60 local NoteParam6 = DataSheetManager.ConstData:GetDataByID("GuildLeaderChangeMemberOfflineTimeLimit").IntValue/60 local NoteParam7 = DataSheetManager.ConstData:GetDataByID("GuildLowActivityPreDismiss").IntValue local NoteParam3 = DataSheetManager.ConstData:GetDataByID("GuildLeaderChangeLeaderOfflineTimeLimit2").IntValue/60 local NoteParam5 = DataSheetManager.ConstData:GetDataByID("GuildLeaderChangeLeaderOfflineTimeLimit3").IntValue/60 local desc8, time8 = UTL.Time.GetDateDescAndTime({[1] = 2}) local NoteParam8 = string.Concat(desc8, time8) local NoteParam9 = DataSheetManager.ConstData:GetDataByID("FraudPreventionLeaveNum").IntValue local NoteParams = {id = LuaConst.NoteID.Guild ,params = {NoteParam1, NoteParam2, NoteParam3, NoteParam4, NoteParam5, NoteParam6, NoteParam7, NoteParam8, NoteParam9}} UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, NoteParams) end function Guild_Controller.IsGuildCommunityFunctionOpen() if GUILD_COMMUNITY_OPEN_CN == 1 and GUILD_COMMUNITY_OPEN == 1 then return true elseif GUILD_COMMUNITY_OPEN == 1 then return not GameAppInfo.IsChinesePackage() elseif GUILD_COMMUNITY_OPEN_CN == 1 then return GameAppInfo.IsChinesePackage() else return false end end function Guild_Controller.IsGuildCommunityOpen(type) if type == Guild_Controller.GuildCommunityType.CN then return GameAppInfo.IsChinesePackage() elseif type == Guild_Controller.GuildCommunityType.Oversea then return not GameAppInfo.IsChinesePackage() else return true end end function private.OnBeKickOut() UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildSalary) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildFamousPop) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildSalaryPop) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildManagementRewardsPop) end function private.CloseSalaryByGMS(funcID, isUnlock) if funcID == MDL.Unlock.FunctionType.GuildSalary then if not isUnlock then UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildSalary) end end end function Guild_Controller.GetGuildFamousTips() local date1, time1 = UTL.Time.GetDateDescAndTime({GUILD_BALANCE_TIME_ID[1]}) local date2, time2 = UTL.Time.GetDateDescAndTime({GUILD_BALANCE_TIME_ID[2]}) if GameAppInfo.IsVietnamPackage() then return string.FormatByIdsId(Const_IDS["IDS_GuildRankEvent_Intro"], GUILD_BALANCE_PREVIEW_DAY, date1 .. "/" .. date2 .. " " .. time1, GUILD_FAMOUS_COUNT ) else return string.FormatByIdsId(Const_IDS["IDS_GuildRankEvent_Intro"], GUILD_BALANCE_PREVIEW_DAY, date1 .. "/" .. date2 .. time1, GUILD_FAMOUS_COUNT ) end end function private.RefreshSalaryRed() local guildFamousInfo = MDL.Guild.GetMyFamousInfo() local hasSalaryRP = guildFamousInfo.hasFirstBalance and guildFamousInfo.hasRewardSalary == false if hasSalaryRP then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_Salary) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_Salary) end end function private.RefreshGuildAuctionShareRed() if MDL.Guild.IsHasGuild() and MDL.Guild.CanReceiveWeekAccumulatedAuctionBonus() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.GuildAuction_ShareBonus) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.GuildAuction_ShareBonus) end end function private.RefreshFamousEntryRed() local guildFamousInfo = MDL.Guild.GetMyFamousInfo() local time = MDL.RedPoint.GetRedPointTimeByType(MDL.RedPoint.RedPointType.GuildFamousEntry) if not time and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildFamous) and guildFamousInfo.hasFirstBalance == false then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.GuildFamousEntry) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.GuildFamousEntry) end end --是否为势力领导层(主公、丞相、御史、太尉) function Guild_Controller.IsGuildLeader(jobTitle) return jobTitle == MDL.Guild.JobEnum.Leader or jobTitle == MDL.Guild.JobEnum.RenshiElder or jobTitle == MDL.Guild.JobEnum.NeishiElder or jobTitle == MDL.Guild.JobEnum.JunshiElder end function Guild_Controller.CheckGuildManagementEntry() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildLeaderTask) == false then return false end if MDL.Guild.CanViewLeaderReward() == false then return false end if Guild_Controller.IsGuildLeader(MDL.Guild.GetMyGuildInfo().jobTitle) then --非首期不是名门,不开放 local info = MDL.Guild.GetMyFamousInfo() if info.hasFirstBalance == false or info.famousGuild == true then return true end end return false end function Guild_Controller.OpenLeaderManagement() if MDL.Guild.IsHasGuild() == false then CTL.Guild.OpenGuildMain() return end if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildLeaderTask) == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Formation_RelationShip_Closed) return end local myJobTitle = MDL.Guild.GetMyGuildInfo().jobTitle if Guild_Controller.IsGuildLeader(myJobTitle) == false then CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildLeaderInspire_IsLeader"]) return end MDL.Guild.GetGuildLeaderTaskInfoReq() end function Guild_Controller.CheckManagementRewardRed(type) if MDL.Guild.IpairsLeaderTaskInfo() then for i, v in MDL.Guild.IpairsLeaderTaskInfo() do if v.rewardState == Guild_Controller.GuildLeaderTaskRewardState_CanGet then local cfg = DataSheetManager.GuildLeaderInspire:GetDataByID(v.taskId) if cfg.Classification == type then return true end end end end return false end function Guild_Controller.RemoveLeaderTaskRed() local redInfo = PersistentData.PlayerData:Get(ConstLeaderRedKey) if redInfo == nil then redInfo = {} end redInfo.guildId = MDL.Guild.GetMyGuildId() redInfo.nextTimestamp = UTL.Time.GetServerIntervalNextTimeByTimeId(DataSheetManager.ConstData:GetDataByID("GuildLeaderInspireRankTime").IntValue) + UTL.Time.GetServerTimestamp() PersistentData.PlayerData:Set(ConstLeaderRedKey, redInfo, true) Guild_Controller.UpdateLeaderTaskRed() end function Guild_Controller.UpdateLeaderTaskRed() CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_LeaderReward) if not MDL.Guild.IsHasGuild() then return end if Guild_Controller.CheckGuildManagementEntry() then if MDL.Guild.IpairsLeaderTaskInfo() then --1.有领取奖励 for i, v in MDL.Guild.IpairsLeaderTaskInfo() do if v.rewardState == Guild_Controller.GuildLeaderTaskRewardState_CanGet then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_LeaderReward) return end end --2.成为领导有一次性红点 local redInfo = PersistentData.PlayerData:Get(ConstLeaderRedKey) if redInfo == nil or redInfo.guildId ~= MDL.Guild.GetMyGuildId() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_LeaderReward) return end --3.每周一5点 local nextTime = UTL.Time.GetServerIntervalNextTimeByTimeId(DataSheetManager.ConstData:GetDataByID("GuildLeaderInspireRankTime").IntValue) + UTL.Time.GetServerTimestamp() if redInfo == nil or nextTime > redInfo.nextTimestamp then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Welfare_LeaderReward) end end end end --巅峰势力文本参数 function Guild_Controller.GetPeakParam(ids) local _, offset = MDL.Guild.GetGuildBalanceTime() local customStr, customType, refreshInterval if offset > UTL.Time.TotalSecondsOneDay then customStr = string.FormatByIdsId(ids, string.Concat("{0}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Day), "{1}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Hour))) customType = 1 refreshInterval = offset - math.floor(offset / UTL.Time.TotalSecondsOneDay) * UTL.Time.TotalSecondsOneDay elseif offset > UTL.Time.TotalSecondsOneHour then customStr = string.FormatByIdsId(ids, string.Concat("{0}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Hour), "{1}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Minute))) customType = 3 refreshInterval = offset - math.floor(offset / UTL.Time.TotalSecondsOneHour) * UTL.Time.TotalSecondsOneHour elseif offset > UTL.Time.TotalSecondsOneMinute then customStr = string.FormatByIdsId(ids, string.Concat("{0}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Minute), "{1}", UIUtils.GetLocalizedTxt(Const_IDS.IDS_AnniversaryPrepare_Hint_Second))) customType = 5 refreshInterval = offset - math.floor(offset / UTL.Time.TotalSecondsOneMinute) * UTL.Time.TotalSecondsOneMinute else customStr = string.FormatByIdsId(ids, UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_4)) customType = 10 refreshInterval = 0 end return customStr, customType, refreshInterval end function Guild_Controller.OpenGuildMain(context) if MDL.Guild.IsHasGuild() then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildBasePanel, context) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildBasePanel) end end return Guild_Controller