miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/MyGuildManager.lua

884 lines
33 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

MyGuildManager = {}
local this = MyGuildManager
local guildSacrificeRewardConfig=ConfigManager.GetConfig(ConfigName.GuildSacrificeRewardConfig)
local guildHelpConfig=ConfigManager.GetConfig(ConfigName.GuildHelpConfig)
function this.Initialize()
this.MyGuildInfo = nil
this.MyMemInfo = nil
this.MyGuildMemList = {}
this.MyGuildApplyList = {}
this.MyGuildLogList = {}
this._MemWalkData = {}
this.MyFeteInfo={}
end
-- 登录初始化数据
function MyGuildManager.InitBaseData(func)
if PlayerManager.familyId == 0 then
if func then func() end
return
end
NetManager.RequestMyGuildInfo(func)
end
-- 初始化所有数据
function MyGuildManager.InitAllData(func)
if PlayerManager.familyId == 0 then
if func then func() end
return
end
-- 有公会刷新一遍数据
local step = 0
local function _StepFunc()
step = step + 1
if step == 3 then
if func then func() end
end
end
NetManager.RequestMyGuildInfo(_StepFunc)
this.RequestMyGuildMembers(_StepFunc)
GuildFightManager.InitData(_StepFunc)
end
-- 设置我的公会信息
function MyGuildManager.SetMyGuildInfo(msg)
-- 公会信息
this.MyGuildInfo = msg.familyBaseInfo
this.MyFeteInfo.score= this.MyGuildInfo.fete --登录时的奖励进度信息 后续数据刷新由MyGuildManager.MyFeteInfo.score操作
LogBlue("this.MyGuildInfo.id:"..this.MyGuildInfo.id)
if this.MyGuildInfo.id then
PlayerManager.familyId = this.MyGuildInfo.id
end
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end
-- 设置我的公会信息
function MyGuildManager.SetMyMemInfo(msg)
-- 成员数据
this.MyMemInfo = msg.familyUserInfo
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end
--设置我的祭祀信息
function MyGuildManager.SetMyFeteInfo(msg)
this.MyFeteInfo.takeFeteReward=msg.familyUserInfo.takeFeteReward --祭祀领取进度
this.MyFeteInfo.lastFeteGuildId=msg.familyUserInfo.lastFeteGuildId --上次祭祀公会id
this.MyFeteInfo.lastFeteType=msg.familyUserInfo.lastFeteType --上次祭祀类型 //每日清除 5点推送
end
--设置祭祀 进度信息
function MyGuildManager.SetMyFeteInfo_ByScore(msg)
this.MyFeteInfo.score=msg.score
end
--设置祭祀5点刷新 数据重置
function MyGuildManager.SetMyFeteInfo_FiveRefresh(msg)
this.MyFeteInfo.takeFeteReward=msg.takeFeteReward
this.MyFeteInfo.lastFeteType=msg.lastFeteType
end
---============================ 行走相关======================================
-- 请求行走
function MyGuildManager.RequestWalk(pathlist, func)
NetManager.GuildWalkRequest(pathlist, func)
end
-- 设置公会中玩家得行走数据
function MyGuildManager.SetWalkData(msg)
this._MemWalkData = {}
--Log("==============公会行走数据初始化")
for i, data in ipairs(msg.familyWalkIndicaiton) do
--Log("uid = "..data.uid..", name = "..data.name..", 当前位置 = "..data.curPos)
this._MemWalkData[data.uid] = data
end
--Log("==============公会行走数据初始化")
end
-- 更新行走数据
function MyGuildManager.UpdateWalkData(msg)
if not this._MemWalkData then
this._MemWalkData = {}
end
this._MemWalkData[msg.uid] = msg
--Log("#NAME?")
Log("uid = "..msg.uid..", name = "..msg.name..", 当前位置 = "..msg.curPos)
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.WalkUpdate, msg)
end
-- 获取所有行走数据
function MyGuildManager.GetMemWalkData()
return this._MemWalkData
end
-- 获取某个成员得行走数据
function MyGuildManager.GetMemWalkDataById(uid)
return this._MemWalkData[uid]
end
---============================ 行走相关end======================================
-- 获取日志信息
function MyGuildManager.RequestMyGuildLog(func)
NetManager.RequestMyGuildLog(function(msg)
this.MyGuildLogList = msg.familyLogInfo
if func then func() end
-- 发送日志数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.LogDataUpdate)
end)
end
-- 获取成员信息
function MyGuildManager.RequestMyGuildMembers(func)
NetManager.RequestMyGuildMembers(function(msg)
this.MyGuildMemList = msg.familyUserInfo
table.sort(this.MyGuildMemList, function(a, b)
if a.seconds == b.seconds then
return a.position < b.position
end
return a.seconds < b.seconds
end)
if func then func() end
-- 发送成员数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.MemberDataUpdate)
end)
end
-- 获取申请信息
function MyGuildManager.RequestMyGuildApplyList(func)
NetManager.RequestMyGuildApply(function(msg)
this.MyGuildApplyList = msg.familyApply
if func then func() end
-- 发送申请数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.ApplyDataUpdate)
-- 刷新服务器红点
ResetServerRedPointStatus(RedPointType.Guild_Apply)
end)
end
-- 申请修改图腾
function MyGuildManager.RequestChangeLogo(logoId, func)
NetManager.RequestChangeLogo(logoId, function(msg)
this.MyGuildInfo.icon = logoId
if func then func() end
-- 发送申请数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end)
end
-- 获取我的公会信息
function MyGuildManager.GetMyGuildInfo()
return this.MyGuildInfo
end
-- 获取我的公会的成员数据
function MyGuildManager.GetMyGuildMemList()
return this.MyGuildMemList
end
-- 获取我的公会的会长信息
function MyGuildManager.GetMyGuildMasterInfo()
for _, v in ipairs(this.MyGuildMemList) do
if v.position == GUILD_GRANT.MASTER then
return v
end
end
end
-- 获取公会成员数据
function MyGuildManager.GetMemInfo(memId)
if not memId then return end
for _, v in ipairs(this.MyGuildMemList) do
if v.roleUid == memId then
return v
end
end
end
-- 重置公会成员战斗力
function MyGuildManager.ResetMemForce(memId, force)
if not memId then return end
for _, v in ipairs(this.MyGuildMemList) do
if v.roleUid == memId then
v.soulForce = force
break
end
end
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end
-- 获取我再公会中的数据
function MyGuildManager.GetMyMemInfo()
return this.MyMemInfo
end
-- 获取公会日志数据
function MyGuildManager.GetMyGuildLog()
return this.MyGuildLogList
end
-- 获取公会申请数据
function MyGuildManager.GetMyGuildApplyList()
return this.MyGuildApplyList
end
-- 获取我在公会中的职位
function MyGuildManager.GetMyPositionInGuild()
if PlayerManager.familyId == 0 then return end
if not this.MyMemInfo then return end
return this.MyMemInfo.position
end
-- 获取公会管理数量
function MyGuildManager.GetAdminMemNum()
local num = 0
for _, v in ipairs(this.MyGuildMemList) do
if v.position == GUILD_GRANT.ADMIN then
num = num + 1
end
end
return num
end
---============== 操作=================
-- 请求操作申请数据
function MyGuildManager.OperateApply(opType, applyId, func)
-- 公会战期间无法执行此操作
--if opType == GUILD_APPLY_OPTYPE.ONE_AGREE or opType == GUILD_APPLY_OPTYPE.ALL_AGREE then
-- if GuildFightManager.IsInGuildFight() then
-- PopupTipPanel.ShowTip("公会战期间无法执行此操作")
-- return
-- end
--end
if opType == GUILD_APPLY_OPTYPE.ALL_AGREE or opType == GUILD_APPLY_OPTYPE.ALL_REFUSE then
if #this.MyGuildApplyList == 0 then
PopupTipPanel.ShowTip("没有入会申请")
return
end
end
NetManager.RequestOperateMyGuildApply(opType, applyId, function()
if opType == GUILD_APPLY_OPTYPE.ALL_AGREE or opType == GUILD_APPLY_OPTYPE.ALL_REFUSE then
this.MyGuildApplyList = {}
elseif opType == GUILD_APPLY_OPTYPE.ONE_AGREE or opType == GUILD_APPLY_OPTYPE.ONE_REFUSE then
local removeIndex = nil
for i, v in ipairs(this.MyGuildApplyList) do
if v.roleUid == applyId then
removeIndex = i
break
end
end
-- 删除相应位置的数据
if removeIndex then
table.remove(this.MyGuildApplyList, removeIndex)
end
end
-- 发送申请数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.ApplyDataUpdate)
-- 成功回调
if func then func() end
end)
end
-- 请求修改公会宣言
function MyGuildManager.RequestChangeGuildAnnounce(announce, func)
local pos = this.GetMyPositionInGuild()
if pos == GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("您无权修改公会宣言")
return
end
if not announce or announce == "" then
PopupTipPanel.ShowTip("公会宣言不可为空")
return
end
NetManager.RequestChangeGuildBase(1, announce, function(msg)
if msg.result == 0 then
PopupTipPanel.ShowTip(msg.err)
return
end
this.MyGuildInfo.annouce = announce
if func then func() end
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end)
end
-- 请求修改公会名称
function MyGuildManager.RequestChangeGuildName(name, func)
local pos = this.GetMyPositionInGuild()
if pos == GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("您无权修改公会名称")
return
end
-- 判断物品数量
local cost = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).RenameCost
local haveNum = BagManager.GetItemCountById(cost[1][1])
if haveNum < cost[1][2] then
PopupTipPanel.ShowTip("所需物品不足")
return
end
if not name or name == "" then
PopupTipPanel.ShowTip("公会名称不可为空")
return
end
local config = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1)
local minLen, maxLen = config.NameSize[1], config.NameSize[2]
local len = StringWidth(name)
if len < minLen or len > maxLen then
PopupTipPanel.ShowTip("公会名称长度不符合规范2-6个字")
return
end
NetManager.RequestChangeGuildBase(0, name, function(msg)
if msg.result == 0 then
PopupTipPanel.ShowTip(msg.err)
return
end
this.MyGuildInfo.name = name
if func then func() end
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end)
end
-- 请求修改公会申请类型
function MyGuildManager.RequestChangeJoinType(joinType, limitLevel, func)
local pos = this.GetMyPositionInGuild()
if pos == GUILD_GRANT.MEMBER then return end
NetManager.RequestChangeJoinType(joinType, limitLevel, function()
this.MyGuildInfo.joinType = joinType
if func then func() end
-- 发送数据更新事件
--Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DataUpdate)
end)
end
-- 请求退出公会
function MyGuildManager.RequestQuitGuild(func)
-- 公会战期间无法执行此操作
if GuildFightManager.IsInGuildFight() then
PopupTipPanel.ShowTip("公会战期间无法执行此操作")
return
end
local pos = this.GetMyPositionInGuild()
if pos == GUILD_GRANT.MASTER then
PopupTipPanel.ShowTip("会长不能退出公会")
return
end
NetManager.RequestQuitGuild(function()
PlayerManager.familyId = 0
this.MyGuildInfo = nil
this.MyMemInfo = nil
this.MyFeteInfo={}
this.MyGuildMemList = {}
this.MyGuildApplyList = {}
this.MyGuildLogList = {}
if func then func() end
-- 退出公会成功事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.OnQuitGuild)
--清援助数据
MyGuildManager.SetGuildHelpInfo_FiveRefresh()
-- 退出公会成功
PopupTipPanel.ShowTip("退出公会成功")
-- 刷新服务器红点
ResetServerRedPointStatus(RedPointType.Guild_Apply)
ResetServerRedPointStatus(RedPointType.Guild_Shop)
ResetServerRedPointStatus(RedPointType.Shop_Guild_Check)
end)
end
-- 请求任命官职
function MyGuildManager.AppointmentPos(tId, tPos, func)
-- 公会战期间无法执行此操作
if GuildFightManager.IsInGuildFight() then
PopupTipPanel.ShowTip("公会战期间无法执行此操作")
return
end
if tId == PlayerManager.uid then
PopupTipPanel.ShowTip("无法对自己执行此操作")
return
end
-- 判断我是否有权限
local pos = MyGuildManager.GetMyPositionInGuild()
if pos == GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("您没有变更成员职位的权限")
return
end
--
if tPos == GUILD_GRANT.MASTER and pos ~= GUILD_GRANT.MASTER then
PopupTipPanel.ShowTip("您没有转让会长的权限")
return
end
-- 如果委任官员判断官员数量是否已达上限
if tPos == GUILD_GRANT.ADMIN then
local adminNum = this.GetAdminMemNum()
local guildData = this.GetMyGuildInfo()
local maxNum = ConfigManager.GetConfigData(ConfigName.GuildLevelConfig, guildData.levle).OfficalNum
if adminNum >= maxNum then
PopupTipPanel.ShowTip("已达官员最大数量")
return
end
end
-- 判断目标成员职位是否符合条件
local tData = this.GetMemInfo(tId)
if tPos == tData.position then
PopupTipPanel.ShowTip("此成员已经是公会"..GUILD_GRANT_STR[tPos])
return
end
-- 管理之间无法操作
if pos == GUILD_GRANT.ADMIN and tData.position == GUILD_GRANT.ADMIN then
PopupTipPanel.ShowTip("您无法对官员执行此操作")
return
end
NetManager.RequestMyGuildAppointment(tId, tPos, function()
-- 成员数据变动
this.RequestMyGuildMembers()
if func then func() end
end)
end
-- 请求踢人
function MyGuildManager.RequestKickOut(tId, func)
-- 公会战期间无法执行此操作
if GuildFightManager.IsInGuildFight() then
PopupTipPanel.ShowTip("公会战期间无法执行此操作")
return
end
if tId == PlayerManager.uid then
PopupTipPanel.ShowTip("无法对自己执行此操作")
return
end
-- 判断我是否有权限
local pos = MyGuildManager.GetMyPositionInGuild()
if pos == GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("您没有此权限")
return
end
-- 判断目标职位是否符合条件
local tData = this.GetMemInfo(tId)
-- 管理之间无法操作
if tData.position == GUILD_GRANT.MASTER then
PopupTipPanel.ShowTip("您无法对会长执行此操作")
return
elseif pos == GUILD_GRANT.ADMIN and tData.position == GUILD_GRANT.ADMIN then
PopupTipPanel.ShowTip("您无法对官员执行此操作")
return
end
NetManager.RequestKickOutFormMyGuild(tId, function()
-- 成员数据变动
this.RequestMyGuildMembers()
if func then func() end
end)
end
-- 请求退出公会
function MyGuildManager.RequestDismissGuild(dType, func)
-- 公会战期间无法执行解散公会的操作
if dType == 1 then
if GuildFightManager.IsInGuildFight() then
PopupTipPanel.ShowTip("公会战期间无法执行此操作")
return
end
end
local pos = this.GetMyPositionInGuild()
if pos ~= GUILD_GRANT.MASTER then
PopupTipPanel.ShowTip("您没有此权限")
return
end
NetManager.RequestDismissGuild(dType, function()
if func then func() end
-- 解散公会成功
local destroyTime = ConfigManager.GetConfigData(ConfigName.GuildSetting, 1).DestroyTime
local timeStr = ""
if destroyTime < 60 then
timeStr = destroyTime .. ""
elseif destroyTime >= 60 and destroyTime < 3600 then
timeStr = math.floor(destroyTime/60).."分钟"
else
timeStr = math.floor(destroyTime/3600).."小时"
end
PopupTipPanel.ShowTip(dType == 1 and string.format("公会将在%s后解散", timeStr) or "取消解散成功")
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.DismissStatusChanged)
end)
end
-- 判断商店栏位是否解锁
local _SortUnLockLevel = nil
function MyGuildManager.GetGuildShopSortIsUnLock(sort)
if not _SortUnLockLevel then
_SortUnLockLevel = {}
local guildLevelConfig = ConfigManager.GetConfig(ConfigName.GuildLevelConfig)
for level, data in ConfigPairs(guildLevelConfig) do
for sort = 1, data.ShopSort do
if not _SortUnLockLevel[sort] then
_SortUnLockLevel[sort] = level
end
end
end
end
local unLockLevel = _SortUnLockLevel[sort]
-- 没有解锁等级 999级解锁
if not unLockLevel then return false, 999 end
-- 判断是否解锁
local isUnLock = this.GetMyGuildInfo().levle >= unLockLevel
return isUnLock, unLockLevel
end
---=========== 服务器推送方法================
-- 被提出公会
function MyGuildManager.BeKickOut(msg)
-- uid 为0表示公会解散
LogPink("msg.uid "..msg.uid)
if msg.uid == PlayerManager.uid or msg.uid == 0 then
PlayerManager.familyId = 0
this.MyGuildInfo = nil
this.MyMemInfo = nil
this.MyFeteInfo={}
this.MyGuildMemList = {}
this.MyGuildApplyList = {}
this.MyGuildLogList = {}
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.BeKickOut)
-- 添加tip显示
GuildManager.AddGuildTip(GUILD_TIP_TYPE.KICKOUT, msg.uid)
-- 刷新服务器红点
ResetServerRedPointStatus(RedPointType.Guild_Apply)
ResetServerRedPointStatus(RedPointType.Guild_Shop)
ResetServerRedPointStatus(RedPointType.Shop_Guild_Check)
else
local rIndex = nil
for index, mem in ipairs(this.MyGuildMemList) do
if mem.roleUid == msg.uid then
rIndex = index
break
end
end
if rIndex then
local rMem = table.remove(this.MyGuildMemList, rIndex)
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.KickOut, rMem.roleUid)
end
LogPink("msg.uid "..msg.uid)
--清除援助信息
-- MyGuildManager.DelSingleGuildHelpInfo(msg.uid)
end
end
-- 我的职位更新
function MyGuildManager.UpdateGuildPosition(msg)
local pos = msg.position
local uid = msg.uid
if uid == PlayerManager.uid then
local oldPos = this.MyMemInfo.position
this.MyMemInfo.position = pos
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.PositionUpdate)
-- 加入tip显示
GuildManager.AddGuildTip(GUILD_TIP_TYPE.POS, pos, oldPos)
-- 降职重置红点儿
if pos == GUILD_GRANT.MEMBER then
-- 刷新服务器红点
ResetServerRedPointStatus(RedPointType.Guild_Apply)
end
end
-- 更新成员列表里的职位
for _, v in ipairs(this.MyGuildMemList) do
if v.roleUid == uid then
v.position = pos
break
end
end
-- 发送数据更新事件
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.MemberDataUpdate)
end
--公会祭祀红点检测
function MyGuildManager.CheckGuildFeteRedPoint()
if PlayerManager.familyId == 0 then
return
end
if this.MyFeteInfo.lastFeteType==0 then --未祭祀
return true
end
local d={}--进度条可领取
for i = 1, 3 do
if this.MyFeteInfo.score and this.MyFeteInfo.score>=guildSacrificeRewardConfig[i].Score and this.MyGuildInfo.id and this.MyGuildInfo.id==this.MyFeteInfo.lastFeteGuildId then --有未领取 并且是当前公会 与上次祭祀公会相同
table.insert(d,i)
end
end
for n = 1, #d do
for index, v in ipairs(this.MyFeteInfo.takeFeteReward) do --已领
if d[n]==v then
table.remove(d,n) --删除已领数据 剩余未领取数据
end
end
end
local isOn =false
--若剩余数据 有未领取
isOn= #d>0
return isOn
end
this.isPanelRequest = false
--公会援助
function MyGuildManager.SetMyAidInfo(msg)
this.MyFeteInfo.guildHelpInfo = msg.familyUserInfo.guildHelpInfo
this.MyFeteInfo.guildHelpTime = msg.familyUserInfo.guildHelpTime
this.MyFeteInfo.isTakeGuildHelpReward = msg.familyUserInfo.isTakeGuildHelpReward
this.MyFeteInfo.GuildAidTimeStamp = msg.familyUserInfo.lastHelpSendTime
end
function MyGuildManager.SetMyAidBoxStateInfo(boxState)
this.MyFeteInfo.isTakeGuildHelpReward = boxState
MyGuildManager.RefreshAidRedPot()
end
this.allGuildHelpInfo = {}--援助 公会援助所有信息
--设置援助5点刷新 数据重置
function MyGuildManager.SetGuildHelpInfo_FiveRefresh()
this.MyFeteInfo.guildHelpInfo = nil
this.MyFeteInfo.guildHelpTime = 0
this.allGuildHelpInfo = {}
MyGuildManager.RefreshAidRedPot()
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.RefreshGuildAid)
end
--初始化工会援助所有信息
function MyGuildManager.SetAllGuildHelpInfo(msg)
for i = 1, #msg.guildHelpInfoIndication do
if msg.guildHelpInfoIndication[i].uid and msg.guildHelpInfoIndication[i].uid > 0 then
local singleHelpInfo = {}
singleHelpInfo.uid = msg.guildHelpInfoIndication[i].uid
singleHelpInfo.name = msg.guildHelpInfoIndication[i].name
singleHelpInfo.guildHelpInfo = {}
for j = 1, #msg.guildHelpInfoIndication[i].guildHelpInfo do
if msg.guildHelpInfoIndication[i].guildHelpInfo[j].num ~= -1 then
table.insert(singleHelpInfo.guildHelpInfo,{type = msg.guildHelpInfoIndication[i].guildHelpInfo[j].type,--碎片id
num = msg.guildHelpInfoIndication[i].guildHelpInfo[j].num,--总获得数量
hadtakenum = msg.guildHelpInfoIndication[i].guildHelpInfo[j].hadtakenum, })--已领取数量
end
end
LogRed(" msg.guildHelpInfoIndication[i].uid ".. msg.guildHelpInfoIndication[i].uid)
this.allGuildHelpInfo[msg.guildHelpInfoIndication[i].uid] = singleHelpInfo
end
end
MyGuildManager.RefreshAidRedPot()
end
--当公会成员退出时清除求援信息
function MyGuildManager.DelSingleGuildHelpInfo(Deluid)
-- LogGreen("DelSingleGuildHelpInfo "..Deluid)
for uid, value in pairs(this.allGuildHelpInfo) do
if uid == Deluid then
this.allGuildHelpInfo[uid] = nil
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.RefreshGuildAid)
MyGuildManager.RefreshAidRedPot()
end
end
end
--推送更新工会援助信息
function MyGuildManager.SetSingleGuildHelpInfo(msg)
LogGreen("msg.uid "..msg.uid)
LogGreen("#this.allGuildHelpInfo "..LengthOfTable(this.allGuildHelpInfo))
local isStarAdd = true
for uid, value in pairs(this.allGuildHelpInfo) do
LogGreen("uid "..uid.." "..msg.uid)
if uid == msg.uid then
isStarAdd = false
this.allGuildHelpInfo[uid].uid = msg.uid
this.allGuildHelpInfo[uid].name = msg.name
this.allGuildHelpInfo[uid].guildHelpInfo = {}
LogGreen("msg.guildHelpInfo "..#msg.guildHelpInfo)
for j = 1, #msg.guildHelpInfo do
LogGreen("推送更新工会援助信息 "..msg.uid.." "..msg.guildHelpInfo[j].type.." "..msg.guildHelpInfo[j].num.." "..msg.guildHelpInfo[j].hadtakenum)
if msg.guildHelpInfo[j].num ~= -1 then
table.insert(this.allGuildHelpInfo[uid].guildHelpInfo,{type = msg.guildHelpInfo[j].type,--碎片id
num = msg.guildHelpInfo[j].num,--总获得数量
hadtakenum = msg.guildHelpInfo[j].hadtakenum, })--已领取数量
else
if this.allGuildHelpInfo[uid] then
this.allGuildHelpInfo[uid] = nil
end
end
end
end
end
if isStarAdd then
if msg.uid and msg.uid > 0 then
local singleHelpInfo = {}
singleHelpInfo.uid = msg.uid
singleHelpInfo.name = msg.name
singleHelpInfo.guildHelpInfo = {}
-- LogGreen("msg.guildHelpInfo "..#msg.guildHelpInfo)
for j = 1, #msg.guildHelpInfo do
-- LogGreen("推送更新工会援助信息 "..msg.uid.." "..msg.guildHelpInfo[j].type)
if msg.guildHelpInfo[j].num ~= -1 then
table.insert(singleHelpInfo.guildHelpInfo,{type = msg.guildHelpInfo[j].type,--碎片id
num = msg.guildHelpInfo[j].num,--总获得数量
hadtakenum = msg.guildHelpInfo[j].hadtakenum, })--已领取数量
end
end
LogRed(" msg.uid ".. msg.uid)
this.allGuildHelpInfo[msg.uid] = singleHelpInfo
end
end
MyGuildManager.SetSingleGuildHelpInfoRefreshMyData(msg)
end
--自己发的援助更新自己信息
function MyGuildManager.SetSingleGuildHelpInfoRefreshMyData(msg)
if msg then
if msg.uid == PlayerManager.uid then
-- LogPink("自己发的援助更新自己信息 "..msg.uid.." "..msg.guildHelpInfo[1].type)
this.MyFeteInfo.guildHelpInfo = msg.guildHelpInfo
end
end
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.RefreshGuildAid)
MyGuildManager.RefreshAidRedPot()
end
--公会援助
function MyGuildManager.SetMyAidInfoHadtakenum(chipId,hadtakenum)
if this.MyFeteInfo.guildHelpInfo and #this.MyFeteInfo.guildHelpInfo > 0 then
for i = 1, #this.MyFeteInfo.guildHelpInfo do
if this.MyFeteInfo.guildHelpInfo[i].type == chipId then
this.MyFeteInfo.guildHelpInfo[i].hadtakenum = this.MyFeteInfo.guildHelpInfo[i].hadtakenum + hadtakenum
end
end
end
MyGuildManager.RefreshAidRedPot()
end
--更新自己援助次数
function MyGuildManager.SetSingleGuildHelpguildHelpTimeData()
if this.MyFeteInfo.guildHelpTime and this.MyFeteInfo.guildHelpTime > 0 then
this.MyFeteInfo.guildHelpTime = this.MyFeteInfo.guildHelpTime + 1
else
this.MyFeteInfo.guildHelpTime = 1
end
MyGuildManager.RefreshAidRedPot()
end
--更新自己援助CD时间
function MyGuildManager.SetGuildHelpCDTimeData()
this.MyFeteInfo.GuildAidTimeStamp = GetTimeStamp()
end
function MyGuildManager.GetAllGuildHelpInfo()
local curAllGuildHelpInfo = {}
LogGreen("this.allGuildHelpInfo "..LengthOfTable(this.allGuildHelpInfo))
for key, value in pairs(this.allGuildHelpInfo) do
LogGreen("value.guildHelpInfo "..#value.guildHelpInfo)
for j = 1, #value.guildHelpInfo do
local aidMaxNum = 5
for k = 1, #guildHelpConfig[1].RecourseReward do
if guildHelpConfig[1].RecourseReward[k][2] == value.guildHelpInfo[j].type then
aidMaxNum = guildHelpConfig[1].RecourseReward[k][3]
end
end
LogGreen("aidMaxNum "..aidMaxNum .." ".. value.guildHelpInfo[j].num .." "..value.uid .." ".. PlayerManager.uid)
if aidMaxNum ~= value.guildHelpInfo[j].num and value.uid ~= PlayerManager.uid then
table.insert(curAllGuildHelpInfo,{type = value.guildHelpInfo[j].type,--碎片id
num = value.guildHelpInfo[j].num,--总获得数量
hadtakenum = value.guildHelpInfo[j].hadtakenum,
uid = value.uid,
name = value.name,
})--已领取数量
end
end
end
LogGreen("curAllGuildHelpInfo "..#curAllGuildHelpInfo)
return curAllGuildHelpInfo
end
this.allGuildHelpRecordInfo = {}--援助 公会援助记录所有信息
--初始化工会援助记录所有信息
function MyGuildManager.SetAllGuildHelpLogInfo(msg)
this.allGuildHelpRecordInfo = msg.guildHelpLog
end
--推送更新工会援助记录所有信息
function MyGuildManager.SetSingleGuildHelpLogInfo(msg)
table.insert(this.allGuildHelpRecordInfo,msg.guildHelpLog)
end
--获取我的公会援助红点
function MyGuildManager.GetMyGuildHelpRedPoint()
if not PlayerManager.familyId or PlayerManager.familyId == 0 then return false end
--是否还有援助次数
local isShowRedPoint = false
if this.MyFeteInfo.guildHelpInfo then
isShowRedPoint = #this.MyFeteInfo.guildHelpInfo < ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseTime[1]
else
isShowRedPoint = true
end
if not isShowRedPoint then
for i = 1, #this.MyFeteInfo.guildHelpInfo do
if this.MyFeteInfo.guildHelpInfo[i].num > this.MyFeteInfo.guildHelpInfo[i].hadtakenum then
isShowRedPoint = true
end
end
end
return isShowRedPoint
end
--获取公会军团援助红点
function MyGuildManager.GetMyAidOtherGuildHelpRedPoint()
if not PlayerManager.familyId or PlayerManager.familyId == 0 or LengthOfTable(this.allGuildHelpInfo) < 1 then return false end
for key, value in pairs(this.allGuildHelpInfo) do
LogBlue(LengthOfTable(this.allGuildHelpInfo))
LogBlue("key:"..key.." value"..value.uid)
LogBlue("value.guildHelpInfo:"..LengthOfTable(value.guildHelpInfo))
if value.uid ~= PlayerManager.uid and this.MyFeteInfo.guildHelpTime < ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).HelpTime[1]
and LengthOfTable(value.guildHelpInfo) > 0 then
for j = 1, #value.guildHelpInfo do
local aidMaxNum = 5
for k = 1, #guildHelpConfig[1].RecourseReward do
if guildHelpConfig[1].RecourseReward[k][2] == value.guildHelpInfo[j].type then
aidMaxNum = guildHelpConfig[1].RecourseReward[k][3]
end
end
LogGreen("aidMaxNum "..aidMaxNum .." ".. value.guildHelpInfo[j].num .." "..value.uid .." ".. PlayerManager.uid)
if aidMaxNum > value.guildHelpInfo[j].num then
LogBlue("MyGuildManager.GetMyAidOtherGuildHelpRedPoint返回true")
return true
end
end
end
end
return false
end
--获取公会援助宝箱红点
function MyGuildManager.GetGuildHelpBoxRedPoint()
if not PlayerManager.familyId or PlayerManager.familyId == 0 then return false end
local chipMaxNum = ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseTime[2]
local curFinishAidChipNum = 0
if this.MyFeteInfo.guildHelpInfo and #this.MyFeteInfo.guildHelpInfo > 0 then
for i = 1, #this.MyFeteInfo.guildHelpInfo do
local curguildHelpInfo = this.MyFeteInfo.guildHelpInfo[i]
if curguildHelpInfo.hadtakenum == chipMaxNum then
curFinishAidChipNum = curFinishAidChipNum + 1
end
end
end
if not MyGuildManager.MyFeteInfo.isTakeGuildHelpReward and curFinishAidChipNum >= ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseTime[1] then
return true
end
return false
end
function MyGuildManager.RefreshAidRedPot()
if not PlayerManager.familyId or PlayerManager.familyId == 0 then return end
CheckRedPointStatus(RedPointType.Guild_AidBox)
CheckRedPointStatus(RedPointType.Guild_AidGuild)
CheckRedPointStatus(RedPointType.Guild_AidMy)
end
function MyGuildManager.ShowGuildAidCdTime(_isShowTips)
local isShowTips = _isShowTips or true
-- 判断是否在冷却
local _CurTimeStamp = GetTimeStamp()
local stampTime = ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseCD
if this.MyFeteInfo.GuildAidTimeStamp and _CurTimeStamp - this.MyFeteInfo.GuildAidTimeStamp < stampTime then
if isShowTips then
local cd = math.floor(stampTime - (_CurTimeStamp - this.MyFeteInfo.GuildAidTimeStamp))
PopupTipPanel.ShowTip("操作需间隔"..GetLeftTimeStrByDeltaTime(cd).."")
end
return false
end
return true
end
return this