ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldArena.py
@@ -56,6 +56,8 @@
        self.tagLV = 0
        self.tagJob = 0
        self.tagScore = 0
        self.tagFace = 0
        self.tagFacePic = 0
        return
    
class ArenaBattleRec():
@@ -73,6 +75,8 @@
        self.tagPlayerID = 0 # 小于10000的为机器人ID
        self.tagLV = 0
        self.tagJob = 0
        self.tagFace = 0
        self.tagFacePic = 0
        self.tagScore = 0
        
        self.addScore = 0
@@ -91,6 +95,7 @@
value4        tagScore        目标积分,非实时积分,一般机器人时有用
strValue1    resultInfo    isWin,addScore
strValue2    updInfo    isDispose,updScore
strValue3    faceInfo    face,facePic
'''
''' 榜单数据 '''
@@ -102,70 +107,16 @@
def SetArenaBillRealmLV(billData, realmLV): return billData.SetValue1(realmLV)
def GetArenaBillLV(billData): return billData.GetValue2()
def SetArenaBillLV(billData, lv): billData.SetValue2(lv)
def GetArenaBillFace(billData): return billData.GetValue3()
def SetArenaBillFace(billData, face): billData.SetValue3(face)
def GetArenaBillFacePic(billData): return billData.GetValue4()
def SetArenaBillFacePic(billData, facePic): billData.SetValue4(facePic)
def GetArenaBillScore(billData): return billData.GetCmpValue()
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():
@@ -193,6 +144,11 @@
        battleRec.isDispose = int(updInfo[0] if len(updInfo) > 0 else 0)
        battleRec.updScore = int(updInfo[1] if len(updInfo) > 1 else 0)
        
        strValue3 = recData.GetStrValue3()
        faceInfo = strValue3.split(",") if strValue3 else []
        battleRec.tagFace = int(faceInfo[0] if len(faceInfo) > 0 else 0)
        battleRec.tagFacePic = int(faceInfo[1] if len(faceInfo) > 1 else 0)
        battleRecList = GetPlayerArenaBattleRecList(playerID)
        battleRecList.append(battleRec)
        
@@ -215,7 +171,6 @@
            else:
                __ResetArenaRobotBillboard()
                
    RepairArenaBillboardFightPower()
    return
def OnServerClose():
@@ -236,6 +191,7 @@
            
            recData.SetStrValue1("%s,%s" % (int(battleRec.isWin), battleRec.addScore))
            recData.SetStrValue2("%s,%s" % (int(battleRec.isDispose), battleRec.updScore))
            recData.SetStrValue3("%s,%s" % (battleRec.tagFace, battleRec.tagFacePic))
            
    return
@@ -795,6 +751,8 @@
                        SetArenaBillRealmLV(billData, cacheDict["RealmLV"])
                        SetArenaBillLV(billData, cacheDict["LV"])
                        SetArenaBillFightPower(billData, cacheDict["FightPower"])
                        SetArenaBillFace(billData, cacheDict.get("Face", 0))
                        SetArenaBillFacePic(billData, cacheDict.get("FacePic", 0))
                else:
                    if matchIndex < len(PyGameData.g_arenaRobotLVList):
                        robotLV = PyGameData.g_arenaRobotLVList[matchIndex] # 同步更新机器人榜单变化等级
@@ -803,6 +761,8 @@
                matchPlayer.tagLV = GetArenaBillLV(billData)
                matchPlayer.tagJob = GetArenaBillJob(billData)
                matchPlayer.tagScore = GetArenaBillScore(billData)
                matchPlayer.tagFace = GetArenaBillFace(billData)
                matchPlayer.tagFacePic = GetArenaBillFacePic(billData)
                
                GameWorld.DebugLog("    %s 匹配在榜单上的: tagPlayerID=%s,tagLV=%s,tagScore=%s,matchOrder=%s" 
                                   % (i + 1, matchPlayer.tagPlayerID, matchPlayer.tagLV, matchPlayer.tagScore, matchOrder), playerID)
@@ -834,6 +794,8 @@
        matchInfo.Job = matchPlayer.tagJob
        matchInfo.LV = matchPlayer.tagLV
        matchInfo.Score = matchPlayer.tagScore
        matchInfo.Face = matchPlayer.tagFace
        matchInfo.FacePic = matchPlayer.tagFacePic
        
        # 玩家读取额外信息, 机器人其他信息不处理,这里直接读最新的查看缓存,防止刷新不及时(并不是实时数据,只是相对实时,前端可自行控制刷新频率)
        if matchInfo.PlayerID > MaxRobotID:
@@ -846,6 +808,8 @@
                matchInfo.RealmLV = cacheDict["RealmLV"]
                matchInfo.FightPower = fightPower % ShareDefine.Def_PerPointValue
                matchInfo.FightPowerEx = fightPower / ShareDefine.Def_PerPointValue
                matchInfo.Face = cacheDict.get("Face", 0)
                matchInfo.FacePic = cacheDict.get("FacePic", 0)
        else:
            # 此处机器人的暂忽略等级变化的同步,仅在刷新、更新积分时同步,此处省略查询机器人所属榜单排名
            pass
@@ -885,7 +849,7 @@
   
    curScore = playerScore
    isFindTag = False
    tagLV, tagJob, tagScore = 0, 0, 0
    tagLV, tagJob, tagScore, tagFace, tagFacePic = 0, 0, 0, 0, 0
    tagRealmLV, tagFightPower, tagAccID = 0, 0, "" # 机器人无值
    
    # 先找匹配列表
@@ -893,7 +857,7 @@
    for matchPlayer in matchList:
        if matchPlayer.tagPlayerID == tagPlayerID:
            isFindTag = True
            tagLV, tagJob, tagScore = matchPlayer.tagLV, matchPlayer.tagJob, matchPlayer.tagScore
            tagLV, tagJob, tagScore, tagFace, tagFacePic = matchPlayer.tagLV, matchPlayer.tagJob, matchPlayer.tagScore, matchPlayer.tagFace, matchPlayer.tagFacePic
            GameWorld.DebugLog("    对手在匹配列表中! tagLV=%s, tagJob=%s, tagScore=%s" % (tagLV, tagJob, tagScore), playerID)
            break
        
@@ -903,7 +867,7 @@
        for battleRec in curBattleRecList:
            if battleRec.tagPlayerID == tagPlayerID:
                isFindTag = True
                tagLV, tagJob, tagScore = battleRec.tagLV, battleRec.tagJob, battleRec.tagScore
                tagLV, tagJob, tagScore, tagFace, tagFacePic = battleRec.tagLV, battleRec.tagJob, battleRec.tagScore, battleRec.tagFace, battleRec.tagFacePic
                GameWorld.DebugLog("    对手在对战记录中! tagLV=%s, tagJob=%s, tagScore=%s" % (tagLV, tagJob, tagScore), playerID)
                break
            
@@ -1012,6 +976,8 @@
    battleRec.addScore = addScore
    battleRec.isDispose = 1
    battleRec.updScore = updScore
    battleRec.tagFace = tagFace
    battleRec.tagFacePic = tagFacePic
    curBattleRecList.append(battleRec)
    if len(curBattleRecList) > battleRecMaxCount:
        curBattleRecList = curBattleRecList[len(curBattleRecList) - battleRecMaxCount:]
@@ -1030,6 +996,8 @@
        tagBattleRec.addScore = tagAddScore
        tagBattleRec.isDispose = 1 if tagOnline else 0
        tagBattleRec.updScore = updTagScore
        tagBattleRec.tagFace = face
        tagBattleRec.tagFacePic = facePic
        tagBattleRecList.append(tagBattleRec)
        if len(tagBattleRecList) > battleRecMaxCount:
            tagBattleRecList = tagBattleRecList[len(tagBattleRecList) - battleRecMaxCount:]
@@ -1116,6 +1084,8 @@
        recInfo.AddScoreLen = len(recInfo.AddScore)
        recInfo.IsWin = battleRec.isWin
        recInfo.Time = battleRec.battleTime
        recInfo.Face = battleRec.tagFace
        recInfo.FacePic = battleRec.tagFacePic
        
        if recInfo.PlayerID > MaxRobotID:
            curCache = PlayerViewCache.FindViewCache(recInfo.PlayerID)