local Guild_Model = {} local private = {} local guild_operate_pb = require 'Proto/guild_operate_pb' local guild_enum_pb = require 'Proto/guild_enum_pb' local chat_pb = require("Proto/chat_pb") local EventSystem = require('Event/EventSystem') local auction_base_pb = require 'Proto.auction_base_pb' local myGuildInfo = nil local guildList = {} local myGuildMemberInfo = {} local isNeedSend = false local Const_Enum_Auction = 1000 Guild_Model.CurClickIdentityId = nil Guild_Model.CurClickJobId = nil Guild_Model.GuildUpdateType = { ApproveTagline = guild_enum_pb.ApproveTagline, EmblemContent = guild_enum_pb.EmblemContent, EmblemFrame = guild_enum_pb.EmblemFrame, GroupChatNum = guild_enum_pb.GroupChatNum, LimitGs = guild_enum_pb.LimitGs, LimitLevel = guild_enum_pb.LimitLevel, Name = guild_enum_pb.Name, Notice = guild_enum_pb.Notice, RecruitTagline = guild_enum_pb.RecruitTagline, FriendInvite = guild_enum_pb.FriendInvite, IsAutoApprove = guild_enum_pb.GUIsAutoApprove, EmblemContent_EmblemFrame = guild_enum_pb.EmblemContentAndEmblemFrame, SwitchSmartInvite = guild_enum_pb.SwitchSmartInvite, } Guild_Model.JobEnum = { Leader = 1, -- 主公 RenshiElder = 11, -- 御史 NeishiElder = 12, -- 丞相 JunshiElder = 13, -- 太尉 Elite = 21, Common = 99, } Guild_Model.IdentityEnum = { Warlord = 1, Goddess = 2, } Guild_Model.AuthorityEnum = { GuildDisband = 1, --解散势力 GuildName = 2, --势力改名 GuildEmblem = 3, --编辑徽记 GuildGroup = 4, --编辑议事群 GuildAnnouncement = 5, --更改宣言 GuildNotice = 6, --更改公告 GuildMail = 7, --势力通知 GuildChangeLeader = 8, --让位 GuildAppoint1 = 9, --任命职位 GuildAppoint2 = 10, --更改身份 GuildInvite = 11, --审批 GuildRecruit = 12, --招募 GuildKick = 13, --踢人 GuildRecommend= 14, --引荐 GuildBuilding = 15, --建筑升级 GuildTech = 16, --科技发展 GuildAllies = 17, --结盟 GuildWarSign = 18, --势力战报名 GuildWarPrepareEdit = 19, --备战编辑 GuildWarCommander = 20, --势力战指挥 GuildSpoil = 21, --俸禄管理 SlgGvEEditMark = 24, --汉中风云编辑标记 SlgGvEFightBoss = 25, --汉中风云开怪 } function Guild_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageGetGuildList, private.OnGetGuildList) NetManager.RegisterMsgCB(MessageEnums.MessageGetGuildInfo, private.OnGetGuildInfo) NetManager.RegisterMsgCB(MessageEnums.MessageGuildCreate, private.OnGuildCreate) NetManager.RegisterMsgCB(MessageEnums.MessageApplayJoinGuild, private.OnGuildJoin) NetManager.RegisterMsgCB(MessageEnums.MessageGuildKickOutMember, private.OnGuildKickOutMember) NetManager.RegisterMsgCB(MessageEnums.MessageGuildNotification, private.OnGuildNotification) NetManager.RegisterMsgCB(MessageEnums.MessageGuildSetup, private.OnGuildSetup) NetManager.RegisterMsgCB(MessageEnums.MessageGuildSetupBatch, private.OnGuildBatchSetup) NetManager.RegisterMsgCB(MessageEnums.MessageGuildLeave, private.OnGuildLeave) NetManager.RegisterMsgCB(MessageEnums.MessageGuildSetupCheck, private.OnGuildSetupCheck) NetManager.RegisterMsgCB(MessageEnums.MessageInviteJoinGuild, private.OnInviteJoinGuild) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildInvited, private.OnPushGuildInvited) NetManager.RegisterMsgCB(MessageEnums.MessageCancelApplayJoinGuild, private.OnCancelApplayJoinGuild) NetManager.RegisterMsgCB(MessageEnums.MessageGuildInviteHandle, private.OnGuildInviteHandle) NetManager.RegisterMsgCB(MessageEnums.MessageIsGuildFull, private.CheckIsGuildFull) NetManager.RegisterMsgCB(MessageEnums.MessageGuildAppointJob, private.OnGuildAppointJob) NetManager.RegisterMsgCB(MessageEnums.MessageGuildAppointIdentity, private.OnGuildAppointIdentity) NetManager.RegisterMsgCB(MessageEnums.MessageG2CBroadcastUpdateGuild, private.OnBroadcastUpdateGuild) NetManager.RegisterMsgCB(MessageEnums.MessageGuildApproval, private.OnGuildApproval) NetManager.RegisterMsgCB(MessageEnums.MessageGuildChangeLeader, private.OnGuildChangeLeader) NetManager.RegisterMsgCB(MessageEnums.MessageG2CBroadcastWelcomeJoin, private.OnWelcomeJoin) NetManager.RegisterMsgCB(MessageEnums.MessageGuildBuildingLevelUp, private.OnBuildLevelUp) NetManager.RegisterMsgCB(MessageEnums.MessageGuildBuildingSpeedUp, private.OnBuildSpeedUp) NetManager.RegisterMsgCB(MessageEnums.MessageGuildDonateRank, private.OnGuildDonateRank) NetManager.RegisterMsgCB(MessageEnums.MessageGuildDonate, private.OnGuildDonate) NetManager.RegisterMsgCB(MessageEnums.MessageGuildDynamic, private.OnGuildDynamic) NetManager.RegisterMsgCB(MessageEnums.MessageGetMaxReptGuildInfo, private.GetMaxReptGuildInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageRewardSalary, private.RewardSalaryResp) NetManager.RegisterMsgCB(MessageEnums.MessageRewardAuctionBonus, private.RewardAuctionBonusResp) NetManager.RegisterMsgCB(MessageEnums.MessageGetGuildAuctionInfo, private.GetGuildAuctionInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageGetGuildSalaryInfo, private.GetGuildSalaryInfoResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushGuildBuildingChangeInfo, private.GuildBuildingChangeInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageRewardGuildLeaderTask, nil) NetManager.RegisterMsgCB(MessageEnums.MessageGetGuildLeaderTaskInfo, private.OnGetGuildLeaderTaskInfo) private.GuildFamousInfo = { -- famousGuild 是否是名门 -- hasRewardSalary 是否已领工资 -- hasFirstBalance 是否已经结算 -- balanceTime 结算时间戳 -- activityScore 贡献积分 } private.GuildAuctionShareBonusInfo = { -- key: activityID, value:AuctionBonusRewardInfo 势力拍卖分红信息 } private.WeekAccumulatedAuctionBonusInfo = { ReceivedBonus = {}, WeekTotalBonus = {}, SlgReceivedBonus = {}, SlgWeekTotalBonus = {}, } EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.OnLoginPostprocess) end local function IpairsValue(tab, i) if string.isNilOrEmpty(Guild_Model.GetMyGuildId()) or tab == nil then return nil end i = i + 1 local data = tab[i] if data then return i, tab[i] else return nil end end function Guild_Model.GetNameByJobId(jobId) if jobId == Guild_Model.JobEnum.Leader then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Leader) elseif jobId == Guild_Model.JobEnum.RenshiElder then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Commander1) elseif jobId == Guild_Model.JobEnum.NeishiElder then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Commander2) elseif jobId == Guild_Model.JobEnum.JunshiElder then return UIUtils.GetLocalizedTxt(Const_IDS.IDS_Guild_Commander3) end end -- 获取名望势力 function Guild_Model.GetTopFamousGuildInfo() return private.TopFamousGuildInfo end -- 大于0表示有免费改名次数 function Guild_Model.GetNamedFreeNums() return myGuildMemberInfo.listInfo.freeRenameNums or 0 end function Guild_Model.GetGuildMembersIterator(includeSelf) return IpairsValue, myGuildMemberInfo.members, includeSelf and 0 or 1 end function Guild_Model.GetGuildListReq() local msg = guild_operate_pb.GetGuildListReq() NetManager.SendMessage(MessageEnums.MessageGetGuildList,msg) end function Guild_Model.GetGuildInfoReq() local msg = guild_operate_pb.GetGuildInfoReq() NetManager.SendMessage(MessageEnums.MessageGetGuildInfo,msg) end function Guild_Model.GuildCreateReq(info) local msg = guild_operate_pb.GuildCreateReq() msg.createType = info.createType msg.name = info.name msg.emblemContent = info.emblemContend msg.emblemFrame = info.emblemFrame msg.recruitTagline = info.recruitTagline msg.isAutoApprove = info.isAutoApprove NetManager.SendMessage(MessageEnums.MessageGuildCreate,msg) end function Guild_Model.GuildJoinReq(guildIds) local maxValue = DataSheetManager.ConstData:GetDataByID("PlayerApplicationListLimit").IntValue local count = #myGuildInfo.applayGuildId if maxValue <= count then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Fail4) return end local msg = guild_operate_pb.ApplayJoinGuildReq() for i, v in ipairs(guildIds) do table.insert( msg.guildId,v) end msg.isBatch = false NetManager.SendMessage(MessageEnums.MessageApplayJoinGuild,msg) end function Guild_Model.GuildOneKeyJoinReq() local maxValue = DataSheetManager.ConstData:GetDataByID("PlayerApplicationListLimit").IntValue local count = #myGuildInfo.applayGuildId if maxValue <= count then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Fail4) return end local msg = guild_operate_pb.ApplayJoinGuildReq() local applyCount = maxValue - count for i,v in ipairs(guildList) do if v.isAutoApprove and applyCount > 0 and v.memberCount < Guild_Model.GetMaxMemberCount(v) and not Guild_Model.IsApplay(v.id) then table.insert( msg.guildId,v.id) applyCount = applyCount - 1 end end if applyCount > 0 then for i,v in ipairs(guildList) do if v.memberCount < Guild_Model.GetMaxMemberCount(v) and applyCount > 0 and not Guild_Model.IsApplay(v.id)then table.insert( msg.guildId,v.id) applyCount = applyCount - 1 end end end if #msg.guildId == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_QuickApplyNoTarget) return end msg.isBatch = true NetManager.SendMessage(MessageEnums.MessageApplayJoinGuild,msg) end function Guild_Model.GetMaxMemberCount(guildBaseInfo) if guildBaseInfo then return guildBaseInfo.memberCountLimit else return myGuildMemberInfo.listInfo.memberCountLimit end end function Guild_Model.GuildLeaveReq(guildId) local msg = guild_operate_pb.GuildLeaveReq() msg.guildId = guildId NetManager.SendMessage(MessageEnums.MessageGuildLeave,msg) end function Guild_Model.GuildKickOutMemberReq(memberAcid,name) local str =string.FormatByIdsId(Const_IDS.IDS_GuildKickbConfirm_Label,name) UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_GuildKickbConfirm_Title, str, function () local msg = guild_operate_pb.GuildKickOutMemberReq() table.insert( msg.memberAcid, memberAcid ) msg.isBatch = false NetManager.SendMessage(MessageEnums.MessageGuildKickOutMember,msg) end, nil) end function Guild_Model.GuildKickOutMultiReq(memberAcids) local msg = guild_operate_pb.GuildKickOutMemberReq() for i,v in ipairs(memberAcids) do table.insert( msg.memberAcid, v) end msg.isBatch = true NetManager.SendMessage(MessageEnums.MessageGuildKickOutMember,msg) end function Guild_Model.GuildNotificationReq(title,content) local msg = guild_operate_pb.GuildNotificationReq() msg.title = title msg.content = content NetManager.SendMessage(MessageEnums.MessageGuildNotification,msg) end function Guild_Model.GuildSetupReq(type, content, emblemFrame) local msg = guild_operate_pb.GuildSetupReq() msg.type = type msg.content = content msg.EmblemFrame = emblemFrame or 0 NetManager.SendMessage(MessageEnums.MessageGuildSetup,msg) end --对GuildSetupReqd的整合重构,不要一次发多个军团设置的改变,不然每次都会再拉一次军团主协议。 --先在这里试点,其他系统如果有类似的扩展需求可以类似替,但注意服务器需要同步修改,并非通用逻辑.. function Guild_Model.GuildSetupGroupReq(typeList, contentList, emblemFrameList) local msg = guild_operate_pb.GuildSetupBatchReq() for i, v in ipairs(typeList) do local info = guild_operate_pb.GuildSetupInfo() info.type = v info.content = contentList[i] info.EmblemFrame = emblemFrameList or 0 table.insert(msg.info, info) end NetManager.SendMessage(MessageEnums.MessageGuildSetupBatch, msg) end function Guild_Model.GuildSetupCheckReq(type, content) local msg = guild_operate_pb.GuildSetupReq() msg.type = type msg.content = content NetManager.SendMessage(MessageEnums.MessageGuildSetupCheck,msg) end function Guild_Model.InvitePlayer(acid) local msg = guild_operate_pb.InviteJoinGuildReq() msg.invitedAcid = acid NetManager.SendMessage(MessageEnums.MessageInviteJoinGuild,msg) end function Guild_Model.CancelApplayJoinGuildReq(guildId) local msg = guild_operate_pb.CancelApplayJoinGuildReq() msg.guildId = guildId NetManager.SendMessage(MessageEnums.MessageCancelApplayJoinGuild,msg) end function Guild_Model.GuildInviteHandleReq(guildId,isAgree,isOneKeyRefuse) local msg = guild_operate_pb.GuildInviteHandleReq() if isOneKeyRefuse then msg.isOneKeyRefuse = isOneKeyRefuse else msg.guildId = guildId or 0 msg.isAgree = isAgree msg.isOneKeyRefuse = false end NetManager.SendMessage(MessageEnums.MessageGuildInviteHandle,msg) end function Guild_Model.CheckGuildFullReq(guildId) local msg = guild_operate_pb.IsGuildFullReq() msg.guildId = guildId NetManager.SendMessage(MessageEnums.MessageIsGuildFull,msg) end function Guild_Model.GuildAppointJobReq(acid,jobTitle) local msg = guild_operate_pb.GuildAppointJobReq() msg.acid = acid msg.jobTitle = jobTitle NetManager.SendMessage(MessageEnums.MessageGuildAppointJob,msg) end function Guild_Model.GuildAppointIdentityReq(acid,identity, isCancel) local msg = guild_operate_pb.GuildAppointIdentityReq() msg.acid = acid msg.identity = identity msg.isCancel = isCancel or false NetManager.SendMessage(MessageEnums.MessageGuildAppointIdentity,msg) end function Guild_Model.GuildApprovalReq(agreeAcids,refuseAcids,isBatch) local msg = guild_operate_pb.GuildApprovalReq() msg.isBatch = isBatch or false if agreeAcids then for i,v in ipairs(agreeAcids) do table.insert(msg.agreeAcids, v) end end if refuseAcids then for i,v in ipairs(refuseAcids) do table.insert(msg.refuseAcids, v) end end NetManager.SendMessage(MessageEnums.MessageGuildApproval,msg) end function Guild_Model.GuildChangeLeaderReq(acid,name) local str =string.FormatByIdsId(Const_IDS.IDS_GuildLeaderChangeConfirm_Label2,name) UTL.MessageBox.ShowCountDownBox(Const_IDS.IDS_GuildLeaderChangeConfirm_Title, str, function () local msg = guild_operate_pb.GuildChangeLeaderReq() msg.acid = acid NetManager.SendMessage(MessageEnums.MessageGuildChangeLeader,msg) end, nil,nil,nil,5) end function Guild_Model.GuildBuildingLevelUpReq(id, lv) local msg = guild_operate_pb.GuildBuildingLevelUpReq() msg.buildingId = id msg.buildingLvl = lv NetManager.SendMessage(MessageEnums.MessageGuildBuildingLevelUp,msg) end function Guild_Model.GuildBuildingSpeedUpReq(id,lv) local msg = guild_operate_pb.GuildBuildingSpeedUpReq() msg.buildingId = id msg.buildingLvl = lv NetManager.SendMessage(MessageEnums.MessageGuildBuildingSpeedUp,msg) end function Guild_Model.GuildDonateRankReq() local msg = guild_operate_pb.GuildDonateRankReq() NetManager.SendMessage(MessageEnums.MessageGuildDonateRank,msg) end function Guild_Model.GuildDonateReq(id,num) local msg = guild_operate_pb.GuildDonateReq() msg.donateId = id msg.donateNum = num NetManager.SendMessage(MessageEnums.MessageGuildDonate,msg) end function Guild_Model.GuildDynamicReq() local msg = guild_operate_pb.GuildDynamicReq() NetManager.SendMessage(MessageEnums.MessageGuildDynamic,msg) end function Guild_Model.GetMyGuildInfo() return myGuildInfo end function Guild_Model.GetMyGuildId() if myGuildInfo~=nil then return myGuildInfo.guildId end return 0 end function Guild_Model.IsSameGuild(guildId) local myGuildId = Guild_Model.GetMyGuildId() if myGuildId == 0 or string.isNilOrEmpty(myGuildId) then return false end return myGuildId == guildId end function Guild_Model.IsHasGuild() return myGuildInfo and not string.isNilOrEmpty(myGuildInfo.guildId) end function Guild_Model.IsInvitePlayer() if Guild_Model.IsHasGuild() then if Guild_Model.JobHasPermission(myGuildInfo.jobTitle,Guild_Model.AuthorityEnum.GuildInvite) then return true end end return false end function Guild_Model.JobHasPermission(jobId,permissionId) if Guild_Model.IsHasGuild() then local jobData = DataSheetManager.GuildJob:GetDataByID(jobId) if not jobData then logging.error(LTAG.ERROR, "当前军团职位无法从GuildJob查询到数据 JobJd = ", jobId) return false end for i, v in ipairs(jobData.JobID) do if v == permissionId then return true end end end return false end function Guild_Model.SetMyGuildInfo(msgId, info, isInit) local isGuildLevelChanged, isGuildChanged if myGuildInfo and info and info.fameLevel > myGuildInfo.fameLevel then isGuildLevelChanged = true end if myGuildInfo and myGuildInfo.guildId ~= info.guildId then if string.isNilOrEmpty(info.guildId)then EventSystem.Dispatch(EventID.UI_Guild_BeKickOutRefresh) myGuildInfo = info private.LeaveCloseView() MDL.WorldBoss.ClearAllSeekHelp() MDL.GuildBoss.ClearData() CTL.ChannelChat.ExitGuild() CTL.VoiceRoom.ExitVoiceRoom(MDL.VoiceRoom.VoiceRoomType.Guild) CTL.GuildEscort.ShowMainNotice(false) else myGuildInfo = info if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildBasePanel) then EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) CTL.Guild.OpenGuildMain() end UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildApplyManifestoPanel) CTL.ChannelChat.JoinGuildChatChannel(myGuildInfo.guildId) isNeedSend = true MDL.GuildWar.SendGetGuildWarInfo() CTL.Country.GetCountryInfo() end isGuildLevelChanged = true isGuildChanged = true end myGuildInfo = info if isGuildLevelChanged then EventSystem.Dispatch(EventID.OnConditionChangeFunctionUpdate, LuaConst.UnlockConditionType.GuildLevel) end if isGuildChanged then EventSystem.Dispatch(EventID.OnConditionChangeFunctionUpdate, LuaConst.UnlockConditionType.HaveGuild) end -- 更新名门信息 private.GuildFamousInfo.balanceTime = info.balanceTime private.GuildFamousInfo.hasRewardSalary = info.hasRewardSalary private.GuildFamousInfo.famousGuild = info.famousGuild private.GuildFamousInfo.hasFirstBalance = info.hasFirstBalance private.GuildFamousInfo.activityScore = info.activityScore private.GuildFamousInfo.contribute = info.contribute private.GuildFamousInfo.clientJobTitle = info.clientJobTitle -- 薪资相关使用的职位 private.GuildFamousInfo.baseRewardInfo = info.baseRewardInfo -- 薪资基础奖励 private.GuildFamousInfo.clientFamousGuild = info.clientFamousGuild -- 薪资界面使用的是否名门 private.GuildFamousInfo.rewardInfo = info.rewardInfo -- 薪资额外奖励 private.GuildFamousInfo.hasBalanceNums = info.hasBalanceNums -- 名门已结算次数 EventSystem.Dispatch(EventID.UI_Guild_FamousInfoRefresh) EventSystem.Dispatch(EventID.UI_Guild_AuctionShareBonusRefresh) if string.isNilOrEmpty(myGuildInfo.guildId) then PersistentData.DeviceData:Set("OfficerLoginTipsKey", true, true) PersistentData.DeviceData:Set("BeAlienatedTipsKey", true, true) end CTL.GuildEscort.ShowMainNotice(true) EventSystem.Dispatch(EventID.UI_Guild_SelfInfoRefresh) CTL.Guild.SetInvitedList(info.invitedList) CTL.Guild.RefreshRedPoint() CTL.Guild.DonateRed() CTL.Guild.AlliesRed() CTL.Guild.UpdateLeaderTaskRed() --刷新军团战斥候相关UI CTL.ChannelChat.RefreshGuildWarChannelMemberUI(true) CTL.ChannelChat.RefreshGuildWarChannelUI() CTL.ChannelChat.RefreshGuildWarMapUI() Guild_Model.UpdateGuildBuildingInfo(info.buildingInfo) SDKUtil.SetPartyName(info.guildName) -- 刷新攻城略地红点信息 CTL.GVGFight.DealwithRedPoint() end function Guild_Model.GetGuildWuziCount() return myGuildInfo and myGuildInfo.goldIngot or 0 end ---最初设计的时候,军团的全量信息会在打开界面的时候推送 ---军团建筑信息由于红点的需求,需要在enterworld就要推送 ---分别在enterworld的personalGuildInfo,打开界面的全量guildInfo,单独的push协议三个地方更新 function Guild_Model.UpdateGuildBuildingInfo(buildingInfo) if not next(myGuildMemberInfo) then myGuildMemberInfo = {buildingInfo = buildingInfo} else local oldInfo = myGuildMemberInfo.buildingInfo for i = #oldInfo, 1, -1 do table.remove(oldInfo) end for i = 1, #buildingInfo do table.insert(oldInfo, buildingInfo[i]) end end EventSystem.Dispatch(EventID.UI_GuildBuildingInfoRefresh) end function private.GuildBuildingChangeInfoPush(msg) logging.log(LTAG.LOG, "MessageG2CPushGuildBuildingChangeInfo", msg) for i, v in ipairs(myGuildMemberInfo.buildingInfo) do if v.buildingId == msg.buildingId then v.level = msg.buildingLevel end end EventSystem.Dispatch(EventID.UI_GuildBuildingInfoRefresh) end function Guild_Model.CheckLeader(isNot) local isLeader = false if myGuildInfo and not string.isNilOrEmpty(myGuildInfo.guildId) then isLeader = myGuildInfo.jobTitle == Guild_Model.JobEnum.Leader end if isNot == 1 then return isLeader else return not isLeader end end function Guild_Model.GetMyJobID() return (myGuildInfo and not string.isNilOrEmpty(myGuildInfo.guildId)) and myGuildInfo.jobTitle or nil end --- 是否是势力高层 jobLevel >= 7 function Guild_Model.IsGuildManagementGroup() if myGuildInfo and not string.isNilOrEmpty(myGuildInfo.guildId) then local jobLevel = DataSheetManager.GuildJob:GetDataByID(myGuildInfo.jobTitle).Level return jobLevel >= 7 end return false end function Guild_Model.GetBuildName(BuildID) local buildingNameIDS = DataSheetManager.GuildBuildingBase:GetDataByID(BuildID).BuildingName return buildingNameIDS end function Guild_Model.IsApplay(guildId) for i,v in ipairs(myGuildInfo.applayGuildId) do if v == guildId then return true end end return false end function Guild_Model.IsReachLevel(level,desc) return myGuildInfo and myGuildInfo.fameLevel >= tonumber(level) , desc and string.FormatByIdsId(Const_IDS[desc],CTL.Guild.GetGuildLevelStr(tonumber(level))) end function Guild_Model.CheckBuildLevel(buildID, desc) local data = string.split(buildID, ";") local id = tonumber(data[1]) local level = tonumber(data[2]) local levelRes = false local buildingName if not myGuildMemberInfo.buildingInfo then return false end for i, v in ipairs(myGuildMemberInfo.buildingInfo) do if id == v.buildingId then buildingName = DataSheetManager.GuildBuildingBase:GetDataByID(v.buildingId).BuildingName if v.level >= level then levelRes = true end break end end local unlockText if not string.isNilOrEmpty(desc) then unlockText = string.FormatByIdsId(Const_IDS[desc], UIUtils.GetLocalizedTxt(Const_IDS[buildingName]), level) end return myGuildInfo and levelRes, unlockText end function Guild_Model.IsNeedSend() return isNeedSend end function Guild_Model.SetIsNeedSend(isNeed) isNeedSend = isNeed end function Guild_Model.GetMyGuildMemberInfo() return Guild_Model.GetMemberData(BattleDataGetter.GetAcID()) end function Guild_Model.GetMemberData(acid) for i,v in ipairs(myGuildMemberInfo.members) do if v.roleInfo.acid == acid then return v end end end function Guild_Model.IsMember(acid) for i,v in ipairs(myGuildMemberInfo.members) do if v.roleInfo.acid == acid then return true end end end function Guild_Model.GetOnlineCount(members) local count = 0 for i,v in ipairs(members) do if v.roleInfo.isOnline then count = count + 1 end end return count end function Guild_Model.GetMemberJobDesc(data) local jobData = DataSheetManager.GuildJob:GetDataByID(data.jobTitle) local str = UIUtils.GetLocalizedTxt(Const_IDS[jobData.JobName]) local identityStr = "" for i, v in ipairs(data.identity) do local statusData = DataSheetManager.GuildStatus:GetDataByID(v) if statusData then if string.len(identityStr) == 0 then identityStr = UIUtils.GetLocalizedTxt(Const_IDS[statusData.JobName]) else identityStr = identityStr.. "/"..UIUtils.GetLocalizedTxt(Const_IDS[statusData.JobName]) end end end if string.len(identityStr) > 0 then if data.jobTitle ~= 99 then str = str.."/"..identityStr else str = identityStr end end return str end function Guild_Model.GetGuildMemberInfo() return myGuildMemberInfo end function Guild_Model.GetBuildInfo(id) for i, v in ipairs(myGuildMemberInfo.buildingInfo) do if id == v.buildingId then return v end end end function private.OnGetGuildList(msg) local maxFame = 0 local maxPlayers = 0 for i, v in ipairs(msg.guildBaseInfos) do if v.memberCount > maxPlayers then maxPlayers = v.memberCount end if v.fameValue > maxFame then maxFame = v.fameValue end end local param1 = DataSheetManager.ConstData:GetDataByID("GuildApplyParam1").IntValue local param2 = DataSheetManager.ConstData:GetDataByID("GuildApplyParam2").IntValue local param3 = DataSheetManager.ConstData:GetDataByID("GuildApplyParam3").IntValue local t = {} for i, v in ipairs(msg.guildBaseInfos) do table.insert(t,v) end table.sort(t, function (a,b) -- 这个是策划需求算法 local aTotal = a.fameValue local bTotal = a.fameValue for i=1,a.fameLevel do aTotal = aTotal + DataSheetManager.GuildReputation:GetDataByID(i).Value end for i=1,b.fameLevel do bTotal = bTotal + DataSheetManager.GuildReputation:GetDataByID(i).Value end local aHeight = math.getPreciseDecimal(aTotal/maxFame,2) * param1 + (math.min( param2,maxPlayers - a. memberCount) * param3) local bHeight = math.getPreciseDecimal(bTotal/maxFame,2) * param1 + (math.min( param2,maxPlayers - b. memberCount) * param3) if aHeight == bHeight then return aTotal > bTotal end return aHeight > bHeight end) guildList = t EventSystem.Dispatch(EventID.UI_Guild_GuildListRefresh,t) end function private.OnPushGuildInvited(msg) CTL.Guild.TryAddInvite(msg.inviteInfo) --CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_PlayerInfolistButton_Invite) end function private.OnCancelApplayJoinGuild() -- body end function private.OnGetGuildInfo(msg) table.sort(msg.guildInfo.members, private.SortMembers) myGuildMemberInfo = msg.guildInfo EventSystem.Dispatch(EventID.UI_Guild_GuildInfoRefresh, msg.guildInfo) CTL.Guild.UpdateLeaderTaskRed() CTL.ChannelChat.RefreshGuildWarChannelMemberUI() CTL.ChannelChat.RefreshGuildWarChannelUI() CTL.ChannelChat.RefreshGuildWarMapUI() end function private.SortMembers(a, b) if a.roleInfo.acid == BattleDataGetter.GetAcID() then return true end if b.roleInfo.acid == BattleDataGetter.GetAcID() then return false end if a.roleInfo.isOnline == b.roleInfo.isOnline then if a.roleInfo.isOnline then if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then return a.roleInfo.gsSum > b.roleInfo.gsSum else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end else return a.roleInfo.logoutTime > b.roleInfo.logoutTime end else return a.roleInfo.isOnline end end function private.OnGuildCreate( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildCreate_Succeed1) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildCreateLevelPanel) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) CTL.Guild.OpenGuildMain() CTL.Sound.PlayGameSound("UI_joinarmy") EventSystem.Dispatch(EventID.BI_FirstJoinGuild) CTL.Guild.UpdateLeaderTaskRed() end end function private.OnGuildJoin( msg ) if msg.Resp.Code == 0 then if not Guild_Model.IsHasGuild() then if msg.isBatch then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_QuickApplySent) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Succeed3) end else EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildApplyManifestoPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildFamousPop) -- 名望势力 CTL.Guild.OpenGuildMain() CTL.Sound.PlayGameSound("UI_joinarmy") EventSystem.Dispatch(EventID.BI_FirstJoinGuild) end end end function private.OnInviteJoinGuild(msg) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildInvite_Succeed1) end end function private.OnGuildKickOutMember( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) Guild_Model.GetGuildInfoReq() end end function private.OnGuildNotification( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildMail_Succeed1) end end function private.OnGuildSetup( msg ) if msg.Resp.Code == 0 then if msg.type ~= Guild_Model.GuildUpdateType.LimitLevel then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed2) end UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildChangeFrame) if Guild_Model.IsHasGuild() then Guild_Model.GetGuildInfoReq() else EventSystem.Dispatch(EventID.UI_Guild_GuildSetupRefresh) end end end function private.OnGuildBatchSetup( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed2) if Guild_Model.IsHasGuild() then MDL.Guild.GetGuildInfoReq() else EventSystem.Dispatch(EventID.UI_Guild_GuildSetupRefresh) end end end function private.OnGuildLeave( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildPlayerQuitSucceed) EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) CTL.ChannelChat.ExitGuild() CTL.VoiceRoom.ExitVoiceRoom(MDL.VoiceRoom.VoiceRoomType.Guild) MDL.WorldBoss.ClearAllSeekHelp() MDL.GuildAuction.OnGuildQuit() CTL.GuildAllies.ResetRpRefreshTime() CTL.Country.OnLeaveGuild() CTL.Guild.UpdateLeaderTaskRed() EventSystem.Dispatch(EventID.UI_Guild_Leave) end end function private.OnGuildSetupCheck(msg) if msg.type == Guild_Model.GuildUpdateType.RecruitTagline then EventSystem.Dispatch(EventID.UI_Guild_GuildCheckContent, msg) end end function private.OnGuildInviteHandle(msg) if msg.Resp.Code == 0 then --UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildInvitedInPanel) end end function private.CheckIsGuildFull(msg) if msg.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_Guild_TargetGuildFull, msg.full) end end function private.OnGuildAppointJob( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) Guild_Model.GetGuildInfoReq() end end function private.OnGuildAppointIdentity( msg ) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) Guild_Model.GetGuildInfoReq() end end function private.OnG2CPushInfoCode(msg) local msgData = DataSheetManager.ErrorCode:GetDataByID(msg.infoCode) local str = UTL.String.GetMessageFormatStr(msgData.IDS,msg.infoMsg) CTL.Tips.AddTipsMsg(str) if msg.infoCode == 1328 then --被踢出公会id CTL.VoiceRoom.ExitVoiceRoom(MDL.VoiceRoom.VoiceRoomType.Guild) myGuildInfo.guildId = 0 private.LeaveCloseView() EventSystem.Dispatch(EventID.UI_Guild_BeKickOutRefresh) end end function private.LeaveCloseView() CTL.GuildAllies.CloseAllFuncPanel() CTL.GuildWar.CloseAllFuncPanel() MDL.GuildAuction.ForceLockGuildWarAuction() CTL.Country.OnLeaveGuild() CTL.SlgGvE.OnLeaveGuild() EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildBasePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildApplyManifestoPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildPublicNotice) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildMainSetPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildChangeFrame) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildChangeNamePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildEditorChatNumber) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildNoticePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildRecruitManifestoPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildCheckPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAppointPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildMemberKickOut) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildChangePositionPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildWelcome) -- 如果在势力商店被踢,隐藏势力商铺页签 EventSystem.Dispatch(EventID.UI_OperationActivity_DataChanged) end function private.OnGuildApproval(msg) if msg.Resp.Code == 0 then Guild_Model.GetGuildInfoReq() if msg.isBatch then if msg.isAgree then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_AgreeAll) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_DeclineAll) end else if msg.isAgree then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Agree) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildApply_Decline) end end end end function private.OnBroadcastUpdateGuild(msg) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildBasePanel) or UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildAlliesBasePanel) then if msg.isUpdateList then Guild_Model.GetGuildListReq() elseif msg.isUpdateGuild then Guild_Model.GetGuildInfoReq() end end end function private.OnGuildChangeLeader(msg) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Guild_CommonSucceed1) myGuildInfo.jobTitle = Guild_Model.JobEnum.Common Guild_Model.GetGuildInfoReq() end end ------------------成员排序------------------ function Guild_Model.SortByLevel(members) table.sort(members,private.SortByLevel) end function Guild_Model.SortByGS(members) table.sort(members,private.SortByGS) end function Guild_Model.SortByToday(members) table.sort(members,private.SortByToday) end function Guild_Model.SortBy7Day(members) table.sort(members,private.SortBy7Day) end function Guild_Model.SortByJob(members) table.sort(members,private.SortByJob) end function Guild_Model.SortByOnline(members) table.sort(members,private.SortByOnline) end function private.SortByLevel(a,b) if a.roleInfo.level == b.roleInfo.level then if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.gsSum > b.roleInfo.gsSum else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime < b.roleInfo.logoutTime else return a.roleInfo.isOnline end end else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end else return a.roleInfo.level > b.roleInfo.level end end function private.SortByGS(a,b) if a.roleInfo.gsSum == b.roleInfo.gsSum then if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.level > b.roleInfo.level else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime < b.roleInfo.logoutTime else return a.roleInfo.isOnline end end else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end else return a.roleInfo.gsSum > b.roleInfo.gsSum end end function private.SortByToday(a,b) if a.fameContributeToday == b.fameContributeToday then if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.gsSum > b.roleInfo.gsSum else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime < b.roleInfo.logoutTime else return a.roleInfo.isOnline end end else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end else return a.fameContributeToday > b.fameContributeToday end end function private.SortBy7Day(a,b) if a.fameContribute7DaySum == b.fameContribute7DaySum then if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.gsSum > b.roleInfo.gsSum else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime < b.roleInfo.logoutTime else return a.roleInfo.isOnline end end else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end else return a.fameContribute7DaySum > b.fameContribute7DaySum end end function private.SortByJob(a,b) if a.jobTitle == b.jobTitle then if #a.identity == #b.identity then if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.gsSum > b.roleInfo.gsSum else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime < b.roleInfo.logoutTime else return a.roleInfo.isOnline end end else return #a.identity > #b.identity end else return a.jobTitle < b.jobTitle end end function private.SortByOnline(a,b) if a.roleInfo.isOnline and a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.gsSum > b.roleInfo.gsSum else if a.roleInfo.isOnline == b.roleInfo.isOnline then return a.roleInfo.logoutTime > b.roleInfo.logoutTime else return a.roleInfo.isOnline end end end function private.OnWelcomeJoin(msg) CTL.Guild.OnGuildNewMemberNotice(msg.roleInfo) end function private.OnBuildLevelUp(msg) if msg.Resp.Code == 0 then for i,v in ipairs(myGuildMemberInfo.buildingInfo) do if v.buildingId == msg.buildingInfo.buildingId then table.remove(myGuildMemberInfo.buildingInfo, i ) table.insert(myGuildMemberInfo.buildingInfo, i, msg.buildingInfo) end end local buildingData = DataSheetManager.GuildBuildingBase:GetDataByID(msg.buildingInfo.buildingId) CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBuildingConstructBegin,UIUtils.GetLocalizedTxt(Const_IDS[buildingData.BuildingName])) EventSystem.Dispatch(EventID.UI_Guild_GuildBuildRefresh) end end function private.OnBuildSpeedUp(msg) if msg.Resp.Code == 0 then for i,v in ipairs(myGuildMemberInfo.buildingInfo) do if v.buildingId == msg.buildingInfo.buildingId then table.remove(myGuildMemberInfo.buildingInfo, i ) table.insert(myGuildMemberInfo.buildingInfo, i, msg.buildingInfo) end end CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBuilding_BoostSucceed) EventSystem.Dispatch(EventID.UI_Guild_GuildBuildRefresh) end end function private.OnGuildDonateRank(msg) if msg.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_Guild_DonateRankRefresh, msg.danateInfos) end end function private.OnGuildDonate(msg) if msg.Resp.Code == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildDonate_DonateSucceed) Guild_Model.GetGuildInfoReq() EventSystem.Dispatch(EventID.UI_Guild_DonateRankRefresh, msg.danateInfos) end end function private.OnGuildDynamic(msg) if msg.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_Guild_DiaryRefresh, msg.events) end end ------------------------------------------- --region -------------------- 名望势力相关----------------------------------- -- 获取拍卖分红页签信息 function Guild_Model.GetGuildAuctionInfoReq() local msg = guild_operate_pb.GetGuildAuctionInfoReq() NetManager.SendMessage(MessageEnums.MessageGetGuildAuctionInfo, msg) end function private.GetGuildAuctionInfoResp(msg) for i, v in ipairs(msg.auctionAndRewardInfo) do private.GuildAuctionShareBonusInfo[MDL.GuildAuction.AuctionGuildShareIndex[v.auctionType]] = v end EventSystem.Dispatch(EventID.UI_Guild_AuctionShareBonusRefresh) end function private.GetGuildAuctionInfoResp(msg) for i, v in ipairs(msg.auctionAndRewardInfo) do private.GuildAuctionShareBonusInfo[MDL.GuildAuction.AuctionGuildShareIndex[v.auctionType]] = v end EventSystem.Dispatch(EventID.UI_Guild_AuctionShareBonusRefresh) end -- 拉取势力贡献活跃度 function Guild_Model.GetGuildSalaryInfoReq() local msg = guild_operate_pb.GetGuildSalaryInfoReq() NetManager.SendMessage(MessageEnums.MessageGetGuildSalaryInfo, msg) end function private.GetGuildSalaryInfoResp(msg) private.GuildFamousInfo.activityScore = msg.activityScore private.GuildFamousInfo.contribute = msg.contribute private.GuildFamousInfo.rewardInfo = msg.rewardInfo private.GuildFamousInfo.clientJobTitle = msg.jobTitle private.GuildFamousInfo.clientFamousGuild = msg.famousGuild private.GuildFamousInfo.baseRewardInfo = msg.baseRewardInfo EventSystem.Dispatch(EventID.UI_Guild_FamousInfoRefresh) end -- 拉取前三名势力 function Guild_Model.GetMaxReptGuildInfoReq() local msg = guild_operate_pb.GetMaxReptGuildInfoReq() NetManager.SendMessage(MessageEnums.MessageGetMaxReptGuildInfo, msg) end function private.GetMaxReptGuildInfoResp(msg) private.TopFamousGuildInfo = msg.guildInfo EventSystem.Dispatch(EventID.UI_Guild_FamousInfoRefresh) EventSystem.Dispatch(EventID.UI_Guild_RankInfo, msg.guildRankInfo) end -- 领取工资 function Guild_Model.RewardSalaryReq() local msg = guild_operate_pb.RewardSalaryReq() NetManager.SendMessage(MessageEnums.MessageRewardSalary, msg) end function private.RewardSalaryResp(msg) end -- 领取分红 function Guild_Model.RewardAuctionBonusReq(auctionType) local msg = guild_operate_pb.RewardAuctionBonusReq() --周日没活动,默认发送势力战type msg.auctionType = auctionType or auction_base_pb.GuildWar NetManager.SendMessage(MessageEnums.MessageRewardAuctionBonus, msg) end function private.RewardAuctionBonusResp(msg) if msg.Resp.Code == 0 then -- 领取成功更新 Guild_Model.GetGuildAuctionInfoReq() end end --- 基础方法 function Guild_Model.SetGuildAuctionShareChange(auctionAndRewardInfo) for i, v in ipairs(auctionAndRewardInfo) do private.GuildAuctionShareBonusInfo[MDL.GuildAuction.AuctionGuildShareIndex[v.auctionType]] = v end EventSystem.Dispatch(EventID.UI_Guild_AuctionShareBonusRefresh) end -- 获取我的势力活跃贡献度 function Guild_Model.GetMyGuildContributeScore() return private.GuildFamousInfo.activityScore or 0 end -- 获取势力名望信息 function Guild_Model.GetMyFamousInfo() return private.GuildFamousInfo end -- 按周累积的拍卖分红 function Guild_Model.UpdateWeekAuctionBonus(personalAuctionBonus) table.clear(private.WeekAccumulatedAuctionBonusInfo.ReceivedBonus) table.clear(private.WeekAccumulatedAuctionBonusInfo.WeekTotalBonus) table.clear(private.WeekAccumulatedAuctionBonusInfo.SlgReceivedBonus) table.clear(private.WeekAccumulatedAuctionBonusInfo.SlgWeekTotalBonus) for _, v in ipairs(personalAuctionBonus.ReceivedBonus) do private.WeekAccumulatedAuctionBonusInfo.ReceivedBonus[v.itemId] = v.itemCount end for _, v in ipairs(personalAuctionBonus.WeekTotalBonus) do private.WeekAccumulatedAuctionBonusInfo.WeekTotalBonus[v.itemId] = v.itemCount end for _, v in ipairs(personalAuctionBonus.SlgReceivedBonus) do private.WeekAccumulatedAuctionBonusInfo.SlgReceivedBonus[v.itemId] = v.itemCount end for _, v in ipairs(personalAuctionBonus.SlgWeekTotalBonus) do private.WeekAccumulatedAuctionBonusInfo.SlgWeekTotalBonus[v.itemId] = v.itemCount end EventSystem.Dispatch(EventID.UI_Guild_AuctionShareBonusRefresh) end -- 获取按周累积的拍卖分红 function Guild_Model.GetWeekAccumulatedAuctionBonus() return private.WeekAccumulatedAuctionBonusInfo end function Guild_Model.CanReceiveWeekAccumulatedAuctionBonus() for id, num in pairs(private.WeekAccumulatedAuctionBonusInfo.WeekTotalBonus) do local diff = private.WeekAccumulatedAuctionBonusInfo.ReceivedBonus[id] or 0 if num - diff > 0 then return true end end return false end function Guild_Model.CanReceiveSlgGvEWeekAuctionBonus() for id, num in pairs(private.WeekAccumulatedAuctionBonusInfo.SlgWeekTotalBonus) do local diff = private.WeekAccumulatedAuctionBonusInfo.SlgReceivedBonus[id] or 0 if num - diff > 0 then return true end end return false end -- 获取势力分红信息 --- @param activityID 活动ID 无则返回所有的拍卖分红信息 function Guild_Model.GetGuildAuctionShareBonusInfo(activityID) if activityID then return private.GuildAuctionShareBonusInfo[activityID] else return private.GuildAuctionShareBonusInfo end end function Guild_Model.GetGuildSalaryJobID() return private.GuildFamousInfo.clientJobTitle or 0 end -- 返回下次名望势力结算时间 ---@return 是否是首期 ---@return 下期结算倒计时 function Guild_Model.GetGuildBalanceTime() local leftTime = myGuildInfo.balanceTime - UTL.Time.GetServerTimestamp() return private.GuildFamousInfo.hasFirstBalance, leftTime > 0 and leftTime or 0 end function Guild_Model.GetHasBalanceNums() return private.GuildFamousInfo.hasBalanceNums or 0 end -- 自己当前是否在名门势力 function Guild_Model.IsMyGuildFamous() return private.GuildFamousInfo.famousGuild or false end -- 薪资上期是否名门 function Guild_Model.GetSalaryIsFamousGuild() return private.GuildFamousInfo.clientFamousGuild or false end function Guild_Model.GetSalaryJobID() return private.GuildFamousInfo.clientJobTitle end function Guild_Model.IsGuildSalaryManagement() return DataSheetManager.GuildJob:GetDataByID(private.GuildFamousInfo.clientJobTitle).Level >= 7 end -- 获取势力工资展示 function Guild_Model.GetSalaryRewards() local rewardList = {} for i, v in ipairs(private.GuildFamousInfo.baseRewardInfo) do if v.itemNum > 0 then table.insert(rewardList, {itemId = v.itemId, itemNum = v.itemNum, isBase = true}) end end for i, v in ipairs(private.GuildFamousInfo.rewardInfo) do if v.itemNum > 0 then table.insert(rewardList, {itemId = v.itemId, itemNum = v.itemNum}) end end return rewardList end function Guild_Model.SendFamousGuildNotification(targetID) local content = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Guild_PrestigiousGuildApplyMsg"]) CTL.ChannelChat.SendTextMsg(content, targetID, false, chat_pb.Personal) end --endregion---------------------------------------------------------------------- function private.OnLoginPostprocess() private.OnLeaderTaskInfoUpdate() end function Guild_Model.SetLeaderTaskInfo(guildLeaderTaskInfo, isInit) private.guildLeaderTaskInfo = guildLeaderTaskInfo private.leaderHasGotRewardCount = 0 if guildLeaderTaskInfo.rewardItems and #guildLeaderTaskInfo.rewardItems > 0 then for i, v in ipairs(guildLeaderTaskInfo.rewardItems) do if v.itemId == MDL.Currency.CurrencyType.DragonJade then private.leaderHasGotRewardCount = private.leaderHasGotRewardCount + v.itemNums end end end if isInit == false then private.OnLeaderTaskInfoUpdate() end end function private.OnLeaderTaskInfoUpdate() CTL.Guild.UpdateLeaderTaskRed() EventSystem.Dispatch(EventID.UI_Guild_LeaderTaskInfoUpdate, false) end function Guild_Model.IpairsLeaderTaskInfo() if private.guildLeaderTaskInfo and private.guildLeaderTaskInfo.canView then return ipairs(private.guildLeaderTaskInfo.guildTask) end return nil end function Guild_Model.CanViewLeaderReward() if private.guildLeaderTaskInfo and private.guildLeaderTaskInfo.canView then return true end return false end function Guild_Model.GetLeaderHasGetCount() return private.leaderHasGotRewardCount or 0 end -- -1表示未完成;0表示已完成未领取;1表示已领取 function Guild_Model.GetLeaderTaskState(taskId) local state = CTL.Guild.GuildLeaderTaskRewardState_UnFinished if private.guildLeaderTaskInfo and private.guildLeaderTaskInfo.canView then for _, v in ipairs(private.guildLeaderTaskInfo.guildTask) do if v.taskId == taskId then state = v.rewardState break end end end return state end function Guild_Model.GetLeaderTaskProgress(config) local curProgress, totalProgress = 0, 0 if private.guildTaskInfo and private.guildLeaderTaskInfo then local state = Guild_Model.GetLeaderTaskState(config.ID) if config.TaskProgress == 1 then --任务进度最大值为1 if state == CTL.Guild.GuildLeaderTaskRewardState_UnFinished then curProgress = 0 totalProgress = 1 else curProgress = 1 totalProgress = 1 end else --正常显示任务进度 for i, v in ipairs(private.guildTaskInfo) do if v.taskType == config.Enum then curProgress = v.param if config.Enum == Const_Enum_Auction then if private.GuildFamousInfo.hasBalanceNums == 0 then totalProgress = config.EnumParam[1] else totalProgress = config.EnumParam[2] end else local index = private.guildLeaderTaskInfo.guildBuildLevelRecord if index > #config.EnumParam then totalProgress = config.EnumParam[#config.EnumParam] else totalProgress = config.EnumParam[index] end end break end end end end return curProgress, totalProgress end function Guild_Model.RewardGuildLeaderTaskReq(taskId, isOneKey) local msg = NetManager.GetPB("guild_leader_task_opt_pb").RewardGuildLeaderTaskReq() msg.taskId = taskId msg.isOneKey = isOneKey NetManager.SendMessage(MessageEnums.MessageRewardGuildLeaderTask, msg) end function Guild_Model.GetGuildLeaderTaskInfoReq() local msg = NetManager.GetPB("guild_leader_task_opt_pb").GetGuildLeaderTaskInfoReq() NetManager.SendMessage(MessageEnums.MessageGetGuildLeaderTaskInfo, msg) end function private.OnGetGuildLeaderTaskInfo(msgResp) if msgResp.Resp.Code == 0 then private.guildTaskInfo = msgResp.guildTaskInfo if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildManagementRewardsPop) == false then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildManagementRewardsPop) end EventSystem.Dispatch(EventID.UI_Guild_LeaderTaskInfoUpdate, true) else UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildManagementRewardsPop) end end return Guild_Model