------ 彩金将-抽奖 local SuperGoldLottery_Model = {} local private = {} local EventSystem = require("Event/EventSystem") local activity_capsule_opt_pb = require('Proto/activity_capsule_opt_pb') --奖池抽取类型 SuperGoldLottery_Model.LimitType = { Limit = 1, --抽取后不放回 Unlimited = 2, --抽取后放回 } function SuperGoldLottery_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageActivityCapsuleSample, private.ActivityCapsuleSampleResp) -- 活动卡池抽卡 private.turnTableInfo = {} end function SuperGoldLottery_Model.OnShutdown() end -- 活动卡池抽卡 req -- drawLayer 抽取层数; drawNums 抽取次数 function SuperGoldLottery_Model.ActivityCapsuleSampleReq(activityId,drawLayer,drawNums) local msg = activity_capsule_opt_pb.ActivityCapsuleSampleReq() msg.activityId = activityId msg.drawLayer = drawLayer msg.drawNums = drawNums private.delayRefershUI = true --是否要延迟刷新UI MDL.Reward.SetCloseNotExpTipShow(true) NetManager.SendMessage(MessageEnums.MessageActivityCapsuleSample, msg) end --活动卡池抽卡 resp function private.ActivityCapsuleSampleResp(msgResp) if msgResp.Resp.Code == 0 then logging.log(LTAG.LOG,"ActivityCapsuleSampleResp",msgResp) private.cardReward = msgResp.cardReward --抽卡奖励 EventSystem.Dispatch(EventID.UI_SuperGoldLottery_RefreshRedPoint) --刷新红点 EventSystem.Dispatch(EventID.UI_SuperGoldLottery_PlayAnimation,private.cardReward) --播放抽奖动画 private.delayRefershUI = false end MDL.Reward.SetCloseNotExpTipShow(false) end --同步抽奖信息 function SuperGoldLottery_Model.SynActivityInfo(capsuleInfo) logging.log(LTAG.LOG,"SuperGoldLottery_Model.SynActivityInfo",capsuleInfo) --构造抽奖信息 private.capsuleInfo = {} for i,v in ipairs(capsuleInfo) do private.capsuleInfo[v.activityId] = v --抽奖信息 end EventSystem.Dispatch(EventID.UI_SuperGoldLottery_RefreshRedPoint) if next(private.capsuleInfo) then if not private.delayRefershUI then EventSystem.Dispatch(EventID.UI_SuperGoldLottery_RefreshUI) --刷新UI end end end --当前奖池ID function SuperGoldLottery_Model.GetCurrentTurnTableID(activityId) local turnTableID if private.capsuleInfo and private.capsuleInfo[activityId] then turnTableID = private.capsuleInfo[activityId].rewardIndex end if turnTableID and turnTableID > 0 then return turnTableID end local firstLayer = SuperGoldLottery_Model.GetTurnTableInfo(activityId)[1] turnTableID = firstLayer.TurnTableID return turnTableID end --获取当前层已经抽过的奖品 function SuperGoldLottery_Model.GetHasGetRewardInfoByLayer(activityId,layer) if private.capsuleInfo and private.capsuleInfo[activityId] and private.capsuleInfo[activityId].capsuleHistory then for i,v in ipairs(private.capsuleInfo[activityId].capsuleHistory) do if v.drawLayer == layer then return v.drawRewardInfo end end end return nil end function SuperGoldLottery_Model.GetHeroType(activityId) local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) return heroType end --获取奖池数据 function SuperGoldLottery_Model.GetTurnTableInfo(activityId) if not private.turnTableInfo[activityId] then private.turnTableInfo[activityId] = {} for i,v in DataSheetManager.SuperGoldTurntable:GetDataByHeroType_TurnTableID(SuperGoldLottery_Model.GetHeroType(activityId)) do table.insert(private.turnTableInfo[activityId],v) end end return private.turnTableInfo[activityId] end --根据奖池Id 获取数据 function SuperGoldLottery_Model.GetRewardByTurnTableID(id) local result = {} for i,v in DataSheetManager.SuperGoldTurntableReward:GetDataByTurnTableID_RewardID(id) do table.insert(result,v) end return result end --根据奖池Id 获取该奖池的总权重 function SuperGoldLottery_Model.GetRewardTotalWeightByTurnTableID(id) local weight = -1 local array = SuperGoldLottery_Model.GetRewardByTurnTableID(id) if array then for i,v in ipairs(array) do weight = weight + v.Weight end return weight end return -1 end return SuperGoldLottery_Model