local SuperGoldBoss_Model = {} local private = {} local EventSystem = require 'Event/EventSystem' local activity_super_gold_opt_pb = require('Proto.activity_super_gold_opt_pb') local fuben_common = require('Proto/fuben_pb') local EnergyMaxBuyCount SuperGoldBoss_Model.BossRankName = { TotalScoreRank = DataSheetManager.SuperGoldBossRankData:GetDataByID(1).Enum, --累积积分排行榜 MaxDamageRank = DataSheetManager.SuperGoldBossRankData:GetDataByID(2).Enum, --单次最高伤害排行榜 } function SuperGoldBoss_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageSuperGoldTrialOpen, private.SuperGoldTrialOpenResp) NetManager.RegisterMsgCB(MessageEnums.MessageSuperGoldTrialTimeReward, private.SuperGoldTrialTimeRewardResp) NetManager.RegisterMsgCB(MessageEnums.MessageSuperGoldTrialSweep, private.SuperGoldTrialSweepResp) NetManager.RegisterMsgCB(MessageEnums.MessageSuperGoldTrialResultOpt, private.SuperGoldTrialResultOptResp) NetManager.RegisterMsgCB(MessageEnums.MessageSuperGoldTrialEnergyBuy, private.SuperGoldTrialEnergyBuyResp) EventSystem.Regist(EventID.UI_SuperGoldBoss_CloseBossBattleInfoViewDmgDelta, private.OnCloseBossBattleInfoViewDmgDelta) EventSystem.Regist(EventID.Level_InitLevel, private.OnInitLevel) private.InitMaxEnergyData() private.participateTimes = {} private.myTotalScoreRank = {} private.myMaxScoreRank = {} private.myMaxDamageRank = {} private.maxScore = {} private.todayScore = {} private.alreadyGet = {} private.maxDifficulty = {} private.energyBuyTimes = {} private.tempDifficult = {} private.recommendDifficulty = {} end function SuperGoldBoss_Model.GetTodayScore(activityId) return private.todayScore[activityId] or 0 end function SuperGoldBoss_Model.GetMaxScore(activityId) return private.maxScore[activityId] or 0 end function SuperGoldBoss_Model.GetMyRankByName(activityId, rankName) if rankName == SuperGoldBoss_Model.BossRankName.TotalScoreRank then return private.myTotalScoreRank[activityId] or 0 elseif rankName == SuperGoldBoss_Model.BossRankName.MaxDamageRank then return private.myMaxDamageRank[activityId] or 0 end end function SuperGoldBoss_Model.GetParticipateTimes(activityId) return private.participateTimes[activityId] or 0 end function SuperGoldBoss_Model.GetTimesRewardList(activityId) return private.alreadyGet[activityId] end function SuperGoldBoss_Model.GetDefaultDifficult(activityId, gsGroupId) if not private.tempDifficult[activityId] then return SuperGoldBoss_Model.GetRecommendDifficult(activityId, gsGroupId) else return private.tempDifficult[activityId] end end function SuperGoldBoss_Model.GetRecommendDifficult(activityId, gsGroupId) if private.recommendDifficulty[activityId] and private.recommendDifficulty[activityId] >= 0 then return math.max(private.maxDifficulty[activityId], private.recommendDifficulty[activityId], 1) else return SuperGoldBoss_Model.GetRecommendGsDifficult(gsGroupId) end end function SuperGoldBoss_Model.GetRecommendGsDifficult(gsGroupId) local teamGs = MDL.Player.GetLineUpGs() local recommendDifficulty = 1 for i, v in DataSheetManager.SuperGoldBossGS:GetDataByGSGroupID_BossLevel(gsGroupId) do if teamGs >= v.RecommendGS then recommendDifficulty = v.BossLevel else break end end return recommendDifficulty end function SuperGoldBoss_Model.SaveTempDifficult(activityId, difficult) private.tempDifficult[activityId] = difficult end function SuperGoldBoss_Model.GetAddHeroAddLevel(addHeroId) if not MDL.HeroSelect.IsHasHero(addHeroId) then return 0 end local heroBreakLevel = MDL.HeroStar.GetHeroStarLevel(addHeroId) for i, v in DataSheetManager.SuperGoldBossHero:GetDataByHeroID_LevelID(addHeroId) do if heroBreakLevel < v.HeroStar then return i - 1 end end return DataSheetManager.SuperGoldBossHero:GetDataLengthByHeroID_LevelID(addHeroId) end --满足排名的时候还需要满足最低积分的需求才可以领取相应的奖励 function SuperGoldBoss_Model.GetCurrentIndexOfRewardRank(activityId, rankName) local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(heroType) local rankGroupId = bossData.RankRewardGroup local sheetFunc local myScore local rank local times if rankName == SuperGoldBoss_Model.BossRankName.MaxDamageRank then sheetFunc = DataSheetManager.SuperGoldBossDamageRank[rankGroupId] myScore = private.maxScore[activityId] rank = private.myMaxScoreRank[activityId] elseif rankName == SuperGoldBoss_Model.BossRankName.TotalScoreRank then sheetFunc = DataSheetManager.SuperGoldBossTotalRank[rankGroupId] myScore = private.todayScore[activityId] rank = private.myTotalScoreRank[activityId] times = private.participateTimes[activityId] end --排名和积分找出第一个没办法同时满足的区间的上一个index return MDL.GoldenHeroBoss.CalculateRewardRank(rank, sheetFunc, myScore, times) end function SuperGoldBoss_Model.CalculateTotalPointRewardRank(activityId, rank, score, times) local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(heroType) return MDL.GoldenHeroBoss.CalculateRewardRank(rank, DataSheetManager.SuperGoldBossTotalRank[bossData.RankRewardGroup], score, times) end function private.SetSuperGoldInfo(activityId, superGoldInfo) private.participateTimes[activityId] = superGoldInfo.times private.myTotalScoreRank[activityId] = superGoldInfo.myDailyRank private.myMaxScoreRank[activityId] = superGoldInfo.myRank private.maxScore[activityId] = superGoldInfo.maxScore private.todayScore[activityId] = superGoldInfo.todayScore private.maxDifficulty[activityId] = superGoldInfo.maxDifficulty private.energyBuyTimes[activityId] = superGoldInfo.energyBuyTimes private.alreadyGet[activityId] = superGoldInfo.alreadyGet private.recommendDifficulty[activityId] = superGoldInfo.firstDifficultyId EventSystem.Dispatch(EventID.UI_SuperGoldBoss_InfoRefresh) end --region ******体力相关****** function SuperGoldBoss_Model.GetEnergyBuyCount(activityId) return private.energyBuyTimes[activityId] or 0 end function SuperGoldBoss_Model.SetEnergyBuyCount(activityId, count) private.energyBuyTimes[activityId] = count end function SuperGoldBoss_Model.GetEnergyMaxCount() return EnergyMaxBuyCount end function SuperGoldBoss_Model.OpenEnergyBuyView(activityId, itemId) local maxBuyCount = SuperGoldBoss_Model.GetEnergyMaxCount() local energyBuyCount = SuperGoldBoss_Model.GetEnergyBuyCount(activityId) if maxBuyCount - energyBuyCount <= 0 then return false end if not itemId then local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(heroType) itemId = bossData.EnergyItem end local energyBuyData = DataSheetManager.SuperGoldBossEnergyBuy:GetDataByID(energyBuyCount + 1) if CTL.Currency.IsDragonJadeUsedInJapan(energyBuyData.CurrencyID) then --日本消耗龙玉特殊弹窗 UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldEnergyBuy, { param = { activityId = activityId }, itemId = itemId }, "GoldenHero/GoldenHeroStore/UIGoldenHeroStoreExchange_JP") else UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldEnergyBuy, { param = { activityId = activityId }, itemId = itemId }, Const_UI_Lua.UIEnum.UIGoldenHeroStoreExchange) end return true end function private.InitMaxEnergyData() for k, v in DataSheetManager.SuperGoldBossEnergyBuy:GetEnumerator() do EnergyMaxBuyCount = v.ID end end --endregion --region ******协议相关****** function SuperGoldBoss_Model.EnterSuperGoldBoss(activityId, difficultId, bossLevelId) if CTL.TeamMatch.IsCanGoOtherScene(LuaConst.LevelType.GoldHeroTrail) then local msg = fuben_common.EnterFubenReq() msg.id = 0 msg.superGoldTrial.activityId = activityId msg.superGoldTrial.levelId = difficultId msg.mapType = LuaConst.LevelType.GoldHeroTrail msg.mapID = bossLevelId NetManager.SendMessage(MessageEnums.MessageEnterFuben, msg) CTL.SuperGoldBoss.SaveTempData(activityId, difficultId, bossLevelId) CTL.SuperGoldMain.SetIsOpenedActivity() end end function SuperGoldBoss_Model.SuperGoldTrialOpenReq(activityId, difficultyId) local msg = activity_super_gold_opt_pb.SuperGoldTrialOpenReq() msg.activityId = activityId msg.difficultyId = difficultyId NetManager.SendMessage(MessageEnums.MessageSuperGoldTrialOpen, msg) end function private.SuperGoldTrialOpenResp(msgResp) if msgResp.Resp.Code == 0 then private.SetSuperGoldInfo(msgResp.activityId, msgResp.trialInfo) end end function SuperGoldBoss_Model.SuperGoldTrialTimeRewardReq(activityId, rewardId) local msg = activity_super_gold_opt_pb.SuperGoldTrialTimeRewardReq() msg.activityId = activityId msg.rewardId = rewardId NetManager.SendMessage(MessageEnums.MessageSuperGoldTrialTimeReward, msg) end function private.SuperGoldTrialTimeRewardResp(msgResp) if msgResp.Resp.Code == 0 then private.SetSuperGoldInfo(msgResp.activityId, msgResp.trialInfo) end end function SuperGoldBoss_Model.SuperGoldTrialResultOptReq(activityId, opt) local msg = activity_super_gold_opt_pb.SuperGoldTrialResultOptReq() msg.activityId = activityId msg.opt = opt NetManager.SendMessage(MessageEnums.MessageSuperGoldTrialResultOpt, msg) end function private.SuperGoldTrialResultOptResp(msgResp) if msgResp.Resp.Code == 0 then if msgResp.opt then private.SetSuperGoldInfo(msgResp.activityId, msgResp.trialInfo) end EventSystem.Dispatch(EventID.UI_SuperGoldBoss_SummaryOpt, msgResp.activityId) --处理奖励 end end function SuperGoldBoss_Model.SuperGoldTrialSweepReq(activityId) local msg = activity_super_gold_opt_pb.SuperGoldTrialSweepReq() msg.activityId = activityId NetManager.SendMessage(MessageEnums.MessageSuperGoldTrialSweep, msg) end function private.SuperGoldTrialSweepResp(msgResp) if msgResp.Resp.Code == 0 then private.SetSuperGoldInfo(msgResp.activityId, msgResp.trialInfo) UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldBossSweepSuccess, {activityId = msgResp.activityId, result = msgResp.sweepResult}) end end function SuperGoldBoss_Model.SuperGoldTrialEnergyBuyReq(activityId, times) local msg = activity_super_gold_opt_pb.SuperGoldTrialEnergyBuyReq() msg.activityId = activityId msg.times = times NetManager.SendMessage(MessageEnums.MessageSuperGoldTrialEnergyBuy, msg) end function private.SuperGoldTrialEnergyBuyResp(msgResp) if msgResp.Resp.Code == 0 then private.energyBuyTimes[msgResp.activityId] = msgResp.energyBuyTimes EventSystem.Dispatch(EventID.UI_SuperGoldBoss_InfoRefresh) end end function private.OnCloseBossBattleInfoViewDmgDelta(damageDelta) private.lastBossDamageDelta = damageDelta end function SuperGoldBoss_Model.GetLastBossDamageDelta() return private.lastBossDamageDelta end function private.OnInitLevel() private.lastBossDamageDelta = nil end --endregion ******协议相关****** return SuperGoldBoss_Model