local GuildAllies_Controller = {}
local private = {}
local EventSystem = require('Event/EventSystem')
local AllyPosImage =
{
"slz_1_icon",
"slz_2_icon",
"slz_3_icon",
"slz_4_icon",
}
local AllyRankImage =
{
[1] = ConstAssetPathConfig.Path7,
[2] = ConstAssetPathConfig.AssetPath54,
[3] = ConstAssetPathConfig.AssetPath55,
[4] = ConstAssetPathConfig.AssetPath56
}
local PlusStr = "+%d"
local OfficialPlusStr = "(+%d)"
local ExtraStr = "%s~%d"
local SubstractStr = "-%d"
local OfficialSubstractStr = "(-%d)"
local RedStr = "%d"
local WhiteStr = "%d"
local ValueStr = "+%d"
local PercentStr = "+%d%%"
local PercentStr_1 = "+%0.1f%%"
local RankBuffStr = "%s%s"
local GuildMoneyStr = "%s/%d"
local FP=FP
local OperateLimit = #DataSheetManager.ConstData:GetDataByID("GuildAlliesUnlockParams").IntListValue
local MaxSuccessRate = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GuildAlliesMaxSuccessRate").FloatValue)
local MinSuccessRate = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GuildAlliesMinSuccessRate").FloatValue)
local MaxFriendlinessRatio = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GuildAlliesMaxFriendlinessRatio").FloatValue)
local MinFriendlinessRatio = FP.tonumberV1(DataSheetManager.ConstData:GetDataByID("GuildAlliesMinFriendlinessRatio").FloatValue)
local AllyOprCDDuration = DataSheetManager.ConstData:GetDataByID("GuildAlliesPunishTime").IntValue
local AllyProtectDuration = DataSheetManager.ConstData:GetDataByID("GuildAlliesProtectTime").IntValue
local guild_power_oper = require 'Proto/guild_power_oper_pb'
local GuildAllies_Next_RefreshTime_Key = "GuildAllies_Next_RefreshTime_Key"
local DailyRefreshHMS = DataSheetManager.TimeRefresh:GetDataByID(1).HMS + UTL.Time.GetDisplayDiffLocalTimeZone()
local ResultID =
{
AllianceSuccess = 1,
AllianceFail = 2,
Talk = 3,
Party = 4,
PerfectVisit = 5,
NormalVisit = 6,
Accident = 7,
}
local InteractionTipViewContext =
{
powerID = 0,
targetGuildID = 0,
strategyID = 0,
sortID = 0,
isGoodResult = true,
params = nil,
accidentParams = nil,
allyIndex = 0
}
GuildAllies_Controller.VisitTicketItemID = 15
--策略结果类型
GuildAllies_Controller.StrategyResultType = {
Unknown = 0, --未知结果
Normal = 1, --普通结果
Perfect = 2, --完美结果
}
--------------------- 系统函数 ----------------------------
function GuildAllies_Controller.OnStartup()
EventSystem.Regist(EventID.New_Day_Refresh, GuildAllies_Controller.OnNewDayRefresh)
end
----------------------------------------------------------
-------------------------- 界面操作 -----------------------
function GuildAllies_Controller.TriggerVisitResult(msgResp)
local resultID = msgResp.isGoodStrategy and ResultID.PerfectVisit or ResultID.NormalVisit
local resultCfg = DataSheetManager.GuildAlliesResult:GetDataByID(msgResp.powerID)
local resultParams = resultCfg.Result_Table[resultID]
-- 打开对应tips界面
private.ResetInteractionTipViewContext()
InteractionTipViewContext.strategyID = 1
InteractionTipViewContext.sortID = msgResp.type
InteractionTipViewContext.powerID = msgResp.powerID
InteractionTipViewContext.params = resultParams
InteractionTipViewContext.isGoodResult = msgResp.isGoodStrategy
InteractionTipViewContext.totalCount = msgResp.visitTimes
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesLobbyTips)
UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildAlliesLobbyTips, InteractionTipViewContext)
end
function GuildAllies_Controller.TriggerTalkAndPartyResult(msgResp)
local resultID = msgResp.type == guild_power_oper.PowerAdvise and ResultID.Talk or ResultID.Party
local resultCfg = DataSheetManager.GuildAlliesResult:GetDataByID(msgResp.powerID)
local resultParams = resultCfg.Result_Table[resultID]
-- 打开对应tips界面
private.ResetInteractionTipViewContext()
InteractionTipViewContext.strategyID = 2
InteractionTipViewContext.sortID = msgResp.type
InteractionTipViewContext.powerID = msgResp.powerID
InteractionTipViewContext.params = resultParams
InteractionTipViewContext.isGoodResult = true
InteractionTipViewContext.targetGuildID = msgResp.targetGuildID
InteractionTipViewContext.accidentParams = msgResp.isAccident and resultCfg.Result_Table[ResultID.Accident] or nil
InteractionTipViewContext.totalCount = msgResp.AdviseTimes
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesLobbyTips)
UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildAlliesLobbyTips, InteractionTipViewContext)
end
function GuildAllies_Controller.TriggerAllyResult(msgResp)
-- 结盟表现
if msgResp.type == guild_power_oper.Union then
local resultCfg = DataSheetManager.GuildAlliesResult:GetDataByID(msgResp.powerID)
local resultID = msgResp.unionResult == guild_power_oper.GPSuccess and ResultID.AllianceSuccess or ResultID.AllianceFail
local resultParams = resultCfg.Result_Table[resultID]
-- 打开对应tips界面
private.ResetInteractionTipViewContext()
InteractionTipViewContext.strategyID = 3
InteractionTipViewContext.sortID = 1
InteractionTipViewContext.powerID = msgResp.powerID
InteractionTipViewContext.params = resultParams
InteractionTipViewContext.isGoodResult = msgResp.unionResult == guild_power_oper.GPSuccess
InteractionTipViewContext.allyIndex = msgResp.allyIndex
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesAlignTips)
UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildAlliesAlignTips, InteractionTipViewContext)
elseif msgResp.type == guild_power_oper.Cancel then
if msgResp.unionResult == guild_power_oper.GPSuccess then
EventSystem.Dispatch(EventID.UI_GuildAlliesMyAllies_Refresh)
CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildAllies_TerminateSucceed"])
else
-- 提示操作失败
CTL.Tips.AddTipsMsg(Const_IDS["IDS_InfoChange"])
end
end
end
function GuildAllies_Controller.TriggerCancelAlly(allyData)
if not allyData then
return
end
local guildAlliesData = DataSheetManager.GuildAlliesData:GetDataByID(allyData.powerID)
private.ResetInteractionTipViewContext()
InteractionTipViewContext.powerID = allyData.powerID
InteractionTipViewContext.allyIndex = allyData.allyIndex
UTL.MessageBox.ShowOKCancelBox("", string.FormatByIdsId(Const_IDS["IDS_GuildAllies_TerminateConfirm"], UIUtils.GetLocalizedTxt(Const_IDS[guildAlliesData.AlliesName])), CTL.GuildAllies.RequestCancelAlly)
end
function GuildAllies_Controller.RequestCancelAlly()
if not CTL.GuildAllies.HasPermissionByTitle() then
CTL.Tips.AddTipsMsg(Const_IDS["IDS_Guild_CommonFail4"])
return
end
MDL.GuildAllies.RequestCancelGuildAlliesAlly(InteractionTipViewContext.powerID, InteractionTipViewContext.allyIndex)
end
function private.ResetInteractionTipViewContext()
InteractionTipViewContext.powerID = 0
InteractionTipViewContext.targetGuildID = 0
InteractionTipViewContext.strategyID = 0
InteractionTipViewContext.sortID = 0
InteractionTipViewContext.isGoodResult = false
InteractionTipViewContext.params = nil
InteractionTipViewContext.accidentParams = nil
InteractionTipViewContext.allyIndex = 0
end
-----------------------------------------------------------
function GuildAllies_Controller.SetTextFriendlinessBenefit(txtCmp, dataCfg)
if not txtCmp or not dataCfg then
return
end
local addStr = dataCfg.MaxFriendlinessBenefit > 0 and string.format(ExtraStr, string.format(PlusStr, dataCfg.MinFriendlinessBenefit), dataCfg.MaxFriendlinessBenefit) or string.format(PlusStr, dataCfg.MinFriendlinessBenefit)
local isUnlock = private.IsUnlockOfficialAffect(dataCfg)
local officialAddStr = (isUnlock and dataCfg.OfficerBenefit > 0) and string.format(OfficialPlusStr, dataCfg.OfficerBenefit) or ""
UIUtils.SetLabel(txtCmp, string.format(RankBuffStr, addStr, officialAddStr))
end
-- 根据策略显示收益结果,isPerfectStrategy 是否为最佳策略
function GuildAllies_Controller.SetTextFriendlinessBenefitByStrategy(txtCmp, dataCfg,strategyResultType)
if not txtCmp or not dataCfg then
return
end
--动态结果显示
local addStr
if strategyResultType == GuildAllies_Controller.StrategyResultType.Unknown then
addStr = dataCfg.MaxFriendlinessBenefit > 0 and string.format(ExtraStr, string.format(PlusStr, dataCfg.MinFriendlinessBenefit), dataCfg.MaxFriendlinessBenefit) or string.format(PlusStr, dataCfg.MinFriendlinessBenefit)
elseif strategyResultType == GuildAllies_Controller.StrategyResultType.Normal then
addStr = string.format(PlusStr, dataCfg.MinFriendlinessBenefit)
else
addStr = dataCfg.MaxFriendlinessBenefit > 0 and string.format(PlusStr, dataCfg.MaxFriendlinessBenefit) or string.format(PlusStr, dataCfg.MinFriendlinessBenefit)
end
local isUnlock = private.IsUnlockOfficialAffect(dataCfg)
local officialAddStr = (isUnlock and dataCfg.OfficerBenefit > 0) and string.format(OfficialPlusStr, dataCfg.OfficerBenefit) or ""
UIUtils.SetLabel(txtCmp, string.format(RankBuffStr, addStr, officialAddStr))
end
-- 获取好感度增益数值
function GuildAllies_Controller.GetFriendlinessBenefit(dataCfg, isGoodResult)
if not dataCfg then return 0 end
local isUnlock = private.IsUnlockOfficialAffect(dataCfg)
local officialBenefit = isUnlock and dataCfg.OfficerBenefit or 0
if dataCfg.MaxFriendlinessBenefit == 0 then return dataCfg.MinFriendlinessBenefit + officialBenefit end
return isGoodResult and dataCfg.MaxFriendlinessBenefit + officialBenefit or dataCfg.MinFriendlinessBenefit + officialBenefit
end
-- 设置好感度减益显示
function GuildAllies_Controller.SetTextFriendlinessLose(txtCmp, dataCfg)
if not txtCmp or not dataCfg then return end
local subStr = string.format(SubstractStr, dataCfg.BenefitReduction)
local isUnlock = private.IsUnlockOfficialAffect(dataCfg)
local officialSubStr = (isUnlock and dataCfg.OfficerReduction > 0) and string.format(OfficialSubstractStr, dataCfg.OfficerReduction) or ""
UIUtils.SetLabel(txtCmp, string.format(RankBuffStr, subStr, officialSubStr))
end
-- 获取好感度减益数值
function GuildAllies_Controller.GetFriendlinessLose(dataCfg)
if not dataCfg then return 0 end
local isUnlock = private.IsUnlockOfficialAffect(dataCfg)
return isUnlock and dataCfg.BenefitReduction + dataCfg.OfficerReduction or dataCfg.BenefitReduction
end
-- 获取联盟操作CD时间
function GuildAllies_Controller.GetAllyOprCDTimeState(timeStamp)
if not timeStamp or timeStamp == 0 or timeStamp + AllyOprCDDuration < UTL.Time.GetServerTimestamp() then return false, nil end
local timeStr = string.FormatByIdsKey("IDS_GuildAllies_AlignCooldown", UTL.Time.FormatTimeSeconds(timeStamp + AllyOprCDDuration - UTL.Time.GetServerTimestamp()))
return true, timeStr
end
-- 获取联盟保护时间
function GuildAllies_Controller.GetAllyProtectTimeState(timeStamp)
if not timeStamp or timeStamp == 0 or timeStamp + AllyProtectDuration < UTL.Time.GetServerTimestamp() then return false, nil, nil end
local protectStr = UTL.Time.FormatTimeClockBySeconds(timeStamp + AllyProtectDuration - UTL.Time.GetServerTimestamp())
local timeStr = string.FormatByIdsKey("IDS_GuildAllies_ProtectTime", protectStr)
return true, timeStr, protectStr
end
-- 设置功勋奖励
function GuildAllies_Controller.SetTextGuildMoney(txt, dataCfg)
if not txt or not dataCfg then return end
UIUtils.SetLabel(txt, string.format(PlusStr, dataCfg.GuildMoneyBenefit))
end
-- 设置道具显示
function GuildAllies_Controller.SetTextItem(txtCmp, itemID, itemNum)
if not txtCmp or not itemID or not itemNum then return "" end
local remainCount = MDL.Bag.GetItemCount(itemID)
local remainStr = remainCount >= itemNum and string.format(WhiteStr, itemNum) or string.format(RedStr, itemNum)
UIUtils.SetLabel(txtCmp, remainStr)
end
-- 设置货币显示
function GuildAllies_Controller.SetTextMoney(txtCmp, itemID, itemNum)
if not txtCmp or not itemID or not itemNum then return "" end
UIUtils.SetLabel(txtCmp, MDL.Currency.GetMoneyCount(itemID) >= itemNum and string.format(WhiteStr, itemNum) or string.format(RedStr, itemNum))
end
-- 设置军团货币显示
function GuildAllies_Controller.SetTextGuildMoneyForAlignPanel(txtCmp, itemID, itemNum)
if not MDL.Guild.GetGuildMemberInfo() or not txtCmp or not itemID or not itemNum then return "" end
local myGuildInfo = MDL.Guild.GetMyGuildInfo()
local guildCapitalNum = myGuildInfo and myGuildInfo.goldIngot or 0
local consumeStr = guildCapitalNum >= itemNum and string.format(WhiteStr, guildCapitalNum) or string.format(RedStr, guildCapitalNum)
UIUtils.SetLabel(txtCmp, string.format(GuildMoneyStr, consumeStr, itemNum))
-- UIUtils.SetLabel(txtCmp, guildCapitalNum >= itemNum and string.format(WhiteStr, itemNum) or string.format(RedStr, itemNum))
end
-- 设置成功率显示
function GuildAllies_Controller.CalculateAlliesSuccessRatio(myFriendliness, targetFriendliness)
local successRatio = (MaxSuccessRate - MinSuccessRate) * ((myFriendliness / targetFriendliness) - MinFriendlinessRatio) / (MaxFriendlinessRatio - MinFriendlinessRatio) + MinSuccessRate
successRatio = successRatio > 1 and 1 or successRatio
successRatio = successRatio < 0 and 0 or successRatio
return successRatio
end
-- 设置buff显示
function GuildAllies_Controller.SetTextBuff(stateAttrID, image_1, labTxt_1, valueTxt_1, image_2, labTxt_2, valueTxt_2)
local attrInfo = DataSheetManager.GuildAlliesStateAttr:GetDataByStateAttrID(stateAttrID)
if not attrInfo then return end
local showCount = 0
if #attrInfo.AttrPlus_Table > 0 then
for _, v in ipairs (attrInfo.AttrPlus_Table) do
if showCount == 2 then
break
end
if showCount == 0 then
private.SetTextBuff(image_1, labTxt_1, valueTxt_1, v, false)
elseif showCount == 1 then
private.SetTextBuff(image_2, labTxt_2, valueTxt_2, v, false)
end
showCount = showCount + 1
end
end
if #attrInfo.AttrPercentage_Table > 0 then
for _, v in ipairs (attrInfo.AttrPercentage_Table) do
if showCount == 2 then
break
end
if showCount == 0 then
private.SetTextBuff(image_1, labTxt_1, valueTxt_1, v, true)
elseif showCount == 1 then
private.SetTextBuff(image_2, labTxt_2, valueTxt_2, v, true)
end
showCount = showCount + 1
end
end
end
function private.SetTextBuff(image, labTxt, valueTxt, attrTable, isPercent)
if not valueTxt or not attrTable then
return
end
if DataSheetManager.AttrData:GetDataByID(attrTable.AttrType) then
local attrData = DataSheetManager.AttrData:GetDataByID(attrTable.AttrType)
if image then
UIUtils.SetActive(image, not string.isNilOrEmpty(attrData.Icon))
if not string.isNilOrEmpty(attrData.Icon) then
UTL.Item.SetAtlasSprite(image,"UI_Common", attrData.Icon)
end
end
if labTxt then
UIUtils.SetLabelText(labTxt, Const_IDS[attrData.Name])
end
UIUtils.SetLabel(valueTxt, isPercent and private.GetPercentStr(attrTable.AttrNum * 100) or string.format(ValueStr, attrTable.AttrNum))
end
end
function private.GetPercentStr(attrNum)
if not attrNum or attrNum == 0 then return "" end
if attrNum == math.floor(attrNum) then
return string.format(PercentStr, attrNum)
else
return string.format(PercentStr_1, attrNum)
end
end
-- 当前结盟槽位是否解锁
function GuildAllies_Controller.IsUnlockAllyPos(pos)
local guildInfo = MDL.Guild.GetMyGuildInfo()
if guildInfo then
return guildInfo.maxFameLevel >= GuildAllies_Controller.GetUnlockFameLv(pos)
end
return false
end
-- 盟友位和目标位数量上限
function GuildAllies_Controller.OperateLimit()
return OperateLimit
end
function GuildAllies_Controller.GetCurUnlockAllyPosCount()
local unlockCount = 0
for i = 1, OperateLimit do
if GuildAllies_Controller.IsUnlockAllyPos(i) then
unlockCount = unlockCount + 1
else
break
end
end
return unlockCount
end
-- 获取当前盟友位置的名望解锁等级
function GuildAllies_Controller.GetUnlockFameLv(pos)
if pos and pos > 0 then
local unlockFrameData = DataSheetManager.ConstData:GetDataByID("GuildAlliesUnlockParams").IntListValue
if unlockFrameData[pos] then
return unlockFrameData[pos]
end
end
return 1
end
function private.IsUnlockOfficialAffect(dataCfg)
if not dataCfg then return true end
if dataCfg.TriggerType ~= 0 and dataCfg.TriggerParams ~= 0 then
return MDL.Unlock.IsComplete(dataCfg.TriggerType, dataCfg.TriggerParams)
end
return true
end
-- 是否解锁相关活动操作 结盟 宴请 拜访 游说
function GuildAllies_Controller.IsUnlockOpr()
local state = CTL.Activities.GetState(LuaConst.ActivityType.GuildAllies)
if state ~= CTL.Activities.ActivityState.Opening then
CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildAllies_NotInTime"])
return false
end
local guildInfo = MDL.Guild.GetMyGuildInfo()
if not guildInfo then return false end
local changeGuildCount = MDL.GuildAllies.GetChangeGuildCount()
local punishEndTime = 0
for _, data in DataSheetManager.GuildAlliesLimit:GetEnumerator() do
if changeGuildCount >= data.MinTimes and changeGuildCount <= data.MaxTimes then
punishEndTime = guildInfo.joinGuildTime + data.LimitTime
if UTL.Time.GetServerTimestamp() <= punishEndTime then
CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildAllies_InreactionPunishTime"], UTL.Time.FormatTimeBySecondsToHour(punishEndTime - UTL.Time.GetServerTimestamp()))
return false
end
end
end
return true
end
-- 是否具有军团权限操作结盟 解盟 选中目标
function GuildAllies_Controller.HasPermissionByTitle()
return MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle, 17)
end
function GuildAllies_Controller.IsRobotGuild(guildId)
if not guildId then
return false
end
local isSuccess, guildAlliesInit = DataSheetManager.GuildAlliesInit:TryGetDataByID(tonumber(guildId))
return isSuccess
end
function GuildAllies_Controller.SetAllyPosImage(image, allyPos)
if not image or not allyPos then
return
end
if AllyPosImage[allyPos] then
UIUtils.SetActive(image, true)
UTL.Item.SetAtlasSprite(image, "UI_GuildWar", AllyPosImage[allyPos])
else
UIUtils.SetActive(image, false)
end
end
function GuildAllies_Controller.SetRankImage(image, rank)
if not image then
return
end
if AllyRankImage[rank] then
UIUtils.SetImageByAssetBundle(image, AllyRankImage[rank])
else
UIUtils.SetImageByAssetBundle(image, ConstAssetPathConfig.AssetPath57)
end
end
function GuildAllies_Controller.SetAllyPosText(txt, allyPos)
if not txt or not allyPos then
return
end
if not AllyPosImage[allyPos] then
UIUtils.SetActive(txt, true)
UIUtils.SetLabel(txt, allyPos)
else
UIUtils.SetActive(txt, false)
end
end
function GuildAllies_Controller.IsTimeToRefreshRedPoint()
-- 判断时间
local refreshTimer = PersistentData.PlayerData:Get(GuildAllies_Next_RefreshTime_Key,0)
local curTimer = UTL.Time.GetServerTimestamp()
if refreshTimer > 0 and curTimer < refreshTimer then
return false
end
-- 重置刷新时间
local cDateCurTime = UTL.Time.OsDateOriginal("*t", curTimer)
local todayStartTimer = os.time({year=cDateCurTime.year, month=cDateCurTime.month, day=cDateCurTime.day, hour=0,min=0,sec=0})
if refreshTimer == 0 then
if curTimer < todayStartTimer + DailyRefreshHMS then
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, todayStartTimer + DailyRefreshHMS, true)
else
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, todayStartTimer + DailyRefreshHMS + UTL.Time.TotalSecondsOneDay, true)
end
else
local cDateRefreshTime = UTL.Time.OsDateOriginal("*t", refreshTimer)
if cDateRefreshTime.year == cDateCurTime.year and cDateRefreshTime.month == cDateCurTime.month and cDateRefreshTime.day == cDateCurTime.day then
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, todayStartTimer + DailyRefreshHMS + UTL.Time.TotalSecondsOneDay, true)
else
if curTimer < todayStartTimer + DailyRefreshHMS then
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, todayStartTimer + DailyRefreshHMS, true)
else
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, todayStartTimer + DailyRefreshHMS + UTL.Time.TotalSecondsOneDay, true)
end
end
end
return true
end
function GuildAllies_Controller.ResetRpRefreshTime()
PersistentData.PlayerData:Set(GuildAllies_Next_RefreshTime_Key, 0, true)
end
function GuildAllies_Controller.CloseAllFuncPanel()
UIManager.CloseView(Const_UI_Lua.UIEnum.UIFriendshipRank)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesMyAllies)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesLobby)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesBadBlood)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesAlign)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesAlignTips)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildAlliesLobbyTips)
UIManager.CloseView(Const_UI_Lua.UIEnum.UIMessageBoxView)
EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildAlliesMainPanelNew)
EventSystem.Dispatch(EventID.UI_CloseAndRecoverView, Const_UI_Lua.UIEnum.UIGuildAlliesMapView)
end
function GuildAllies_Controller.OnNewDayRefresh()
if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildAlliesMainPanelNew) then
if MDL.GuildAllies.GetCurShowPowerID() ~= 0 then
MDL.GuildAllies.RequestEnterGuildAllies()
MDL.GuildAllies.RequestGuildAllies(MDL.GuildAllies.GetCurShowPowerID())
end
end
end
--这里是合纵连横玩法说明 需要拼接排名属性 时间等参数
function GuildAllies_Controller.OpenGuildAlliesDesc()
local desc, timeStr = UTL.Time.GetDateDescAndTime({[1] = 2})
local timeStr1 = UTL.Time.GetDiffLocalStrById(1)
local desc2, timeStr2 = UTL.Time.GetDateDescAndTime({{StartTime = 1611,EndTime = 1612}})
local resultCfg1 = DataSheetManager.GuildAlliesData:GetDataByID(1)
local resultCfg2 = DataSheetManager.GuildAlliesData:GetDataByID(2)
local resultCfg3 = DataSheetManager.GuildAlliesData:GetDataByID(3)
local name1 = UIUtils.GetLocalizedTxt(Const_IDS[resultCfg1.AlliesName])
local name2 = UIUtils.GetLocalizedTxt(Const_IDS[resultCfg2.AlliesName])
local name3 = UIUtils.GetLocalizedTxt(Const_IDS[resultCfg3.AlliesName])
local attr1 = private.GetStateAttrById(101)
local attr2 = private.GetStateAttrById(102)
local attr3 = private.GetStateAttrById(103)
local attr4 = private.GetStateAttrById(104)
local attr5 = private.GetStateAttrById(201)
local attr6 = private.GetStateAttrById(202)
local attr7 = private.GetStateAttrById(203)
local attr8 = private.GetStateAttrById(204)
local attr9 = private.GetStateAttrById(301)
local attr10 = private.GetStateAttrById(302)
local attr11 = private.GetStateAttrById(303)
local attr12 = private.GetStateAttrById(304)
local _, timeCDStr = UTL.Time.GetDateDescAndTime({[1] = 1})
UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GuildAllies, params = {timeStr1, name1, attr1, attr2, attr3, attr4, name2, attr5, attr6, attr7, attr8,
name3, attr9, attr10, attr11, attr12, desc..timeStr, desc2..timeStr2, timeCDStr}})
end
function private.GetStateAttrById(stateAttrID)
local attrInfo = DataSheetManager.GuildAlliesStateAttr:GetDataByStateAttrID(stateAttrID)
local str = nil
for _, v in ipairs (attrInfo.AttrPercentage_Table) do
local attrData = DataSheetManager.AttrData:GetDataByID(v.AttrType)
local attrName = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name])
local value = string.format(ValueStr, v.AttrMax)--private.GetPercentStr(v.AttrNum * 100)
if str then
str = str.." "..attrName..value
else
str = attrName..value
end
end
return str
end
--检查首席盟友
function GuildAllies_Controller.CheckHasFirstSeat()
local firstData = MDL.GuildAllies.GetFirstSeat()
if firstData ~= nil then
local guildAllies = DataSheetManager.GuildAlliesData:GetDataByID(firstData.powerID)
CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_ERRORCODE_1456_InfoCode_OnlyOneChiefAlly"], UIUtils.GetLocalizedTxt(Const_IDS[guildAllies.AlliesName])))
return true
end
return false
end
function GuildAllies_Controller.PopGuildAlliesBox(strategyCfg, requestFunc, paraArr)
UIManager.OpenView(
Const_UI_Lua.UIEnum.UIGuildAlliesUseItemPop,
{
TitleIDS = Const_IDS.IDS_GuildAllies_FunctionName,
TipIDS = Const_IDS.IDS_GuildAllies_ChooseInvitationNum,
BtnIDS = Const_IDS.IDS_Guild_DonateBtn,
strategyCfg = strategyCfg,
requestFunc = requestFunc,
requestParams = paraArr
},
Const_UI_Lua.UIEnum.UIUseItemPop
)
end
-- 计算结盟或离间最大可用次数
function GuildAllies_Controller.GetAlliesMaxCount(strategyCfg)
local minCount = 0
if strategyCfg.Cost_Table[1] and strategyCfg.Cost_Table[2] then
local count1 = math.floor(MDL.Bag.GetItemCount(strategyCfg.Cost_Table[1].CostItemID) / strategyCfg.Cost_Table[1].CostItemNum)
local count2 = math.floor(MDL.Currency.GetMoneyCount(strategyCfg.Cost_Table[2].CostItemID) / strategyCfg.Cost_Table[2].CostItemNum)
minCount = math.max(minCount, math.min(count1, count2))
elseif strategyCfg.Cost_Table[1] then
minCount = math.floor(MDL.Bag.GetItemCount(strategyCfg.Cost_Table[1].CostItemID) / strategyCfg.Cost_Table[1].CostItemNum)
end
return minCount
end
return GuildAllies_Controller