local HonorSignet_Model = {} local private = {} local EventSystem = require 'Event/EventSystem' local honor_signet_handle_pb = require 'Proto.honor_signet_handle_pb' local MaxEquipNum = DataSheetManager.ConstData:GetDataByID("HonorSignetMaxEquipNum").IntValue HonorSignet_Model.OpType = { Active = honor_signet_handle_pb.ACTIVITE, --激活 Wear = honor_signet_handle_pb.WEAR, --佩戴 Disboard = honor_signet_handle_pb.DISBOARD, --卸下 } function HonorSignet_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageHonorSignet, private.HonorSignetResp) private.wearInfo = {} private.activeInfo = {} private.sortedList = {} end function HonorSignet_Model.GetMaxEquipNum() return MaxEquipNum end function HonorSignet_Model.GetActiveInfo(id) return private.activeInfo[id] end function HonorSignet_Model.GetActiveIdDict() return private.activeInfo end function HonorSignet_Model.GetEquipList() return private.wearInfo end function HonorSignet_Model.GetEquipNum() return #private.wearInfo end function HonorSignet_Model.GetEquipActiveTimeList() local list = {} for i, v in ipairs(private.wearInfo) do table.insert(list, private.activeInfo[v]) end return list end function HonorSignet_Model.GetSortedHonorSignetList() private.sortedList = {} for i, v in ipairs(private.wearInfo) do table.insert(private.sortedList, DataSheetManager.AchievementHonorSignet:GetDataByID(v)) end table.sort(private.sortedList, private.SortById) local tempHasList = {} local tempLockList = {} for i, v in DataSheetManager.AchievementHonorSignet:GetEnumerator() do local id = v.ID if not CTL.HonorSignet.IsEquip(id) then if CTL.HonorSignet.IsActive(id) then table.insert(tempHasList, v) else if CTL.HonorSignet.IsCanUnlock(id) then table.insert(private.sortedList, v) else table.insert(tempLockList, v) end end end end table.sort(tempHasList, private.SortById) table.sort(tempLockList, private.SortById) for i, v in ipairs(tempHasList) do table.insert(private.sortedList, v) end for i, v in ipairs(tempLockList) do table.insert(private.sortedList, v) end return private.sortedList end function private.SortById(dataA, dataB) if dataA.HonorSignetQuality == dataB.HonorSignetQuality then return dataA.ID < dataB.ID end return dataA.HonorSignetQuality > dataB.HonorSignetQuality end function HonorSignet_Model.SetInfo(info) private.activeInfo = {} for i, v in ipairs(info.activatedInfo) do if v.activatedId > 0 then private.activeInfo[v.activatedId] = v.timestamp end end private.wearInfo = {} for i, v in ipairs(info.wearId) do private.wearInfo[i] = v end EventSystem.Dispatch(EventID.UI_HonorSignet_InfoRefresh) end function HonorSignet_Model.HonorSignetReq(opType, signetId) local msg = honor_signet_handle_pb.HonorSignetReq() msg.opType = opType msg.signetId = signetId NetManager.SendMessage(MessageEnums.MessageHonorSignet, msg) end function private.HonorSignetResp(msgResp) if msgResp.Resp.Code == 0 then if msgResp.opType == HonorSignet_Model.OpType.Active then EventSystem.Dispatch(EventID.UI_HonorSignet_ActiveSuccess, msgResp.signetId) CTL.Tips.AddTipsMsg(Const_IDS.IDS_MagicWeapon_SmallActivation) elseif msgResp.opType == HonorSignet_Model.OpType.Disboard then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HonorSignet_Hint_5) elseif msgResp.opType == HonorSignet_Model.OpType.Wear then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HonorSignet_Hint_8) end end end return HonorSignet_Model