hxp
2020-01-07 26534f375db82568cf5e29e74fd5a58cf71ce20f
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
@@ -242,23 +242,6 @@
        if not CheckHavePKCount(curPlayer):
            return
        
        danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)
        danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
        if not danIpyData:
            return
        cLoseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount)
        matchRobotRate = danIpyData.GetMatchRobotRate() + danIpyData.GetMatchRobotRateEx() * cLoseCount
        isMatchRobot = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_IsMatchRobot)
        GameWorld.Log("isMatchRobot=%s,danLV=%s,cLoseCount=%s,匹配机器人概率=%s" % (isMatchRobot, danLV, cLoseCount, matchRobotRate), playerID)
        if isMatchRobot or (matchRobotRate and GameWorld.CanHappen(matchRobotRate, 100)):
            GameWorld.Log("    本次匹配到机器人!", playerID)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 1)
            startMatchPack = ChPyNetSendPack.tagGCCrossRealmPKStartMatch()
            startMatchPack.IsRobot = 1
            NetPackCommon.SendFakePack(curPlayer, startMatchPack)
            return
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 0)
        dataMsg = {
                   "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
                   "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
@@ -274,6 +257,7 @@
                   "pkScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore), # 当前积分
                   "danLV":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV), # 当前段位
                   "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount), # 连胜次数
                   "cLoseCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount), # 连败次数
                   "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore), # 过天时的积分
                   }
        GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKMatch, dataMsg)
@@ -351,7 +335,6 @@
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 0)
    
    pkCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_PKCount) + 1
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, pkCount)
@@ -398,88 +381,19 @@
    playerID = curPlayer.GetPlayerID()
    isWinner = clientData.IsWin
    
    if GameWorld.IsCrossServer():
        GameWorld.DebugLog("跨服服务器无法发起机器人结算!", playerID)
        return
    if not CheckHavePKCount(curPlayer):
        return
    
    isMatchRobot = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_IsMatchRobot)
    if not isMatchRobot:
        GameWorld.DebugLog("当前不允许结算跨服匹配机器人!IsMatchRobot=%s" % isMatchRobot, playerID)
        return
    zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
    seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
    pkScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)
    danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)
    cWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount)
    if GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState) != 1:
        GameWorld.Log("OnCrossRealmPKRobotOver 跨服赛季未开启,不可进行机器人结算!", playerID)
        overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
        overPack.AddScore = 0
        overPack.Score = pkScore
        overPack.DanLV = danLV
        overPack.CWinCnt = cWinCount
        NetPackCommon.SendFakePack(curPlayer, overPack)
        return
    ondayScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore)
    dayScore = max(0, pkScore - ondayScore) # 今日已获得积分,正积分
    baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKScore", 2) # 胜负保底分
    wBaseScore = baseScoreList[0] if len(baseScoreList) > 0 else 0
    lBaseScore = baseScoreList[1] if len(baseScoreList) > 1 else 0
    wExScore = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKScore", 3)) # 胜方附加分
    lExScore = 0
    if isWinner:
        addScore = wBaseScore + wExScore
        cWinCount += 1
    else:
        addScore = lBaseScore + lExScore
        cWinCount = 0
    dayMaxScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore", 1) # 每日获得积分上限,0为不限制
    if dayMaxScore and addScore:
        addScore = min(dayMaxScore - dayScore, addScore)
    GameWorld.Log("机器人跨服PK结算: isWinner=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s"
                  % (isWinner, zoneID, seasonID, pkScore, danLV, cWinCount, addScore), playerID)
    pkScore += addScore
    winIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
    if winIpyData and winIpyData.GetLVUpScore() and pkScore >= winIpyData.GetLVUpScore():
        danLV += 1
    isToday = True # 机器人结算的默认当天
    if not __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):
        return
    # 只同步以下信息,其他信息前端自行补全
    overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
    overPack.AddScore = addScore
    overPack.Score = pkScore
    overPack.DanLV = danLV
    overPack.CWinCnt = cWinCount
    NetPackCommon.SendFakePack(curPlayer, overPack)
    # 如果能上榜的,则通知跨服更新榜单积分数据
    billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
    if billboardCfg and len(billboardCfg) > 1 or danLV >= billboardCfg[1]:
        dataMsg = {
                   "seasonID":seasonID,
                   "pkZoneID":zoneID,
                   "accID":curPlayer.GetAccID(),
                   "playerID":playerID,
                   "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
                   "playerJob":curPlayer.GetJob(),
                   "fightPower":curPlayer.GetFightPower(),
                   "realmLV":curPlayer.GetOfficialRank(),
                   "pkScore":pkScore,
                   "danLV":danLV,
                   }
        GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKScore, dataMsg)
        GameWorld.Log("    更新积分到跨服服务器 dataMsg=%s" % str(dataMsg), playerID)
    dataMsg = {
               "playerID":playerID,
               "isWinner":isWinner,
               }
    GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKRobotOver, dataMsg)
    GameWorld.Log("同步跨服服务器与机器人PK结算: %s" % str(dataMsg), playerID)
    return