|  |  |  | 
|---|
|  |  |  | import CrossBillboard | 
|---|
|  |  |  | import PyDataManager | 
|---|
|  |  |  | import CrossRealmMsg | 
|---|
|  |  |  | import GameXiangong | 
|---|
|  |  |  | import GameWorship | 
|---|
|  |  |  | import GameWorld | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnActStart(actNum): | 
|---|
|  |  |  | def OnActStart(actNum, ipyData): | 
|---|
|  |  |  | ## 活动开启 | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | personalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | if not personalTemplateID: | 
|---|
|  |  |  | GameWorld.DebugLog("骑宠养成活动没有榜单奖励,不处理OnActStart! actNum=%s" % (actNum)) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActHorsePetTrainAward % actNum, 0) | 
|---|
|  |  |  | PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_HorsePetTrainScore) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.Log("=================================================================================") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnActInStateRefresh(actNum, ipyData): | 
|---|
|  |  |  | ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等 | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | personalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | if not personalTemplateID: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | orderRuleList = GetOrderRuleList(personalTemplateID) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | billboardMgr = PlayerBillboard.GetBillboardMgr() | 
|---|
|  |  |  | billboardObj = billboardMgr.GetBillboardObj(ShareDefine.Def_BT_HorsePetTrainScore) | 
|---|
|  |  |  | billboardObj.SetOrderRuleList(orderRuleList) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnActJoinEnd(actNum, ipyData, dayIndex): | 
|---|
|  |  |  | ## 活动参与结束 | 
|---|
|  |  |  | __OnEndAward(actNum, ipyData, dayIndex) | 
|---|
|  |  |  | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | cfgID = ipyData.GetCfgID() | 
|---|
|  |  |  | personalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | if not personalTemplateID: | 
|---|
|  |  |  | GameWorld.DebugLog("骑宠养成活动没有榜单奖励,不结算榜单奖励! actNum=%s" % (actNum)) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | awardState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ActHorsePetTrainAward % actNum) | 
|---|
|  |  |  | if awardState: | 
|---|
|  |  |  | #已经结算过该活动 | 
|---|
|  |  |  | 
|---|
|  |  |  | if not templateID: | 
|---|
|  |  |  | GameWorld.Log("本次活动没有个人榜奖励!") | 
|---|
|  |  |  | return | 
|---|
|  |  |  | tempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", templateID) | 
|---|
|  |  |  | if not tempIpyDataList: | 
|---|
|  |  |  | billboardDataCount = billBoard.GetCount() | 
|---|
|  |  |  | billBoard.Sort() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GameWorld.Log("结算个人榜单奖励: billboardType=%s,templateID=%s,billboardDataCount=%s" % (billboardType, templateID, billboardDataCount)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", templateID) | 
|---|
|  |  |  | if not orderIpyDataList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rankAwardDict = {} | 
|---|
|  |  |  | for tempIpyData in tempIpyDataList: | 
|---|
|  |  |  | rankAwardDict[tempIpyData.GetRank()] = tempIpyData.GetAwardItemList() | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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("    发放骑宠养成个人榜单奖励: rank=%s,playerID=%s,cmpValue=%s,awardItemList=%s, %s" | 
|---|
|  |  |  | % (rank, playerID, cmpValue, awardItemList, name2)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("ActHorsePetTrainPlayer", [playerID], awardItemList, [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("    发放骑宠养成个人榜单奖励: 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("ActHorsePetTrainPlayer", [playerID], finalAwardItemList, [playerRank]) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderCountTotal -= 1 | 
|---|
|  |  |  | billboardIndex += 1 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def MapServer_HorsePetTrain(curPlayer, msgList): | 
|---|
|  |  |  | 
|---|
|  |  |  | accID = curPlayer.GetAccID() | 
|---|
|  |  |  | playerName = curPlayer.GetName() | 
|---|
|  |  |  | job = curPlayer.GetJob() | 
|---|
|  |  |  | face = curPlayer.GetFace() | 
|---|
|  |  |  | facePic = curPlayer.GetFacePic() | 
|---|
|  |  |  | realmLV = curPlayer.GetOfficialRank() | 
|---|
|  |  |  | _, updScore = dataMsg | 
|---|
|  |  |  | _, updScore, isRelationCrossAct = dataMsg | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #同步跨服 | 
|---|
|  |  |  | playerInfo = {"playerID":playerID, "playerName":playerName, "accID":accID, "job":job, "realmLV":realmLV, | 
|---|
|  |  |  | "playerScore":updScore} | 
|---|
|  |  |  | SyncHorsePetTrainToCrossServer(curPlayer, playerInfo) | 
|---|
|  |  |  | # 仙盟榜... | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if isRelationCrossAct: | 
|---|
|  |  |  | #同步跨服 | 
|---|
|  |  |  | playerInfo = {"playerID":playerID, "playerName":playerName, "accID":accID, "job":job, "realmLV":realmLV, | 
|---|
|  |  |  | "playerScore":updScore, "face":face, "facePic":facePic} | 
|---|
|  |  |  | SyncHorsePetTrainToCrossServer(curPlayer, playerInfo) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def SyncHorsePetTrainToCrossServer(curPlayer, playerInfo): | 
|---|
|  |  |  | 
|---|
|  |  |  | ipyData = IpyGameDataPY.GetIpyGameData("CrossActHorsePetTrain", cfgID) | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | personlLimit = ipyData.GetRankLimitPersonal() | 
|---|
|  |  |  | PersonalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | rankIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", PersonalTemplateID) | 
|---|
|  |  |  | if not rankIpyDataList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | lastRankIpyData = rankIpyDataList[-1] # 取最后一个为最低上榜积分限制 | 
|---|
|  |  |  | personlLimit = lastRankIpyData.GetNeedScore() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | playerID = playerInfo["playerID"] | 
|---|
|  |  |  | playerName = playerInfo["playerName"] | 
|---|
|  |  |  | 
|---|
|  |  |  | accID = playerInfo["accID"] | 
|---|
|  |  |  | realmLV = playerInfo["realmLV"] | 
|---|
|  |  |  | playerScore = playerInfo["playerScore"] | 
|---|
|  |  |  | face = playerInfo.get("face", 0) | 
|---|
|  |  |  | facePic = playerInfo.get("facePic", 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | groupValue1 = zoneID | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if playerScore >= personlLimit: | 
|---|
|  |  |  | name2, type2, value1, value2 = accID, job, realmLV, 0 | 
|---|
|  |  |  | CrossBillboard.UpdCrossBillboard(ShareDefine.Def_CBT_HorsePetTrainScore, groupValue1, playerID, playerName, | 
|---|
|  |  |  | name2, type2, value1, value2, playerScore) | 
|---|
|  |  |  | name2, type2, value1, value2, playerScore, autoSort=False, value3=face, value4=facePic) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnCrossActIDChange(cfgID, zoneID, ipyData, state): | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.Log("=================================================================================") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def OnCrossActInStateRefresh(cfgID, zoneID, ipyData): | 
|---|
|  |  |  | ## 活动中刷新,每次都需要刷新的逻辑,包含重读配置等 | 
|---|
|  |  |  | if not ipyData: | 
|---|
|  |  |  | return | 
|---|
|  |  |  | PersonalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | orderRuleList = GetOrderRuleList(PersonalTemplateID) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | groupValue1 = zoneID | 
|---|
|  |  |  | billboardMgr = PyDataManager.GetCrossBillboardManager() | 
|---|
|  |  |  | billboardObj = billboardMgr.GetCrossBillboard(ShareDefine.Def_CBT_HorsePetTrainScore, groupValue1) | 
|---|
|  |  |  | billboardObj.SetOrderRuleList(orderRuleList) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def GetOrderRuleList(templateID): | 
|---|
|  |  |  | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", 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) | 
|---|
|  |  |  | 
|---|
|  |  |  | GameWorld.Log("=== 跨服骑宠养成活动发放榜单奖励! === cfgID=%s,zoneID=%s" % (cfgID, zoneID)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PersonalTemplateID = ipyData.GetPersonalTemplateID() | 
|---|
|  |  |  | serverIDRangeList = ipyData.GetServerIDRangeList() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | __GiveCrossOrderAwardPersonal(cfgID, zoneID, PersonalTemplateID, ShareDefine.Def_CBT_HorsePetTrainScore) | 
|---|
|  |  |  | __GiveCrossOrderAwardPersonal(cfgID, zoneID, PersonalTemplateID, ShareDefine.Def_CBT_HorsePetTrainScore, serverIDRangeList) | 
|---|
|  |  |  | GameWorld.Log("=================================================================================") | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | def __GiveCrossOrderAwardPersonal(cfgID, zoneID, templateID, billboardType): | 
|---|
|  |  |  | def __GiveCrossOrderAwardPersonal(cfgID, zoneID, templateID, billboardType, serverIDRangeList): | 
|---|
|  |  |  |  | 
|---|
|  |  |  | groupValue1 = zoneID | 
|---|
|  |  |  | billboardMgr = PyDataManager.GetCrossBillboardManager() | 
|---|
|  |  |  | 
|---|
|  |  |  | % (billboardType, zoneID, cfgID, templateID, billboardDataCount)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActHorsePetTrainBillTemp", templateID) | 
|---|
|  |  |  | if orderIpyDataList: | 
|---|
|  |  |  | rankPre = 0 | 
|---|
|  |  |  | billboardIndex = 0 | 
|---|
|  |  |  | for ipyData in orderIpyDataList: | 
|---|
|  |  |  | rank = ipyData.GetRank() | 
|---|
|  |  |  | awardItemList = ipyData.GetAwardItemList() | 
|---|
|  |  |  | orderCountTotal = rank - rankPre # 奖励名次数量 | 
|---|
|  |  |  | rankPre = rank | 
|---|
|  |  |  | orderCount = 0 | 
|---|
|  |  |  | if not orderIpyDataList: | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | worshipType = ShareDefine.Def_WorshipType_CrossHorsePetTrain | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for index in xrange(billboardIndex, billboardDataCount): | 
|---|
|  |  |  | if orderCount >= orderCountTotal: | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | billboardData = billboardObj.At(index) | 
|---|
|  |  |  | playerID = billboardData.ID | 
|---|
|  |  |  | name2 = billboardData.Name2 | 
|---|
|  |  |  | cmpValue = billboardData.CmpValue | 
|---|
|  |  |  |  | 
|---|
|  |  |  | playerRank = index + 1 | 
|---|
|  |  |  | GameWorld.Log("    发放骑宠养成个人榜单奖励: rank=%s,playerID=%s,cmpValue=%s,awardItemList=%s, %s" | 
|---|
|  |  |  | % (rank, playerID, cmpValue, awardItemList, name2)) | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey("ActHorsePetTrainCrossPlayer", [playerID], awardItemList, [playerRank], crossMail=True) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | orderCount += 1 | 
|---|
|  |  |  | billboardIndex += 1 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | awardItemExList = scoreAwardEx[scoreEx] # 取最大满足条件的一档 | 
|---|
|  |  |  | finalAwardItemList = awardItemList + awardItemExList | 
|---|
|  |  |  |  | 
|---|
|  |  |  | playerRank = rank - orderCountTotal + 1 | 
|---|
|  |  |  | GameWorld.Log("    发放骑宠养成个人榜单奖励: 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("ActHorsePetTrainCrossPlayer", [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 | 
|---|
|  |  |  |  | 
|---|