ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldArena.py
@@ -57,6 +57,8 @@
        self.tagLV = 0
        self.tagJob = 0
        self.tagScore = 0
        self.tagFace = 0
        self.tagFacePic = 0
        return
    
class ArenaBattleRec():
@@ -74,6 +76,8 @@
        self.tagPlayerID = 0 # 小于10000的为机器人ID
        self.tagLV = 0
        self.tagJob = 0
        self.tagFace = 0
        self.tagFacePic = 0
        self.tagScore = 0
        
        self.addScore = 0
@@ -92,6 +96,7 @@
value4        tagScore        目标积分,非实时积分,一般机器人时有用
strValue1    resultInfo    isWin,addScore
strValue2    updInfo    isDispose,updScore
strValue3    faceInfo    face,facePic
'''
''' 榜单数据 '''
@@ -103,70 +108,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():
@@ -194,6 +145,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)
        
@@ -216,7 +172,6 @@
            else:
                __ResetArenaRobotBillboard()
                
    RepairArenaBillboardFightPower()
    return
def OnServerClose():
@@ -237,6 +192,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
@@ -598,7 +554,7 @@
        return
    tagPlayerID = valueList[0]
    
    isFindTag, tagLV, tagJob, tagScore = __findBattleTag(playerID, tagPlayerID)
    isFindTag, tagLV, tagJob, tagScore, tagFace, tagFacePic = __findBattleTag(playerID, tagPlayerID)
    if not isFindTag:
        GameWorld.ErrLog("找不到对战对手,不在匹配列表或对战记录里!不能战斗!tagPlayerID=%s" % tagPlayerID, playerID)
        return
@@ -833,6 +789,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] # 同步更新机器人榜单变化等级
@@ -841,6 +799,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)
@@ -872,6 +832,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:
@@ -885,6 +847,7 @@
                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
@@ -898,14 +861,14 @@
    ## 检查查找要战斗的对象是否合法
    
    isFindTag = False
    tagLV, tagJob, tagScore = 0, 0, 0
    tagLV, tagJob, tagScore, tagFace, tagFacePic = 0, 0, 0, 0, 0
        
    # 先找匹配列表
    matchList = PyGameData.g_arenaPlayerMatchDict.get(playerID, [])
    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
        
@@ -915,11 +878,11 @@
        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
            
    return isFindTag, tagLV, tagJob, tagScore
    return isFindTag, tagLV, tagJob, tagScore, tagFace, tagFacePic
def __DoArenaBattleResult(curPlayer, cmdDict):
    ## 地图玩家同步战斗结果
@@ -952,7 +915,7 @@
    curScore = playerScore
    tagRealmLV, tagFightPower, tagAccID = 0, 0, "" # 机器人无值
    
    isFindTag, tagLV, tagJob, tagScore = __findBattleTag(playerID, tagPlayerID)
    isFindTag, tagLV, tagJob, tagScore, tagFace, tagFacePic = __findBattleTag(playerID, tagPlayerID)
    if not isFindTag:
        GameWorld.ErrLog("找不到对战对手,不在匹配列表或对战记录里!不处理结算!tagPlayerID=%s" % tagPlayerID, playerID)
        return retDict
@@ -986,8 +949,10 @@
    curOrder = billBoard.IndexOfByID(playerID) + 1  # 更新前获取名次
    cmpValue2 = fightPower / ShareDefine.Def_PerPointValue
    cmpValue3 = fightPower % ShareDefine.Def_PerPointValue
    face = curPlayer.GetFace()
    facePic =  curPlayer.GetFacePic()
    PlayerBillboard.UpdatePlayerBillboard(playerID, playerName, opInfo, ShareDefine.Def_BT_Arena, playerJob,
                                          realmLV, playerLV, updScore, autoSort=False, cmpValue2=cmpValue2, cmpValue3=cmpValue3)
                                          realmLV, playerLV, updScore, autoSort=False, cmpValue2=cmpValue2, cmpValue3=cmpValue3, value3=face, value4=facePic)
    
    awardItemList = []
    if isWin:
@@ -1014,8 +979,10 @@
            tagAccID = cacheDict["AccID"]
            tagCmpValue2 = tagFightPower / ShareDefine.Def_PerPointValue
            tagCmpValue3 = tagFightPower % ShareDefine.Def_PerPointValue
            tagFace = cacheDict.get("Face", 0)
            tagFacePic = cacheDict.get("FacePic", 0)
            PlayerBillboard.UpdatePlayerBillboard(tagPlayerID, tagPlayerName, tagOpInfo, ShareDefine.Def_BT_Arena, tagJob,
                                                  tagRealmLV, tagLV, updTagScore, autoSort=False, cmpValue2=tagCmpValue2, cmpValue3=tagCmpValue3)
                                                  tagRealmLV, tagLV, updTagScore, autoSort=False, cmpValue2=tagCmpValue2, cmpValue3=tagCmpValue3, value3=tagFace, value4=tagFacePic)
    else:
        robotBillboardData = billBoard.FindByID(tagPlayerID)
        if robotBillboardData:
@@ -1055,6 +1022,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:]
@@ -1073,6 +1042,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:]
@@ -1159,6 +1130,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)