| | |
| | | import ShareDefine |
| | | import DataRecordPack |
| | | import PlayerCompensation |
| | | import PlayerDBGSEvent |
| | | import PlayerBillboard |
| | | import IpyGameDataPY |
| | | import GameWorld |
| | | |
| | | BillboardType = ShareDefine.Def_BT_BossTrialSubmit |
| | | import CrossRealmMsg |
| | | import CrossActionControl |
| | | import CrossBillboard |
| | | import PlayerFamily |
| | | import PyDataManager |
| | | import GameXiangong |
| | | import GameWorship |
| | | |
| | | def OnActStart(actNum): |
| | | ## 活动开启 |
| | | PlayerBillboard.ClearBillboardByIndex(BillboardType) |
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum, 0) |
| | | PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_BossTrialSubmit) |
| | | PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_BossTrialSubmitFamily) |
| | | |
| | | familyActionMgr = GameWorld.GetFamilyActionManager() |
| | | familyManager = GameWorld.GetFamilyManager() |
| | | for i in range(0, familyManager.GetCount()): |
| | | family = familyManager.GetAt(i) |
| | | familyID = family.GetID() |
| | | familyActionMgr.DelFamilyAction(familyID, ShareDefine.Def_ActionType_BossTrialSubmit) |
| | | |
| | | return |
| | | |
| | | def OnActEnd(actNum, ipyData, dayIndex): |
| | | ## 活动结束 |
| | | cfgID = ipyData.GetCfgID() if ipyData else 0 |
| | | # 发放排行奖励 |
| | | GameWorld.Log("=== boss历练活动结束!发放榜单奖励! === actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex)) |
| | | if not cfgID: |
| | | return |
| | | billBoard = GameWorld.GetBillboard().FindBillboard(BillboardType) |
| | | if not billBoard: |
| | | return |
| | | mailKey = ipyData.GetMailKey() |
| | | templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex) |
| | | if not templateID: |
| | | return |
| | | tempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID) |
| | | if not tempIpyDataList: |
| | | return |
| | | GameWorld.Log("=== boss历练活动结束! === actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex)) |
| | | |
| | | rankAwardDict = {} |
| | | for tempIpyData in tempIpyDataList: |
| | | rankAwardDict[tempIpyData.GetRank()] = tempIpyData.GetAwardItemList() |
| | | |
| | | GameWorld.Log(" templateID=%s,rankAwardDict=%s" % (templateID, rankAwardDict)) |
| | | billBoard.Sort() |
| | | for index in xrange(billBoard.GetCount()): |
| | | billBoardData = billBoard.At(index) |
| | | if not billBoardData: |
| | | continue |
| | | |
| | | rank = index + 1 |
| | | |
| | | awardItemList = GameWorld.GetOrderValueByDict(rankAwardDict, rank, False) |
| | | if not awardItemList: |
| | | break |
| | | |
| | | playerID = billBoardData.GetID() |
| | | name2 = billBoardData.GetName2() |
| | | cmpValue = billBoardData.GetCmpValue() |
| | | |
| | | GameWorld.Log(" 发放boss历练榜单奖励: rank=%s,playerID=%s,cmpValue=%s,awardItemList=%s, %s" |
| | | % (rank, playerID, cmpValue, awardItemList, name2)) |
| | | |
| | | PlayerCompensation.SendMailByKey(mailKey, [playerID], awardItemList, [rank]) |
| | | |
| | | DataRecordPack.DR_BillboardData(BillboardType, "BossTrial", {"actNum":actNum, "cfgID":cfgID, "dayIndex":dayIndex, "templateID":templateID}) |
| | | PlayerBillboard.CopyBillboard(ShareDefine.Def_BT_BossTrialSubmitBak, BillboardType) |
| | | PlayerBillboard.ClearBillboardByIndex(BillboardType) |
| | | __OnEndAward(actNum, ipyData, dayIndex) # 兼容活动没有配置参与时间段的在活动结束补触发结算奖励 |
| | | |
| | | PlayerBillboard.CopyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamilyBak, ShareDefine.Def_BT_BossTrialSubmitFamily) |
| | | PlayerBillboard.CopyBillboard(ShareDefine.Def_BT_BossTrialSubmitBak, ShareDefine.Def_BT_BossTrialSubmit) |
| | | GameWorld.Log("=================================================================================") |
| | | return |
| | | |
| | | def OnActInStateRefresh(actNum, ipyData, dayIndex): |
| | | ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等 |
| | | if not ipyData: |
| | | return |
| | | cfgID = ipyData.GetCfgID() |
| | | templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex) |
| | | familyTemplateID = GameWorld.GetTemplateIDByList(ipyData.GetFamilyTemplateIDList(), dayIndex) |
| | | |
| | | billboardMgr = PlayerBillboard.GetBillboardMgr() |
| | | if templateID: |
| | | orderRuleList = GetOrderRuleList(templateID) |
| | | billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmit) |
| | | billboardObj.SetOrderRuleList(orderRuleList) |
| | | |
| | | if familyTemplateID: |
| | | orderRuleList = GetOrderRuleList(familyTemplateID) |
| | | billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_BossTrialSubmitFamily) |
| | | billboardObj.SetOrderRuleList(orderRuleList) |
| | | return |
| | | |
| | | def OnActJoinEnd(actNum, ipyData, dayIndex): |
| | | ## 活动参与结束 |
| | | __OnEndAward(actNum, ipyData, dayIndex) |
| | | return |
| | | |
| | | def __OnEndAward(actNum, ipyData, dayIndex): |
| | | ## 结算奖励 |
| | | if not ipyData: |
| | | return |
| | | cfgID = ipyData.GetCfgID() |
| | | awardState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum) |
| | | if awardState: |
| | | #已经结算过该活动 |
| | | GameWorld.Log("boss历练活动已经结算过奖励了! actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex)) |
| | | return |
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAward % actNum, 1) |
| | | |
| | | GameWorld.Log("=== 本服boss历练活动发放榜单奖励! === actNum=%s,cfgID=%s,dayIndex=%s" % (actNum, cfgID, dayIndex)) |
| | | |
| | | familyTemplateID = GameWorld.GetTemplateIDByList(ipyData.GetFamilyTemplateIDList(), dayIndex) |
| | | __OnEndAward_Family(familyTemplateID, ShareDefine.Def_BT_BossTrialSubmitFamily) |
| | | |
| | | templateID = GameWorld.GetTemplateID(ipyData, cfgID, dayIndex) |
| | | __OnEndAward_Personal(templateID, ShareDefine.Def_BT_BossTrialSubmit) |
| | | |
| | | # 流向备份 |
| | | DataRecordPack.DR_BillboardData(ShareDefine.Def_BT_BossTrialSubmitFamily, "BossTrial", {"actNum":actNum, "cfgID":cfgID, "dayIndex":dayIndex}) |
| | | DataRecordPack.DR_BillboardData(ShareDefine.Def_BT_BossTrialSubmit, "BossTrial", {"actNum":actNum, "cfgID":cfgID, "dayIndex":dayIndex}) |
| | | GameWorld.Log("=================================================================================") |
| | | return |
| | | |
| | | def __OnEndAward_Personal(templateID, billboardType): |
| | | billBoard = GameWorld.GetBillboard().FindBillboard(billboardType) |
| | | if not billBoard: |
| | | return |
| | | if not templateID: |
| | | GameWorld.Log("本次活动没有个人榜奖励!") |
| | | return |
| | | billboardDataCount = billBoard.GetCount() |
| | | billBoard.Sort() |
| | | |
| | | GameWorld.Log("结算个人榜单奖励: billboardType=%s,templateID=%s,billboardDataCount=%s" % (billboardType, templateID, billboardDataCount)) |
| | | |
| | | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID) |
| | | if not orderIpyDataList: |
| | | return |
| | | |
| | | rankPre = 0 |
| | | billboardIndex = 0 |
| | | for ipyData in orderIpyDataList: |
| | | rank = ipyData.GetRank() |
| | | needScore = ipyData.GetNeedScore() |
| | | scoreAwardEx = ipyData.GetScoreAwardEx() |
| | | scoreAwardExList = scoreAwardEx.keys() |
| | | scoreAwardExList.sort() |
| | | awardItemList = ipyData.GetAwardItemList() |
| | | orderCountTotal = rank - rankPre # 奖励名次数量 |
| | | rankPre = rank |
| | | |
| | | for index in xrange(billboardIndex, billboardDataCount): |
| | | if orderCountTotal <= 0: |
| | | break |
| | | |
| | | billBoardData = billBoard.At(index) |
| | | playerID = billBoardData.GetID() |
| | | name2 = billBoardData.GetName2() |
| | | cmpValue = billBoardData.GetCmpValue() |
| | | |
| | | if cmpValue < needScore: |
| | | GameWorld.Log(" 积分不足该榜单所需积分,跳过该名次: index=%s,rank=%s,playerID=%s,cmpValue=%s < %s" % (index, rank, playerID, cmpValue, needScore)) |
| | | break |
| | | |
| | | awardItemExList = [] |
| | | for scoreEx in scoreAwardExList: |
| | | if cmpValue < scoreEx: |
| | | break |
| | | awardItemExList = scoreAwardEx[scoreEx] # 取最大满足条件的一档 |
| | | finalAwardItemList = awardItemList + awardItemExList |
| | | |
| | | playerRank = rank - orderCountTotal + 1 |
| | | GameWorld.Log(" 发放boss历练个人榜单奖励: index=%s,rank=%s,playerRank=%s,playerID=%s,cmpValue=%s,awardItemList=%s,scoreAwardEx=%s,finalAwardItemList=%s, %s" |
| | | % (index, rank, playerRank, playerID, cmpValue, awardItemList, scoreAwardEx, finalAwardItemList, name2)) |
| | | PlayerCompensation.SendMailByKey("BossTrialMail10", [playerID], finalAwardItemList, [playerRank]) |
| | | |
| | | orderCountTotal -= 1 |
| | | billboardIndex += 1 |
| | | |
| | | return |
| | | |
| | | def __OnEndAward_Family(familyTemplateID, billboardType): |
| | | billBoard = GameWorld.GetBillboard().FindBillboard(billboardType) |
| | | if not billBoard: |
| | | return |
| | | if not familyTemplateID: |
| | | GameWorld.Log("本次活动没有仙盟榜奖励!") |
| | | return |
| | | billboardDataCount = billBoard.GetCount() |
| | | billBoard.Sort() |
| | | |
| | | GameWorld.Log("结算仙盟榜单奖励: billboardType=%s,familyTemplateID=%s,billboardDataCount=%s" % (billboardType, familyTemplateID, billboardDataCount)) |
| | | |
| | | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", familyTemplateID) |
| | | if not orderIpyDataList: |
| | | return |
| | | |
| | | familyManager = GameWorld.GetFamilyManager() |
| | | rankPre = 0 |
| | | billboardIndex = 0 |
| | | for ipyData in orderIpyDataList: |
| | | rank = ipyData.GetRank() |
| | | needScore = ipyData.GetNeedScore() |
| | | leaderAwardItemList = ipyData.GetAwardItemList() |
| | | memAwardItemList = ipyData.GetMemAwardItemList() |
| | | orderCountTotal = rank - rankPre # 奖励名次数量 |
| | | rankPre = rank |
| | | |
| | | for index in xrange(billboardIndex, billboardDataCount): |
| | | if orderCountTotal <= 0: |
| | | break |
| | | |
| | | billBoardData = billBoard.At(index) |
| | | familyID = billBoardData.GetID() |
| | | cmpValue = billBoardData.GetCmpValue() |
| | | |
| | | if cmpValue < needScore: |
| | | GameWorld.Log(" 不足该榜单所需提交数,跳过该名次: index=%s,rank=%s,familyID=%s,cmpValue=%s < %s" % (index, rank, familyID, cmpValue, needScore)) |
| | | break |
| | | |
| | | familyRank = rank - orderCountTotal + 1 |
| | | orderCountTotal -= 1 |
| | | billboardIndex += 1 |
| | | |
| | | family = familyManager.FindFamily(familyID) |
| | | if not family: |
| | | continue |
| | | |
| | | familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False) |
| | | if not familyActionData: |
| | | GameWorld.ErrLog("该仙盟没有提交凭证ActionData! familyID=%s" % familyID) |
| | | continue |
| | | awardState = GetFamilyAwardState(familyActionData) |
| | | awardIndex = 0 # 本服奖励状态索引 |
| | | if awardState&pow(2, awardIndex): |
| | | GameWorld.ErrLog("该仙盟本服榜奖励已发放! familyID=%s" % familyID) |
| | | continue |
| | | updAwardState = awardState|pow(2, awardIndex) |
| | | SetFamilyAwardState(familyActionData, updAwardState) |
| | | |
| | | memSubCountDict = GetFamilyMemSubCountDict(familyActionData) |
| | | |
| | | leaderID = family.GetLeaderID() |
| | | awardMemIDList = [] |
| | | for index in xrange(family.GetCount()): |
| | | member = family.GetAt(index) |
| | | memPlayerID = member.GetPlayerID() |
| | | if memPlayerID == leaderID: |
| | | continue |
| | | awardMemIDList.append(memPlayerID) |
| | | |
| | | paramList = [familyRank] |
| | | if not leaderAwardItemList: |
| | | awardMemIDList.append(leaderID) |
| | | else: |
| | | PlayerCompensation.SendMailByKey("BossTrialFamilyLeader", [leaderID], leaderAwardItemList, paramList) |
| | | |
| | | PlayerCompensation.SendMailByKey("BossTrialFamilyMember", awardMemIDList, memAwardItemList, paramList) |
| | | GameWorld.Log("发放boss历练活动仙盟榜单奖励本服: index=%s,rank=%s,familyID=%s,名次=%s,总提交个数=%s,updAwardState=%s,awardMemIDList=%s,memSubCountDict=%s" |
| | | % (index, rank, familyID, familyRank, cmpValue, updAwardState, awardMemIDList, memSubCountDict)) |
| | | |
| | | return |
| | | |
| | | def MapServer_BossTrial(curPlayer, msgList): |
| | | mapID = curPlayer.GetRealMapID() |
| | | playerID = curPlayer.GetPlayerID() |
| | | GameWorld.DebugLog("MapServer_BossTrial mapID=%s,msgList=%s" % (mapID, msgList), playerID) |
| | | if not msgList: |
| | | return |
| | | |
| | | msgType, dataMsg = msgList |
| | | ret = None |
| | | |
| | | if msgType == "BossTrialSubmit": |
| | | ret = __OnBossTrialSubmit(curPlayer, dataMsg) |
| | | |
| | | if ret == None: |
| | | return |
| | | return msgList + (ret if isinstance(ret, list) else [ret]) |
| | | |
| | | def __OnBossTrialSubmit(curPlayer, dataMsg): |
| | | ## 地图提交boss凭证 |
| | | playerID = curPlayer.GetPlayerID() |
| | | accID = curPlayer.GetAccID() |
| | | playerName = curPlayer.GetName() |
| | | job = curPlayer.GetJob() |
| | | face = curPlayer.GetFace() |
| | | facePic = curPlayer.GetFacePic() |
| | | realmLV = curPlayer.GetOfficialRank() |
| | | familyID = curPlayer.GetFamilyID() |
| | | submitCount, updSubmitCount = dataMsg |
| | | |
| | | curFamily, familySubmitTotal = __DoBossTrialSubmitFamilyAction(curPlayer, submitCount) |
| | | familyBillInfo = {} |
| | | |
| | | #更新本服仙盟提交榜单 |
| | | if familyID and curFamily and familySubmitTotal: |
| | | familyBillInfo = PlayerFamily.GetFamilyBillboardInfo(curFamily) |
| | | familyBillInfo["familySubmitTotal"] = familySubmitTotal |
| | | PlayerBillboard.UpdateFamilyBillboard(ShareDefine.Def_BT_BossTrialSubmitFamily, familyBillInfo, familySubmitTotal) |
| | | |
| | | #同步跨服 |
| | | playerInfo = {"playerID":playerID, "playerName":playerName, "accID":accID, "job":job, "realmLV":realmLV, |
| | | "playerSubmitTotal":updSubmitCount, "face":face, "facePic":facePic} |
| | | SyncBossTrialSubmitToCrossServer(curPlayer, playerInfo, familyBillInfo) |
| | | return |
| | | |
| | | def __DoBossTrialSubmitFamilyAction(curPlayer, submitCount): |
| | | ## 执行提交凭证到仙盟Action数据 |
| | | |
| | | curFamily = None |
| | | familySubmitTotal = 0 |
| | | playerID = curPlayer.GetPlayerID() |
| | | familyID = curPlayer.GetFamilyID() |
| | | if not familyID: |
| | | return curFamily, familySubmitTotal |
| | | |
| | | familyManager = GameWorld.GetFamilyManager() |
| | | curFamily = familyManager.FindFamily(familyID) |
| | | if not curFamily: |
| | | return curFamily, familySubmitTotal |
| | | |
| | | familyActionData = GetFamilyBossTrialSubmitActionData(familyID, True) |
| | | |
| | | familySubmitTotal = GetFamilySubmitTotal(familyActionData) + submitCount |
| | | SetFamilySubmitTotal(familyActionData, familySubmitTotal) |
| | | |
| | | memSubCountDict = GetFamilyMemSubCountDict(familyActionData) |
| | | memSubCountDict[playerID] = memSubCountDict.get(playerID, 0) + submitCount |
| | | SetFamilyMemSubCountDict(familyActionData, memSubCountDict) |
| | | |
| | | return curFamily, familySubmitTotal |
| | | |
| | | def GetFamilyBossTrialSubmitActionData(familyID, isAdd=False): |
| | | ## 获取仙盟boss凭证提交 |
| | | familyActionObj = None |
| | | actionType = ShareDefine.Def_ActionType_BossTrialSubmit |
| | | familyAction = GameWorld.GetFamilyActionManager().GetFamilyAction(familyID, actionType) |
| | | if not familyAction.Count(): |
| | | if isAdd: |
| | | familyActionObj = familyAction.AddAction() |
| | | familyActionObj.SetFamilyId(familyID) |
| | | familyActionObj.SetActionType(actionType) |
| | | else: |
| | | familyActionObj = familyAction.At(0) |
| | | |
| | | return familyActionObj |
| | | |
| | | def GetFamilySubmitTotalByID(familyID): |
| | | ## 获取仙盟提交的凭证总数 |
| | | familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False) |
| | | if not familyActionData: |
| | | return 0 |
| | | return GetFamilySubmitTotal(familyActionData) |
| | | |
| | | def GetFamilySubmitTotal(familyActionData): return familyActionData.GetValue1() |
| | | def SetFamilySubmitTotal(familyActionData, submitTotal): familyActionData.SetValue1(submitTotal) |
| | | def GetFamilyAwardState(familyActionData): return familyActionData.GetValue2() |
| | | def SetFamilyAwardState(familyActionData, state): return familyActionData.SetValue2(state) |
| | | |
| | | def GetFamilyMemSubCountDict(familyActionData): |
| | | memSubCountDict = {} |
| | | useData = familyActionData.GetUseData() |
| | | if useData: |
| | | try: |
| | | memSubCountDict = eval(useData) |
| | | except: |
| | | memSubCountDict = {} |
| | | return memSubCountDict |
| | | def SetFamilyMemSubCountDict(familyActionData, memSubCountDict): |
| | | useData = str(memSubCountDict).replace(" ", "") |
| | | familyActionData.SetUseData(useData, len(useData)) |
| | | return |
| | | |
| | | def SyncBossTrialSubmitToCrossServer(curPlayer, playerInfo, familyInfo): |
| | | ## 同步boss凭证提交总数到跨服服务器 |
| | | actInfo = CrossActionControl.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_BossTrial) |
| | | if not actInfo.get(ShareDefine.ActKey_State): |
| | | return |
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID) |
| | | ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {}) |
| | | if not ipyDataDict: |
| | | return |
| | | zoneID = ipyDataDict.get("ZoneID") |
| | | if not cfgID or not zoneID: |
| | | return |
| | | |
| | | dataMsg = {"cfgID":cfgID, "zoneID":zoneID, "playerInfo":playerInfo, "familyInfo":familyInfo} |
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_BossTrialSubmit, dataMsg) |
| | | return |
| | | |
| | | def CrossServerMsg_CrossBossTrialFamilyAward(msgData): |
| | | ## 收到跨服通知 - 结算跨服仙盟榜奖励 |
| | | cfgID = msgData["cfgID"] |
| | | zoneID = msgData["zoneID"] |
| | | templateID = msgData["templateID"] |
| | | awardFamilyList = msgData["awardFamilyList"] |
| | | |
| | | GameWorld.Log("收到跨服同步的结算boss历练活动跨服仙盟榜奖励: cfgID=%s,zoneID=%s,templateID=%s" % (cfgID, zoneID, templateID)) |
| | | |
| | | familyManager = GameWorld.GetFamilyManager() |
| | | |
| | | for familyInfo in awardFamilyList: |
| | | familyID, familyRank, familySubmitTotal, leaderAwardItemList, memAwardItemList = familyInfo |
| | | family = familyManager.FindFamily(familyID) |
| | | if not family: |
| | | GameWorld.DebugLog("非本服仙盟或已解散! familyID=%s" % familyID) |
| | | continue |
| | | |
| | | familyActionData = GetFamilyBossTrialSubmitActionData(familyID, False) |
| | | if not familyActionData: |
| | | GameWorld.ErrLog("该仙盟没有提交凭证ActionData! familyID=%s" % familyID) |
| | | continue |
| | | awardState = GetFamilyAwardState(familyActionData) |
| | | awardIndex = 1 #跨服奖励状态索引 |
| | | if awardState&pow(2, awardIndex): |
| | | GameWorld.ErrLog("该仙盟跨服榜奖励已发放! familyID=%s" % familyID) |
| | | continue |
| | | updAwardState = awardState|pow(2, awardIndex) |
| | | SetFamilyAwardState(familyActionData, updAwardState) |
| | | |
| | | memSubCountDict = GetFamilyMemSubCountDict(familyActionData) |
| | | |
| | | leaderID = family.GetLeaderID() |
| | | awardMemIDList = [] |
| | | for index in xrange(family.GetCount()): |
| | | member = family.GetAt(index) |
| | | memPlayerID = member.GetPlayerID() |
| | | if memPlayerID == leaderID: |
| | | continue |
| | | awardMemIDList.append(memPlayerID) |
| | | |
| | | paramList = [familyRank] |
| | | if not leaderAwardItemList: |
| | | awardMemIDList.append(leaderID) |
| | | else: |
| | | PlayerCompensation.SendMailByKey("BossTrialCrossFamilyLeader", [leaderID], leaderAwardItemList, paramList) |
| | | |
| | | PlayerCompensation.SendMailByKey("BossTrialCrossFamilyMember", awardMemIDList, memAwardItemList, paramList) |
| | | GameWorld.Log("发放boss历练活动仙盟榜单奖励跨服: familyID=%s,名次=%s,总提交个数=%s,updAwardState=%s,awardMemIDList=%s,memSubCountDict=%s" |
| | | % (familyID, familyRank, familySubmitTotal, updAwardState, awardMemIDList, memSubCountDict)) |
| | | |
| | | return |
| | | |
| | | ##------------------------------------------ 跨服boss历练活动 --------------------------------------- |
| | | |
| | | def ClientServerMsg_BossTrialSubmit(serverGroupID, msgData): |
| | | ## 收到子服 - 提交boss凭证 |
| | | |
| | | cfgID = msgData["cfgID"] |
| | | zoneID = msgData["zoneID"] |
| | | playerInfo = msgData["playerInfo"] |
| | | familyInfo = msgData["familyInfo"] |
| | | |
| | | actInfo = CrossActionControl.GetCrossActInfoByCfgID(ShareDefine.CrossActName_BossTrial, cfgID, zoneID) |
| | | if not actInfo or not actInfo[ShareDefine.ActKey_State]: |
| | | GameWorld.ErrLog("跨服boss历练非活动中,无法提交! cfgID=%s, zoneID=%s" % (cfgID, zoneID)) |
| | | return |
| | | if actInfo[ShareDefine.ActKey_StateJoin] != ShareDefine.ActStateJoin_Start: |
| | | GameWorld.ErrLog("跨服boss历练非可参与状态,无法提交! cfgID=%s, zoneID=%s" % (cfgID, zoneID)) |
| | | return |
| | | ipyData = IpyGameDataPY.GetIpyGameData("CrossActBossTrial", cfgID) |
| | | if not ipyData: |
| | | return |
| | | personlLimit, familyLimit = 0, 0 |
| | | |
| | | PersonalTemplateID = ipyData.GetPersonalTemplateID() |
| | | pRankIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", PersonalTemplateID) if PersonalTemplateID else None |
| | | if pRankIpyDataList: |
| | | lastRankIpyData = pRankIpyDataList[-1] # 取最后一个为最低上榜积分限制 |
| | | personlLimit = lastRankIpyData.GetNeedScore() |
| | | |
| | | FamilyTemplateID = ipyData.GetFamilyTemplateID() |
| | | fRankIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", FamilyTemplateID) if FamilyTemplateID else None |
| | | if fRankIpyDataList: |
| | | lastRankIpyData = fRankIpyDataList[-1] # 取最后一个为最低上榜积分限制 |
| | | familyLimit = lastRankIpyData.GetNeedScore() |
| | | |
| | | playerID = playerInfo["playerID"] |
| | | playerName = playerInfo["playerName"] |
| | | job = playerInfo["job"] |
| | | accID = playerInfo["accID"] |
| | | realmLV = playerInfo["realmLV"] |
| | | playerSubmitTotal = playerInfo["playerSubmitTotal"] |
| | | face = playerInfo.get("face", 0) |
| | | facePic = playerInfo.get("facePic", 0) |
| | | |
| | | groupValue1 = zoneID |
| | | |
| | | if playerSubmitTotal >= personlLimit: |
| | | name2, type2, value1, value2 = accID, job, realmLV, 0 |
| | | CrossBillboard.UpdCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1, playerID, playerName, |
| | | name2, type2, value1, value2, playerSubmitTotal, value3=face, value4=facePic) |
| | | |
| | | if familyInfo and familyInfo.get("familySubmitTotal", 0) >= familyLimit: |
| | | familySubmitTotal = familyInfo["familySubmitTotal"] |
| | | CrossBillboard.UpdCrossBillboardFamily(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1, familyInfo, familySubmitTotal) |
| | | |
| | | return |
| | | |
| | | def OnCrossActIDChange(cfgID, zoneID, ipyData, state): |
| | | ## 跨服活动ID变更 |
| | | if state: |
| | | OnCrossActStart(cfgID, zoneID, ipyData) |
| | | else: |
| | | OnCrossActEnd(cfgID, zoneID, ipyData) |
| | | return |
| | | |
| | | def OnCrossActStart(cfgID, zoneID, ipyData): |
| | | ## 跨服活动开启 |
| | | |
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID, 0) |
| | | |
| | | groupValue1 = zoneID |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager() |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1) |
| | | billboardObj.ClearData() # 新活动重置榜单数据 |
| | | |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1) |
| | | billboardObj.ClearData() # 新活动重置榜单数据 |
| | | return |
| | | |
| | | def OnCrossActEnd(cfgID, zoneID, ipyData): |
| | | ## 跨服活动结束 |
| | | |
| | | groupValue1 = zoneID |
| | | GameWorld.Log("=== 跨服boss历练活动结束! === cfgID=%s,zoneID=%s" % (cfgID, zoneID)) |
| | | __OnCrossEndAward(cfgID, zoneID, ipyData) |
| | | |
| | | # 备份、清除榜单数据 |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager() |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1) |
| | | CrossBillboard.CopyBillboardEx(ShareDefine.Def_CBT_BossTrialSubmit, ShareDefine.Def_CBT_BossTrialSubmitBak, groupValue1) |
| | | billboardObj.ClearData() |
| | | |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1) |
| | | CrossBillboard.CopyBillboardEx(ShareDefine.Def_CBT_BossTrialSubmitFamily, ShareDefine.Def_CBT_BossTrialSubmitFamilyBak, groupValue1) |
| | | billboardObj.ClearData() |
| | | GameWorld.Log("=================================================================================") |
| | | return |
| | | |
| | | def OnCrossActInStateRefresh(cfgID, zoneID, ipyData): |
| | | ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等 |
| | | if not ipyData: |
| | | return |
| | | PersonalTemplateID = ipyData.GetPersonalTemplateID() |
| | | FamilyTemplateID = ipyData.GetFamilyTemplateID() |
| | | orderRuleList = GetOrderRuleList(PersonalTemplateID) |
| | | orderRuleListFamily = GetOrderRuleList(FamilyTemplateID) |
| | | |
| | | groupValue1 = zoneID |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager() |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmit, groupValue1) |
| | | billboardObj.SetOrderRuleList(orderRuleList) |
| | | |
| | | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_BossTrialSubmitFamily, groupValue1) |
| | | billboardObj.SetOrderRuleList(orderRuleListFamily) |
| | | return |
| | | |
| | | def GetOrderRuleList(templateID): |
| | | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID) |
| | | if not orderIpyDataList: |
| | | return |
| | | orderRuleList = [] |
| | | for ipyData in orderIpyDataList: |
| | | orderRuleList.append([ipyData.GetRank(), ipyData.GetNeedScore()]) |
| | | return orderRuleList |
| | | |
| | | def OnCrossActJoinEnd(cfgID, zoneID, ipyData): |
| | | ## 跨服活动参与结束 |
| | | __OnCrossEndAward(cfgID, zoneID, ipyData) |
| | | return |
| | | |
| | | def __OnCrossEndAward(cfgID, zoneID, ipyData): |
| | | ## 结算跨服奖励 |
| | | awardState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID) |
| | | if awardState: |
| | | #已经结算过该活动 |
| | | GameWorld.Log("跨服boss历练活动已经结算过奖励了! cfgID=%s,zoneID=%s" % (cfgID, zoneID)) |
| | | return |
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActBossTrialAwardC % zoneID, 1) |
| | | |
| | | GameWorld.Log("=== 跨服boss历练活动发放榜单奖励! === cfgID=%s,zoneID=%s" % (cfgID, zoneID)) |
| | | |
| | | PersonalTemplateID = ipyData.GetPersonalTemplateID() |
| | | FamilyTemplateID = ipyData.GetFamilyTemplateID() |
| | | serverIDRangeList = ipyData.GetServerIDRangeList() |
| | | |
| | | __GiveCrossOrderAwardPersonal(cfgID, zoneID, PersonalTemplateID, ShareDefine.Def_CBT_BossTrialSubmit, serverIDRangeList) |
| | | __GiveCrossOrderAwardFamily(cfgID, zoneID, FamilyTemplateID, ShareDefine.Def_CBT_BossTrialSubmitFamily) |
| | | GameWorld.Log("=================================================================================") |
| | | return |
| | | |
| | | def __GiveCrossOrderAwardPersonal(cfgID, zoneID, templateID, billboardType, serverIDRangeList): |
| | | |
| | | groupValue1 = zoneID |
| | | #billboardType = ShareDefine.Def_CBT_BossTrialSubmit #榜单类型改为参数传入,异常情况下可特殊处理用备份榜单发奖励 |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager() |
| | | billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1) |
| | | billboardDataCount = billboardObj.GetCount() |
| | | if not billboardDataCount: |
| | | GameWorld.Log("跨服Boss凭证个人排行数据为空! billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s" % (billboardType, zoneID, cfgID, templateID)) |
| | | return |
| | | |
| | | # 结算时排序并保存榜单数据流向 |
| | | billboardObj.SortData() |
| | | billboardObj.SaveDRData("BossTrial", {"cfgID":cfgID, "zoneID":zoneID}) |
| | | |
| | | GameWorld.Log("结算跨服Boss凭证个人排行奖励: billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s,billboardDataCount=%s" |
| | | % (billboardType, zoneID, cfgID, templateID, billboardDataCount)) |
| | | |
| | | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID) |
| | | if not orderIpyDataList: |
| | | return |
| | | |
| | | worshipType = ShareDefine.Def_WorshipType_CrossBossTrial |
| | | syncNewWorshipList = [] |
| | | syncNewXiangongDict = {} |
| | | rankPre = 0 |
| | | billboardIndex = 0 |
| | | for ipyData in orderIpyDataList: |
| | | rank = ipyData.GetRank() |
| | | needScore = ipyData.GetNeedScore() |
| | | scoreAwardEx = ipyData.GetScoreAwardEx() |
| | | scoreAwardExList = scoreAwardEx.keys() |
| | | scoreAwardExList.sort() |
| | | awardItemList = ipyData.GetAwardItemList() |
| | | xiangongID = ipyData.GetXiangongID() |
| | | orderCountTotal = rank - rankPre # 奖励名次数量 |
| | | rankPre = rank |
| | | |
| | | for index in xrange(billboardIndex, billboardDataCount): |
| | | if orderCountTotal <= 0: |
| | | break |
| | | |
| | | billboardData = billboardObj.At(index) |
| | | playerID = billboardData.ID |
| | | name2 = billboardData.Name2 |
| | | cmpValue = billboardData.CmpValue |
| | | if cmpValue < needScore: |
| | | GameWorld.Log(" 积分不足该榜单所需积分,跳过该名次: index=%s,rank=%s,playerID=%s,cmpValue=%s < %s" % (index, rank, playerID, cmpValue, needScore)) |
| | | break |
| | | |
| | | awardItemExList = [] |
| | | for scoreEx in scoreAwardExList: |
| | | if cmpValue < scoreEx: |
| | | break |
| | | awardItemExList = scoreAwardEx[scoreEx] # 取最大满足条件的一档 |
| | | finalAwardItemList = awardItemList + awardItemExList |
| | | |
| | | playerRank = rank - orderCountTotal + 1 |
| | | GameWorld.Log(" 发放boss历练个人榜单奖励: index=%s,rank=%s,playerRank=%s,playerID=%s,cmpValue=%s,awardItemList=%s,scoreAwardEx=%s,finalAwardItemList=%s, %s" |
| | | % (index, rank, playerRank, playerID, cmpValue, awardItemList, scoreAwardEx, finalAwardItemList, name2)) |
| | | PlayerCompensation.SendMailByKey("BossTrialCrossPlayer", [playerID], finalAwardItemList, [playerRank], crossMail=True) |
| | | |
| | | orderCountTotal -= 1 |
| | | billboardIndex += 1 |
| | | |
| | | GameXiangong.AddXiangongPlayer(xiangongID, playerID, serverIDRangeList, playerRank, syncNewXiangongDict) |
| | | GameWorship.AddWorshipPlayer(worshipType, playerRank, playerID, serverIDRangeList, syncList=syncNewWorshipList) |
| | | GameWorship.SendNewWorshipPlayer(syncNewWorshipList) |
| | | GameXiangong.SendNewXiangongPlayerToClientServer(syncNewXiangongDict) |
| | | return |
| | | |
| | | def __GiveCrossOrderAwardFamily(cfgID, zoneID, templateID, billboardType): |
| | | |
| | | groupValue1 = zoneID |
| | | #billboardType = ShareDefine.Def_CBT_BossTrialSubmitFamily |
| | | billboardMgr = PyDataManager.GetCrossBillboardManager() |
| | | billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1) |
| | | billboardDataCount = billboardObj.GetCount() |
| | | if not billboardDataCount: |
| | | GameWorld.Log("跨服Boss凭证仙盟排行数据为空! billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s" % (billboardType, zoneID, cfgID, templateID)) |
| | | return |
| | | |
| | | # 结算时排序并保存榜单数据流向 |
| | | billboardObj.SortData() |
| | | billboardObj.SaveDRData("BossTrial", {"cfgID":cfgID, "zoneID":zoneID}) |
| | | |
| | | GameWorld.Log("结算跨服Boss凭证仙盟排行奖励: billboardType=%s,zoneID=%s,cfgID=%s,templateID=%s,billboardDataCount=%s" |
| | | % (billboardType, zoneID, cfgID, templateID, billboardDataCount)) |
| | | |
| | | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActBossTrialTemplate", templateID) |
| | | if not orderIpyDataList: |
| | | return |
| | | |
| | | awardFamilyList = [] |
| | | rankPre = 0 |
| | | billboardIndex = 0 |
| | | for ipyData in orderIpyDataList: |
| | | rank = ipyData.GetRank() |
| | | needScore = ipyData.GetNeedScore() |
| | | leaderAwardItemList = ipyData.GetAwardItemList() |
| | | memAwardItemList = ipyData.GetMemAwardItemList() |
| | | orderCountTotal = rank - rankPre # 奖励名次数量 |
| | | rankPre = rank |
| | | |
| | | for index in xrange(billboardIndex, billboardDataCount): |
| | | if orderCountTotal <= 0: |
| | | break |
| | | |
| | | billboardData = billboardObj.At(index) |
| | | familyID = billboardData.ID |
| | | familySubmitTotal = billboardData.CmpValue |
| | | |
| | | if familySubmitTotal < needScore: |
| | | GameWorld.Log(" 不足该榜单所需提交数,跳过该名次: index=%s,rank=%s,familyID=%s,familySubmitTotal=%s < %s" % (index, rank, familyID, familySubmitTotal, needScore)) |
| | | break |
| | | |
| | | familyRank = rank - orderCountTotal + 1 |
| | | GameWorld.Log(" index=%s,rank=%s,familyID=%s,名次=%s,总提交个数=%s" % (index, rank, familyID, familyRank, familySubmitTotal)) |
| | | awardFamilyList.append([familyID, familyRank, familySubmitTotal, leaderAwardItemList, memAwardItemList]) |
| | | |
| | | orderCountTotal -= 1 |
| | | billboardIndex += 1 |
| | | |
| | | # 广播子服发放奖励 |
| | | sendMsg = {"cfgID":cfgID, "zoneID":zoneID, "templateID":templateID, "awardFamilyList":awardFamilyList} |
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_CrossBossTrialFamilyAward, sendMsg) |
| | | return |
| | | |