local FairPlay_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local fairplay_point_pb = require('Proto.fairplay_point_pb') local fairplay_common_pb = require('Proto.fairplay_common_pb') local fairplay_tvt_pb = require 'Proto.fairplay_tvt_pb' local fairplay_pb = require 'Proto.fairplay_pb' FairPlay_Model.RewardState = { Default = fairplay_point_pb.FPRDefault, WaitForGet = fairplay_point_pb.FPRWaitForGet, AlreadyGot = fairplay_point_pb.FPRAlreadyGot, } FairPlay_Model.SeasonState = { SeasonNotOpen = fairplay_common_pb.SeasonNotOpen, SeasonOpening = fairplay_common_pb.SeasonOpening, SeasonClose = fairplay_common_pb.SeasonClose, } FairPlay_Model.FairPlayState = { UnKnow = fairplay_common_pb.UnKnow, -- 为止 AllSid = fairplay_common_pb.AllSid, -- 全大区 Local = fairplay_common_pb.Local, -- 本服 WarZone = fairplay_common_pb.WarZone, -- 战区 } FairPlay_Model.FairPlayType = { Solo = 0, -- 1V1 Boss = 2, -- boss 挑战 TVT = 1, -- 3V3 FourCountryWar = 3, --四军之战 } FairPlay_Model.BanPickHeroOptType = { Roll = 1, --扔骰子 BanHero = 2, --禁用英雄 PickHero = 3, --选择英雄 Confirm = 4, --确认选择 ChangeHeroOrder = 5, --修改武将顺序 } FairPlay_Model.BanPickStageEnum = { Begin = 0, --扔骰子 AfterRoll = 1, --扔骰子(服务器初始化bp信息) BanPick = 2, --bp阶段选择英雄 ModifyHeroOrder = 3, --修改武将顺序阶段 End = 4, --准备进入战斗 } function FairPlay_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageFairPlayGetReward, private.FairPlayGetRewardResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushFairPlayPointInfo, private.FairPlayInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushTVTSeasonChanged, private.TVTSeasonInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushBossChallengeSeasonChanged, private.BossChallengeSeasonInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushSoloSeasonChanged, private.SyncSoloSeasonInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageFairGetFixAttr,private.FairGetFixAttrResp) --赛季更新服务器主动推送信息 NetManager.RegisterMsgCB(MessageEnums.MessageG2CFairPlayInfo, private.SyncSeasonInfoPush) --一键领取的协议 NetManager.RegisterMsgCB(MessageEnums.MessageFairPlayHistoryDanReward, private.SyncRewardResp) NetManager.RegisterMsgCB(MessageEnums.MessageFairPlayHistoryFamousInfo, private.HistoryFamousResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CBpRoomInfo, private.SyncBpRoomInfoPush) NetManager.RegisterMsgCB(MessageEnums.MessageBanPickHeroOpt, nil) private.fairPlayPoint = 0 private.fairPlayReward = {} private.bpRoomInfo = {} private.famousFameParams = { activityId = nil, titleIDS = nil } end function FairPlay_Model.PushFairPlayScore(info) if info.activityId == LuaConst.ActivityType.SyncSolo then MDL.SyncSolo.SetSyncSoloEloPoint(info.EloScore) elseif info.activityId == LuaConst.ActivityType.TVT then MDL.SyncTeamPVP.SetEloScore(info.EloScore) end end function FairPlay_Model.FairPlayRewardReq(activityId) local msg = fairplay_tvt_pb.FairPlayHistoryDanRewardReq() msg.activityId = activityId NetManager.SendMessage(MessageEnums.MessageFairPlayHistoryDanReward,msg) end function private.SyncSeasonInfoPush(msgResp) if msgResp.activityId == LuaConst.ActivityType.SyncSolo then MDL.SyncSolo.SyncSoloPlayInfoPush(msgResp) elseif msgResp.activityId == LuaConst.ActivityType.TVT then MDL.SyncTeamPVP.SyncTeamPVPPlayInfoPush(msgResp) end end function private.SyncRewardResp(msgResp) if msgResp.activityId == LuaConst.ActivityType.SyncSolo then MDL.SyncSolo.SyncSoloRewardResp(msgResp) elseif msgResp.activityId == LuaConst.ActivityType.TVT then MDL.SyncTeamPVP.SyncTeamPVPRewardResp(msgResp) end end function FairPlay_Model.GetFairPlayPoint() return private.fairPlayPoint end function FairPlay_Model.GetFairPlayRewardState() return private.fairPlayReward end function FairPlay_Model.UpdateFairPlayInfo(info) private.fairPlayPoint = info.point for i, v in ipairs(info.state) do private.fairPlayReward[i] = v end EventSystem.Dispatch(EventID.UI_FairPlay_FairPlayInfoRefresh) end function FairPlay_Model.FairPlayGetRewardReq(index) local msg = fairplay_point_pb.FairPlayGetRewardReq() msg.rewardIndex = index NetManager.SendMessage(MessageEnums.MessageFairPlayGetReward, msg) end function private.FairPlayGetRewardResp(msgResp) if msgResp.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_FairPlay_RewardChestClaim) end end function FairPlay_Model.FairGetFixAttrReq(type) local msg = fairplay_pb.FairGetFixAttrReq() msg.type = type NetManager.SendMessage(MessageEnums.MessageFairGetFixAttr, msg) end --获取修正属性信息 function private.FairGetFixAttrResp(msgResp) if msgResp.Resp.Code == 0 then if private.fixAttrList == nil then private.fixAttrList = {} end private.fixAttrList[msgResp.type] = msgResp.FixAttrList EventSystem.Dispatch(EventID.UI_FairPlay_RefreshHeroFixedInfo) end end function FairPlay_Model.GetFixAttrByTypeAndHeroId(type,heroId) local _heroId, isAwaken = CTL.HeroAwaken.DecodeHeroId(heroId) if private.fixAttrList and private.fixAttrList[type] then local result = private.fixAttrList[type] for i = 1, #result do if result[i].heroId == _heroId and result[i].heroAwaken == isAwaken then return result[i].hpFix, result[i].atkFix, result[i].defFix end end end return nil end function private.FairPlayInfoPush(msg) FairPlay_Model.UpdateFairPlayInfo(msg.info) end function private.TVTSeasonInfoPush(msg) MDL.SyncTeamPVP.UpdateTVTSeasonInfo(msg.info) end function private.SyncSoloSeasonInfoPush(msg) MDL.SyncSolo.UpdateSyncSoloSeasonInfo(msg.info) end function private.BossChallengeSeasonInfoPush(msg) MDL.BossChallenge.UpdateBossChallengeSeasonInfo(msg.info) end function FairPlay_Model.SetFamousFameParams(activityId, titleIDS) private.famousFameParams.activityId = activityId private.famousFameParams.titleIDS = titleIDS end function FairPlay_Model.GetFamousFameParams() return private.famousFameParams.activityId, private.famousFameParams.titleIDS end function FairPlay_Model.HistoryFamousRequest(activityId) local msg = fairplay_tvt_pb.FairPlayHistoryFamousInfoReq() msg.activityId = activityId NetManager.SendMessage(MessageEnums.MessageFairPlayHistoryFamousInfo, msg) end function private.HistoryFamousResp(msg) EventSystem.Dispatch(EventID.UI_Sync_HallOfFameRefresh, msg) end function private.SyncBpRoomInfoPush(msg) logging.log(LTAG.LOG,"SyncBpRoomInfoPush ", msg) if not private.bpRoomInfo[msg.activityId] then private.bpRoomInfo[msg.activityId] = {} end private.bpRoomInfo[msg.activityId] = msg if msg.activityId == LuaConst.ActivityType.SyncSolo then if msg.curStage == FairPlay_Model.BanPickStageEnum.Begin or msg.curStage == FairPlay_Model.BanPickStageEnum.AfterRoll then CTL.SyncSolo.OpenRollDiceUI() else CTL.SyncSolo.OpenBPSelectUI() end end EventSystem.Dispatch(EventID.UI_SyncSolo_NoticeBPInfo) end function FairPlay_Model.GetBpRoomInfo(activityId) return private.bpRoomInfo[activityId] end function FairPlay_Model.BanPickHeroOptReq(activityId, optType, acid, heroIdList) local msg = fairplay_pb.BanPickHeroOptReq() msg.activityId = activityId msg.optType = optType msg.acid = acid if heroIdList then for _, heroId in ipairs(heroIdList) do local id, isAwaken = CTL.HeroAwaken.DecodeHeroId(heroId) msg.heroId:append(id) msg.heroAwaken:append(isAwaken) end end NetManager.SendMessage(MessageEnums.MessageBanPickHeroOpt, msg) end return FairPlay_Model