ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
@@ -177,6 +177,7 @@
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CLoseCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)
@@ -238,17 +239,9 @@
    
    # 进行匹配
    if requestType == 1:
        dayFreeMatchCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 1)
        if dayFreeMatchCountMax:
            todayPKCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)
            todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)
            todayItemAddCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)
            if todayPKCount >= (dayFreeMatchCountMax + todayBuyCount + todayItemAddCount):
                GameWorld.DebugLog("PK次数不足,无法发起匹配! todayPKCount=%s >= (dayFreeMatchCountMax=%s + todayBuyCount=%s + todayItemAddCount=%s)"
                                   % (todayPKCount, dayFreeMatchCountMax, todayBuyCount, todayItemAddCount), playerID)
                return
        if not CheckHavePKCount(curPlayer):
            return
        dataMsg = {
                   "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
                   "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
@@ -264,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)
@@ -277,6 +271,20 @@
        
    return
def CheckHavePKCount(curPlayer):
    ## 检查是否有PK次数
    dayFreeMatchCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 1)
    if dayFreeMatchCountMax:
        todayPKCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)
        todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)
        todayItemAddCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)
        if todayPKCount >= (dayFreeMatchCountMax + todayBuyCount + todayItemAddCount):
            GameWorld.DebugLog("PK次数不足,无法发起匹配! todayPKCount=%s >= (dayFreeMatchCountMax=%s + todayBuyCount=%s + todayItemAddCount=%s)"
                               % (todayPKCount, dayFreeMatchCountMax, todayBuyCount, todayItemAddCount), curPlayer.GetPlayerID())
            return False
    return True
def CrossServerMsg_PKOverInfo(curPlayer, overInfo):
    ## 收到跨服服务器的PK结算信息
    playerID = curPlayer.GetPlayerID()
@@ -284,6 +292,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)
@@ -309,13 +343,16 @@
        winCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_WinCount) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, winCount)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, cWinCount)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CLoseCount, 0)
        GameWorld.Log("    winner winCount=%s,cWinCount=%s" % (winCount, cWinCount), playerID)
    else:
        cLoseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CLoseCount, cLoseCount)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, 0)
        GameWorld.Log("    loser cWinCount=0", playerID)
        GameWorld.Log("    loser cLoseCount=%s" % cLoseCount, 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 +367,33 @@
        GameWorld.Log("    不同天的PK结算不增加今日PK次数! ", playerID)
        
    SyncCrossRealmPKPlayerInfo(curPlayer)
    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
    
    ## 跨服已经通知过了,证明还在跨服服务器,不做以下的处理
    if notifyState:
    if GameWorld.IsCrossServer():
        GameWorld.DebugLog("跨服服务器无法发起机器人结算!", playerID)
        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)
    if not CheckHavePKCount(curPlayer):
        return
    dataMsg = {
               "playerID":playerID,
               "isWinner":isWinner,
               }
    GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKRobotOver, dataMsg)
    GameWorld.Log("同步跨服服务器与机器人PK结算: %s" % str(dataMsg), playerID)
    return
@@ -370,8 +416,15 @@
    if not dayFreeMatchCountMax:
        GameWorld.DebugLog("每日匹配次数没有限制,不需要购买次数!", playerID)
        return
    dayBuyCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 2)
    todayPKCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)
    todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)
    todayItemAddCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)
    canPKCount = dayFreeMatchCountMax + todayBuyCount + todayItemAddCount - todayPKCount
    if canPKCount >= dayFreeMatchCountMax:
        GameWorld.DebugLog("可PK次数不能大于每日免费次数!", playerID)
        return
    dayBuyCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 2)
    #todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)
    if dayBuyCountMax and todayBuyCount >= dayBuyCountMax:
        GameWorld.DebugLog("今日购买次数已满,无法购买!todayBuyCount=%s" % (todayBuyCount), playerID)
        return
@@ -513,7 +566,7 @@
                       % (awardType, awardData, awardIndex, awardState, awardItemList), playerID)
    drDataDict.update({"awardIndex":awardIndex, "awardState":awardState, "awardItemList":awardItemList})
    for itemID, itemCnt, isBind in awardItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem])
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
        
    if awardType == 3:
        PlayerControl.WorldNotify(0, "CrossMatching22", [curPlayer.GetPlayerName(), awardDanLV])
@@ -636,7 +689,7 @@
        PlayerControl.SendMailByKey(mailTypeKey, [playerID], awardItemList, mailParamList, detail=mailDetail)
    else:
        for itemID, itemCnt, isBind in awardItemList:
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind, [IPY_GameWorld.rptItem])
            ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
            
    GameWorld.Log("领取成功! awardItemList=%s" % (awardItemList), playerID)
    drDataDict = {"awardItemList":awardItemList, "order":order, "danLV":danLV, "seasonAwardLV":seasonAwardLV, "isMail":isMail}