hxp
2019-02-12 4551dd1308ab484688ca96be2be8b811fd3a23e6
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
@@ -284,6 +284,32 @@
    isWinner = winnerID == playerID
    GameWorld.Log("地图收到跨服PK结算: isWinner=%s,roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s" 
                  % (isWinner, roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState), playerID)
    isToday = GameWorld.CheckTimeIsSameServerDayEx(GameWorld.ChangeTimeStrToNum(timeStr))
    if not __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):
        return
    ## 跨服已经通知过了,证明还在跨服服务器,不做以下的处理
    if notifyState:
        return
    overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
    overPack.TimeStr = timeStr
    overPack.OverType = overType
    overPack.WinnerID = winnerID
    overPack.RoundWinnerID = roundWinnerIDList
    overPack.RoundCount = len(overPack.RoundWinnerID)
    overPack.AddScore = addScore
    overPack.Score = pkScore
    overPack.DanLV = danLV
    overPack.CWinCnt = cWinCount
    overPack.TagName = tagPlayerName
    overPack.TagNameLen = len(overPack.TagName)
    NetPackCommon.SendFakePack(curPlayer, overPack)
    return
def __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):
    playerID = curPlayer.GetPlayerID()
    curSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
    if curSeasonID != seasonID:
        GameWorld.Log("    非本赛季的结算信息,不处理!curSeasonID=%s,seasonID=%s" % (curSeasonID, seasonID), playerID)
@@ -315,7 +341,7 @@
        GameWorld.Log("    loser cWinCount=0", playerID)
        
    # 同一天的话增加当日PK次数
    if GameWorld.CheckTimeIsSameServerDayEx(GameWorld.ChangeTimeStrToNum(timeStr)):
    if isToday:
        todayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, todayPKCount)
        GameWorld.Log("    同一天的PK结算增加今日PK次数: todayPKCount=%s" % todayPKCount, playerID)
@@ -330,24 +356,74 @@
        GameWorld.Log("    不同天的PK结算不增加今日PK次数! ", playerID)
        
    SyncCrossRealmPKPlayerInfo(curPlayer)
    ## 跨服已经通知过了,证明还在跨服服务器,不做以下的处理
    if notifyState:
    return True
#// C1 08 跨服PK挑战机器人结算 #tagCMCrossRealmPKRobotOver
#
#struct    tagCMCrossRealmPKRobotOver
#{
#    tagHead        Head;
#    BYTE        IsWin;    //是否获胜
#};
def OnCrossRealmPKRobotOver(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    isWinner = clientData.IsWin
    billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
    if not billboardCfg or len(billboardCfg) != 2:
        GameWorld.ErrLog("跨服竞技场排行榜配置错误!")
        return
    danLVLimit = billboardCfg[1]
    playerDanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)
    #策划设计该机器人目的为了前期体验,这里只验证是否超过上榜段位即可,即使作弊也不管,只要有次数即可
    if playerDanLV >= danLVLimit:
        GameWorld.ErrLog("该段位不允许与机器人匹配PK!playerDanLV=%s,danLVLimit=%s" % (playerDanLV, danLVLimit), 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)
    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
    # 只同步以下信息,其他信息前端自行补全
    overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
    overPack.TimeStr = timeStr
    overPack.OverType = overType
    overPack.WinnerID = winnerID
    overPack.RoundWinnerID = roundWinnerIDList
    overPack.RoundCount = len(overPack.RoundWinnerID)
    overPack.AddScore = addScore
    overPack.Score = pkScore
    overPack.DanLV = danLV
    overPack.CWinCnt = cWinCount
    overPack.TagName = tagPlayerName
    overPack.TagNameLen = len(overPack.TagName)
    NetPackCommon.SendFakePack(curPlayer, overPack)
    isToday = True # 机器人结算的默认当天
    __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday)
    return