| | |
| | | import PlayerCompensation
|
| | | import PlayerDBGSEvent
|
| | | import ChPyNetSendPack
|
| | | import DataRecordPack
|
| | | import NetPackCommon
|
| | | import IpyGameDataPY
|
| | | import PyGameData
|
| | |
| | | def GetArenaBillLV(billData): return billData.GetValue2()
|
| | | def SetArenaBillLV(billData, lv): billData.SetValue2(lv)
|
| | | def GetArenaBillScore(billData): return billData.GetCmpValue()
|
| | | def GetArenaBillFightPower(billData): return billData.GetCmpValue2()
|
| | | def SetArenaBillFightPower(billData, fightPower): billData.SetCmpValue2(fightPower)
|
| | | |
| | | def SetArenaBillScore(billData, score): return billData.SetCmpValue(score)
|
| | | def GetArenaBillFightPower(billData): return billData.GetCmpValue2() * ShareDefine.Def_PerPointValue + billData.GetCmpValue3()
|
| | | def SetArenaBillFightPower(billData, fightPower):
|
| | | billData.SetCmpValue2(fightPower / ShareDefine.Def_PerPointValue)
|
| | | billData.SetCmpValue3(fightPower % ShareDefine.Def_PerPointValue)
|
| | | return
|
| | |
|
| | | def RepairArenaBillboardFightPower():
|
| | | ## 修正竞技场榜单的战力数据,支持20亿,bt3_1.100.1 下次大版本更新后可删除
|
| | | |
| | | repairStateKey = "RepairArenaBillboardFightPower"
|
| | | repairState = PlayerDBGSEvent.GetDBGSTrig_ByKey(repairStateKey)
|
| | | if repairState:
|
| | | GameWorld.DebugLog("=== 已经修正竞技场榜单数据 ===")
|
| | | return
|
| | | |
| | | GameWorld.Log("=== 修正竞技场榜单数据 Start ===")
|
| | | |
| | | worldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ArenaWorldLV, worldLV)
|
| | | GameWorld.Log(" SetDBGSTrig_ByKey %s=%s" % (PlayerDBGSEvent.Def_ArenaWorldLV, worldLV))
|
| | | |
| | | robotMaxCount = IpyGameDataPY.GetFuncCfg("ArenaRobot", 1)
|
| | | __RandRobotLVList(robotMaxCount)
|
| | | GameWorld.Log(" PyGameData.g_arenaRobotLVList len=%s, %s" % (len(PyGameData.g_arenaRobotLVList), PyGameData.g_arenaRobotLVList))
|
| | | |
| | | billBoard = GameWorld.GetBillboard().FindBillboard(ShareDefine.Def_BT_Arena)
|
| | | if not billBoard:
|
| | | return
|
| | | |
| | | for index in xrange(billBoard.GetCount()):
|
| | | |
| | | order = index + 1
|
| | | billBoardData = billBoard.At(index)
|
| | | if not billBoardData:
|
| | | continue
|
| | | |
| | | playerID = billBoardData.GetID()
|
| | | fightPower = billBoardData.GetCmpValue2() # 旧战力只存在比较值2
|
| | | |
| | | if playerID <= MaxRobotID:
|
| | | curLV = GetArenaBillLV(billBoardData)
|
| | | updLV = curLV
|
| | | if index < len(PyGameData.g_arenaRobotLVList):
|
| | | updLV = PyGameData.g_arenaRobotLVList[index]
|
| | | GameWorld.Log(" 修正机器人等级: order=%s,playerID=%s,curLV=%s,updLV=%s" |
| | | % (order, playerID, curLV, updLV))
|
| | | SetArenaBillLV(billBoardData, updLV)
|
| | | SetArenaBillFightPower(billBoardData, 0)
|
| | | continue
|
| | | |
| | | curCache = PlayerViewCache.FindViewCache(playerID)
|
| | | if curCache:
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | fightPower = cacheDict["FightPower"]
|
| | | |
| | | SetArenaBillFightPower(billBoardData, fightPower)
|
| | | GameWorld.Log(" 修正真玩家战力: order=%s,playerID=%s,fightPower=%s,cmpValue2=%s,cmpValue3=%s" |
| | | % (order, playerID, fightPower, billBoardData.GetCmpValue2(), billBoardData.GetCmpValue3()))
|
| | | |
| | | billBoard.Sort()
|
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(repairStateKey, 1)
|
| | | GameWorld.Log("=== 修正竞技场榜单的战力数据 OK ===")
|
| | | return
|
| | |
|
| | | def OnServerStart():
|
| | | universalRecMgr = GameWorld.GetUniversalRecMgr()
|
| | | recDataList = universalRecMgr.GetTypeList(Def_RecType_ArenaBattleRecord)
|
| | |
| | | if billBoard.GetCount() > 0:
|
| | | robotMaxCount = IpyGameDataPY.GetFuncCfg("ArenaRobot", 1)
|
| | | PlayerBillboard.UpdateBillboardMaxCount(ShareDefine.Def_BT_Arena, robotMaxCount)
|
| | | __RandRobotLVList(robotMaxCount)
|
| | | else:
|
| | | __ResetArenaRobotBillboard()
|
| | | |
| | | RepairArenaBillboardFightPower()
|
| | | return
|
| | |
|
| | | def OnServerClose():
|
| | |
| | | GameWorld.Log(" 重置初始化竞技场机器人榜单! robotMaxCount=%s" % robotMaxCount)
|
| | | PlayerBillboard.UpdateBillboardMaxCount(ShareDefine.Def_BT_Arena, robotMaxCount)
|
| | |
|
| | | PyGameData.g_arenaRobotLVList = []
|
| | | worldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
|
| | | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ArenaWorldLV, worldLV)
|
| | | GameWorld.Log(" worldLV=%s" % worldLV)
|
| | | |
| | | # 获取机器人随机等级、积分列表
|
| | | robotLVList = __RandRobotLVList(robotMaxCount)
|
| | | robotScoreList = __RandRobotScoreList(robotMaxCount)
|
| | |
| | | value1 = robotRealmLV
|
| | | value2 = robotLV
|
| | | cmpValue = robotScore
|
| | | cmpValue2 = robotFightPower
|
| | | PlayerBillboard.UpdatePlayerBillboard(robotID, robotName, opInfo, ShareDefine.Def_BT_Arena, type2, value1, value2, cmpValue, autoSort=False, cmpValue2=cmpValue2)
|
| | | cmpValue2 = robotFightPower / ShareDefine.Def_PerPointValue
|
| | | cmpValue3 = robotFightPower % ShareDefine.Def_PerPointValue
|
| | | PlayerBillboard.UpdatePlayerBillboard(robotID, robotName, opInfo, ShareDefine.Def_BT_Arena, type2, value1, value2, cmpValue, autoSort=False, cmpValue2=cmpValue2, cmpValue3=cmpValue3)
|
| | |
|
| | | billBoard.Sort()
|
| | | return
|
| | |
| | |
|
| | | lvList[0] = robotMinLV
|
| | | lvList[-1] = robotMaxLV
|
| | | PyGameData.g_arenaRobotLVList = sorted(lvList, reverse=True)
|
| | | return lvList
|
| | |
|
| | | def __GetRobotLVRange():
|
| | | ## 获取赛季机器人等级范围
|
| | | worldLV = max(1, PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv))
|
| | | worldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ArenaWorldLV)
|
| | | worldLV = max(1, worldLV)
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | maxCnt = ipyDataMgr.GetWorldLVCount()
|
| | | worldLVTime = 0
|
| | |
| | | SetArenaBillRealmLV(billData, cacheDict["RealmLV"])
|
| | | SetArenaBillLV(billData, cacheDict["LV"])
|
| | | SetArenaBillFightPower(billData, cacheDict["FightPower"])
|
| | | else:
|
| | | if matchIndex < len(PyGameData.g_arenaRobotLVList):
|
| | | robotLV = PyGameData.g_arenaRobotLVList[matchIndex] # 同步更新机器人榜单变化等级
|
| | | SetArenaBillLV(billData, robotLV)
|
| | |
|
| | | matchPlayer.tagLV = GetArenaBillLV(billData)
|
| | | matchPlayer.tagJob = GetArenaBillJob(billData)
|
| | |
| | | curCache = PlayerViewCache.FindViewCache(matchInfo.PlayerID)
|
| | | if curCache:
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | fightPower = cacheDict["FightPower"]
|
| | | matchInfo.LV = cacheDict["LV"]
|
| | | matchInfo.PlayerName = cacheDict["Name"]
|
| | | matchInfo.RealmLV = cacheDict["RealmLV"]
|
| | | matchInfo.FightPower = cacheDict["FightPower"]
|
| | | |
| | | matchInfo.FightPower = fightPower % ShareDefine.Def_PerPointValue
|
| | | matchInfo.FightPowerEx = fightPower / ShareDefine.Def_PerPointValue
|
| | | else:
|
| | | # 此处机器人的暂忽略等级变化的同步,仅在刷新、更新积分时同步,此处省略查询机器人所属榜单排名
|
| | | pass
|
| | | |
| | | clientPack.MatchList.append(matchInfo)
|
| | | clientPack.MatchCount = len(clientPack.MatchList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | |
| | | retDict = {}
|
| | | retDict.update(cmdDict)
|
| | |
|
| | | accID = curPlayer.GetAccID()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("竞技场玩家战斗结果: %s" % str(cmdDict), playerID)
|
| | |
|
| | |
| | | curScore = playerScore
|
| | | isFindTag = False
|
| | | tagLV, tagJob, tagScore = 0, 0, 0
|
| | | tagRealmLV, tagFightPower, tagAccID = 0, 0, "" # 机器人无值
|
| | |
|
| | | # 先找匹配列表
|
| | | matchList = PyGameData.g_arenaPlayerMatchDict.get(playerID, [])
|
| | |
| | | # 结算自己
|
| | | addScore = __CalcBattleAddScore(playerID, curScore, tagScore, isWin)
|
| | | updScore = max(0, playerScore + addScore)
|
| | | GameWorld.DebugLog(" 更新自身积分: addScore=%s,updScore=%s" % (addScore, updScore), playerID)
|
| | |
|
| | | curOrder = billBoard.IndexOfByID(playerID) + 1 # 更新前获取名次
|
| | | cmpValue2 = fightPower / ShareDefine.Def_PerPointValue
|
| | | cmpValue3 = fightPower % ShareDefine.Def_PerPointValue
|
| | | PlayerBillboard.UpdatePlayerBillboard(playerID, playerName, opInfo, ShareDefine.Def_BT_Arena, playerJob,
|
| | | realmLV, playerLV, updScore, autoSort=False, cmpValue2=fightPower)
|
| | | realmLV, playerLV, updScore, autoSort=False, cmpValue2=cmpValue2, cmpValue3=cmpValue3)
|
| | |
|
| | | awardItemList = []
|
| | | if isWin:
|
| | |
| | | if isWorldNotify:
|
| | | PlayerControl.WorldNotify(0, "ArenaWinerItem", [curPlayer.GetName(), awardItemInfo[0], "", awardItemInfo[1]])
|
| | |
|
| | | tagAddScore = __CalcBattleAddScore(tagPlayerID, tagScore, curScore, not isWin)
|
| | | updTagScore = max(0, tagScore + tagAddScore)
|
| | | # 结算对手,仅玩家时结算,机器人不处理
|
| | | if tagPlayerID > MaxRobotID:
|
| | | tagAddScore = __CalcBattleAddScore(tagPlayerID, tagScore, curScore, not isWin)
|
| | | updTagScore = max(0, tagScore + tagAddScore)
|
| | | GameWorld.DebugLog(" 更新对手积分: tagAddScore=%s,updTagScore=%s" % (tagAddScore, updTagScore), playerID)
|
| | | tagCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | if tagCache:
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(tagCache)
|
| | | tagOpInfo = ""
|
| | | tagLV = cacheDict["LV"]
|
| | | tagPlayerName = cacheDict["Name"]
|
| | | tagRealmLV = cacheDict["RealmLV"]
|
| | | tagFightPower = cacheDict["FightPower"]
|
| | | tagAccID = cacheDict["AccID"]
|
| | | tagCmpValue2 = tagFightPower / ShareDefine.Def_PerPointValue
|
| | | tagCmpValue3 = tagFightPower % ShareDefine.Def_PerPointValue
|
| | | PlayerBillboard.UpdatePlayerBillboard(tagPlayerID, tagPlayerName, tagOpInfo, ShareDefine.Def_BT_Arena, tagJob,
|
| | | tagRealmLV, tagLV, updTagScore, autoSort=False, cmpValue2=tagFightPower)
|
| | | tagRealmLV, tagLV, updTagScore, autoSort=False, cmpValue2=tagCmpValue2, cmpValue3=tagCmpValue3)
|
| | | else:
|
| | | updTagScore = tagScore
|
| | | GameWorld.DebugLog(" 机器人对手,积分不变!updTagScore=%s" % updTagScore, playerID)
|
| | | |
| | | robotBillboardData = billBoard.FindByID(tagPlayerID)
|
| | | if robotBillboardData:
|
| | | SetArenaBillScore(robotBillboardData, updTagScore)
|
| | | |
| | | # 都更新完后排序一次
|
| | | billBoard.Sort()
|
| | | updOrder = billBoard.IndexOfByID(playerID) + 1 # 取最新名次
|
| | | GameWorld.DebugLog(" 更新自身积分: addScore=%s,updScore=%s,curOrder=%s,updOrder=%s" % (addScore, updScore, curOrder, updOrder), playerID)
|
| | | GameWorld.DebugLog(" 更新对手积分: tagPlayerID=%s,tagAddScore=%s,updTagScore=%s" % (tagPlayerID, tagAddScore, updTagScore), playerID)
|
| | | retDict.update({"addScore":addScore, "updScore":updScore, "curOrder":curOrder, "updOrder":updOrder,
|
| | | "awardItemList":awardItemList, "isOK":True})
|
| | |
|
| | | if tagPlayerID <= MaxRobotID:
|
| | | tagUpdOrder = billBoard.IndexOfByID(tagPlayerID) + 1 # 取最新名次
|
| | | tagOrderIndex = tagUpdOrder - 1
|
| | | if tagUpdOrder >= 1 and tagOrderIndex < len(PyGameData.g_arenaRobotLVList) and tagOrderIndex < billBoard.GetCount():
|
| | | GameWorld.DebugLog(" PyGameData.g_arenaRobotLVList=%s" % PyGameData.g_arenaRobotLVList, playerID)
|
| | | updRobotLV = PyGameData.g_arenaRobotLVList[tagOrderIndex]
|
| | | robotBillboardData = billBoard.At(tagOrderIndex)
|
| | | SetArenaBillLV(robotBillboardData, updRobotLV)
|
| | | GameWorld.DebugLog(" 机器人在榜上,更新等级信息! tagPlayerID=%s,tagUpdOrder=%s,updRobotLV=%s" % (tagPlayerID, tagUpdOrder, updRobotLV), playerID)
|
| | | else:
|
| | | GameWorld.DebugLog(" 机器人不在榜上,不更新等级信息! tagPlayerID=%s" % tagPlayerID, playerID)
|
| | | |
| | | battleRecMaxCount = min(MaxBattleRecCount, IpyGameDataPY.GetFuncCfg("ArenaSet", 4))
|
| | |
|
| | | # 插入对战记录
|
| | |
| | |
|
| | | # 对战结束,最后免费刷新一次匹配列表
|
| | | __DoArenaMatchRefresh(curPlayer, True, playerLV, updScore)
|
| | | |
| | | drDict = {"AccID":accID, "PlayerID":playerID, "playerLV":playerLV, "realmLV":realmLV, "fightPower":fightPower, "curScore":[curScore, addScore, updScore], |
| | | "TagAccID":tagAccID, "TagPlayerID":tagPlayerID, "tagLV":tagLV, "tagRealmLV":tagRealmLV, "tagFightPower":tagFightPower, |
| | | "tagScore":[tagScore, tagAddScore, updTagScore], "isWin":isWin}
|
| | | DataRecordPack.SendEventPack("ArenaBattleResult", drDict)
|
| | | return retDict
|
| | |
|
| | | def __SyncPlayerBechallengedUpdScore(curPlayer, updScore):
|
| | |
| | | recInfo.PlayerID = battleRec.tagPlayerID
|
| | | recInfo.Job = battleRec.tagJob
|
| | | recInfo.LV = battleRec.tagLV
|
| | | recInfo.Score = battleRec.tagScore
|
| | | recInfo.AddScore = str(battleRec.addScore)
|
| | | recInfo.AddScoreLen = len(recInfo.AddScore)
|
| | | recInfo.IsWin = battleRec.isWin
|
| | |
| | | curCache = PlayerViewCache.FindViewCache(recInfo.PlayerID)
|
| | | if curCache:
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | fightPower = cacheDict["FightPower"]
|
| | | recInfo.LV = cacheDict["LV"]
|
| | | recInfo.PlayerName = cacheDict["Name"]
|
| | | recInfo.RealmLV = cacheDict["RealmLV"]
|
| | | recInfo.FightPower = cacheDict["FightPower"]
|
| | | recInfo.FightPower = fightPower % ShareDefine.Def_PerPointValue
|
| | | recInfo.FightPowerEx = fightPower / ShareDefine.Def_PerPointValue
|
| | |
|
| | | clientPack.BattleRecordList.append(recInfo)
|
| | |
|
| | |
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | #// A9 A5 查看竞技场对战玩家最新信息 #tagCGQueryArenaBattlePlayer
|
| | | #
|
| | | #struct tagCGQueryArenaBattlePlayer
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD PlayerID; //目标玩家ID,仅支持查真实玩家
|
| | | #};
|
| | | def OnQueryArenaBattlePlayer(index, clientData, tick):
|
| | | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | if not curPlayer:
|
| | | return
|
| | | |
| | | tagPlayerID = clientData.PlayerID
|
| | | tagBattleRecList = GetPlayerArenaBattleRecList(tagPlayerID)
|
| | | if not tagBattleRecList:
|
| | | GameWorld.ErrLog("竞技场玩家无对战记录,无法查询最新数据! tagPlayerID=%s" % tagPlayerID, curPlayer.GetPlayerID())
|
| | | return
|
| | | tagBattleRec = tagBattleRecList[-1] # 取最后一条为最新数据
|
| | | tagScore = tagBattleRec.updScore
|
| | | |
| | | clientPack = ChPyNetSendPack.tagGCArenaBattlePlayerInfo()
|
| | | clientPack.PlayerID = tagPlayerID
|
| | | clientPack.Score = tagScore
|
| | | |
| | | curCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | if curCache:
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | fightPower = cacheDict["FightPower"]
|
| | | clientPack.LV = cacheDict["LV"]
|
| | | clientPack.Job = cacheDict["Job"]
|
| | | clientPack.PlayerName = cacheDict["Name"]
|
| | | clientPack.RealmLV = cacheDict["RealmLV"]
|
| | | clientPack.FightPower = fightPower % ShareDefine.Def_PerPointValue
|
| | | clientPack.FightPowerEx = fightPower / ShareDefine.Def_PerPointValue
|
| | | |
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|