#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerCrossRealmPK
|
#
|
# @todo:¿ç·þPK¾º¼¼³¡
|
# @author hxp
|
# @date 2018-12-21
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þPK¾º¼¼³¡
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2018-12-21 18:00"""
|
#-------------------------------------------------------------------------------
|
|
import ShareDefine
|
import PlayerControl
|
import CrossRealmPlayer
|
import ChPyNetSendPack
|
import NetPackCommon
|
import GameWorld
|
import ChConfig
|
|
def DoPlayerOnDay(curPlayer):
|
totalScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, totalScore)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)
|
return
|
|
def IsCrossRealmPKOpen():
|
## ¿ç·þPKÆ¥ÅäÈüÊÇ·ñ¿ªÆô
|
return 1
|
return GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MergePKState) == ChConfig.Def_Action_Open
|
|
def GetCrossPKZoneID():
|
## »ñÈ¡±¾·þ¿ç·þPKËùÊôÈüÇø
|
return 1
|
|
def GetSeasonID():
|
## »ñÈ¡µ±Ç°Èü¼¾ID
|
return 1
|
|
def IsCrossRealmPKSeasonOpen():
|
return True
|
|
#// C1 01 ¿ç·þPKÆ¥Åä #tagCMCrossRealmPKMatch
|
#
|
#struct tagCMCrossRealmPKMatch
|
#{
|
# tagHead Head;
|
# BYTE Type; // 0-È¡ÏûÆ¥Åä; 1-½øÐÐÆ¥Åä
|
#};
|
def OnCrossRealmPKMatch(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
accID = curPlayer.GetAccID()
|
playerID = curPlayer.GetPlayerID()
|
requestType = clientData.Type
|
|
if GameWorld.IsCrossServer():
|
return
|
|
if not IsCrossRealmPKOpen():
|
GameWorld.Log("OnRequestMergePK ¿ç·þ»î¶¯Î´¿ªÆô£¬²»¿É½øÐÐÆ¥Å䣡", playerID)
|
PlayerControl.NotifyCode(curPlayer, "GeRen_hgg_21675")
|
return
|
|
GameWorld.Log("ÊÕµ½¿ç·þPKÆ¥Åä: type=%s,accID=%s" % (requestType, accID), playerID)
|
|
# ½øÐÐÆ¥Åä
|
if requestType == 1:
|
# pkCnt = __GetMergePKPDictValue(curPlayer, ChConfig.Def_PDict_MergePK_Cnt)
|
# buyCnt = __GetMergePKPDictValue(curPlayer, ChConfig.Def_PDict_MergePK_BuyCnt)
|
# unUsedBuyCnt = __GetMergePKPDictValue(curPlayer, ChConfig.Def_PDict_MergePK_UnUsedBuyCnt)
|
# freeCnt, maxBuyCnt, moneyType, buyCostFormat = ReadChConfig.GetEvalChConfig("MergePK_BuyCost")
|
#
|
# # ³¬³öÃâ·Ñ´ÎÊý ÇÒ ÎÞ¿ÉÓõÄÒѹºÂò´ÎÊý ÔòÐ蹺Âò´ÎÊý
|
# if pkCnt >= freeCnt and unUsedBuyCnt <= 0:
|
#
|
# if buyCnt >= maxBuyCnt:
|
# GameWorld.Log(" ÒÑ´ïµ½×î´ó¿É¹ºÂòPK´ÎÊý£¬²»¿ÉÔÙÂò£¡:buyCnt=%s,maxBuyCnt=%s,pkCnt=%s,unUsedBuyCnt=%s"
|
# % (buyCnt, maxBuyCnt, pkCnt, unUsedBuyCnt), playerID)
|
# return
|
#
|
# buyCost = eval(buyCostFormat)
|
# infoDict = {"pkCnt":pkCnt, "freeCnt":freeCnt, "buyCnt":buyCnt, "buyCost":buyCost}
|
# if not PlayerControl.PayMoney(curPlayer, moneyType, buyCost, ChConfig.Def_Cost_BuyMergePKCnt, infoDict):
|
# return
|
#
|
# # Ôö¼Ó¹ºÂò´ÎÊý ¼° δʹÓõĹºÂò´ÎÊý
|
# __SetMergePKPDictValue(curPlayer, ChConfig.Def_PDict_MergePK_BuyCnt, buyCnt + 1)
|
# __SetMergePKPDictValue(curPlayer, ChConfig.Def_PDict_MergePK_UnUsedBuyCnt, unUsedBuyCnt + 1)
|
# Sync_MergePKCnt(curPlayer)
|
#
|
# GameWorld.Log(" ¹ºÂòPK´ÎÊýÏûºÄ: pkCnt=%s,freeCnt=%s,buyCnt=%s,moneyType=%s,buyCost=%s"
|
# % (pkCnt, freeCnt, buyCnt, moneyType, buyCost), playerID)
|
|
dataMsg = {
|
"seasonID":GetSeasonID(), # Èü¼¾ID
|
"pkZoneID":GetCrossPKZoneID(), # PKÈüÇø
|
"accID":accID,
|
"playerID":playerID,
|
"playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
|
"playerJob":curPlayer.GetJob(),
|
"playerLV":curPlayer.GetLV(),
|
"maxHP":curPlayer.GetMaxHP(),
|
"fightPower":curPlayer.GetFightPower(),
|
"pkScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore), # µ±Ç°»ý·Ö
|
"danLV":1, #curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV), # µ±Ç°¶Îλ
|
"cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount), # Á¬Ê¤´ÎÊý
|
"ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore), # ¹ýÌìʱµÄ»ý·Ö
|
}
|
GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKMatch, dataMsg)
|
GameWorld.Log(" ·¢ËÍÇëÇóÆ¥Åäµ½¿ç·þ·þÎñÆ÷ dataMsg=%s" % str(dataMsg), playerID)
|
|
# È¡ÏûÆ¥Åä
|
else:
|
sendMsg = "Client Cancel!"
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "CrossRealmPKCancel", sendMsg, len(sendMsg))
|
GameWorld.Log(" ·¢ËÍÈ¡ÏûÆ¥Åäµ½GameServer sendMsg=%s" % str(sendMsg), playerID)
|
|
return
|
|
def CrossServerMsg_PKOverInfo(curPlayer, overInfo):
|
## ÊÕµ½¿ç·þ·þÎñÆ÷µÄPK½áËãÐÅÏ¢
|
playerID = curPlayer.GetPlayerID()
|
roomID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState = overInfo
|
isWinner = winnerID == playerID
|
GameWorld.Log("µØÍ¼ÊÕµ½¿ç·þPK½áËã: isWinner=%s,roomID=%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, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState), playerID)
|
curSeasonID = GetSeasonID()
|
if curSeasonID != seasonID:
|
GameWorld.Log(" ·Ç±¾Èü¼¾µÄ½áËãÐÅÏ¢£¬²»´¦Àí£¡curSeasonID=%s,seasonID=%s" % (curSeasonID, seasonID), playerID)
|
return
|
|
# Èü¼¾ÊÇ·ñÒѽáËã
|
if not IsCrossRealmPKSeasonOpen():
|
GameWorld.Log(" Èü¼¾ÒѾ½áËã¹ýÁË£¬²»´¦Àí£¡seasonID=%s" % (seasonID), playerID)
|
return
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
|
|
pkCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_PKCount) + 1
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, pkCount)
|
if isWinner:
|
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)
|
else:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, 0)
|
|
# ͬһÌìµÄ»°Ôö¼Óµ±ÈÕPK´ÎÊý
|
if GameWorld.CheckTimeIsSameServerDayEx(GameWorld.ChangeTimeStrToNum(timeStr)):
|
todayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount) + 1
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, todayPKCount)
|
|
## ¿ç·þÒѾ֪ͨ¹ýÁË£¬Ö¤Ã÷»¹ÔÚ¿ç·þ·þÎñÆ÷£¬²»×öÒÔϵĴ¦Àí
|
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
|
|
|
#// C1 02 ¿ç·þPK¹ºÂò´ÎÊý #tagCMCrossRealmPKBuy
|
#
|
#struct tagCMCrossRealmPKBuy
|
#{
|
# tagHead Head;
|
#};
|
def OnCrossRealmPKBuy(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
return
|
|
|
#// C1 03 ¿ç·þPKÁìÈ¡½±Àø #tagCMCrossRealmPKGetAward
|
#
|
#struct tagCMCrossRealmPKGetAward
|
#{
|
# tagHead Head;
|
# BYTE AwardType; // ½±ÀøÀàÐÍ£»1-ÿÈÕÆ¥Åä½±Àø£¬2-ÿÈÕʤÀû½±Àø£¬3-¶Îλ´ï±ê½±Àø£¬4-Èü¼¾½áËã½±Àø
|
# BYTE AwardData; // ½±ÀøÀàÐͶÔÓ¦Áìȡֵ£»Ã¿ÈÕÆ¥Åä½±ÀøÊ±ÎªÆ¥Åä´ÎÊý£¬Ã¿ÈÕʤÀû½±ÀøÊ±ÎªÊ¤Àû´ÎÊý£¬¶Îλ´ï±ê½±ÀøÊ±ÎªÁìÈ¡µÄ¶Îλ
|
#};
|
def OnCrossRealmPKGetAward(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
return
|
|
|
def SyncCrossRealmPKPlayerInfo(curPlayer):
|
# DWORD Score; // µ±Ç°»ý·Ö
|
# BYTE DanLV; // µ±Ç°¶Îλ
|
# WORD PKCount; // PK´ÎÊý
|
# WORD WinCount; // ʤÀû´ÎÊý
|
# WORD CWinCount; // Á¬Ê¤´ÎÊý
|
# BYTE DayPKCount; // µ±ÈÕÒÑPK´ÎÊý
|
# BYTE DayWinCount; // µ±ÈÕÒÑʤÀû´ÎÊý
|
# BYTE DayBuyCount; // µ±ÈÕÒѹºÂò´ÎÊý
|
pkPlayerInfo = ChPyNetSendPack.tagMCCrossRealmPKPlayerInfo()
|
pkPlayerInfo.Score = 0
|
pkPlayerInfo.DanLV = 0
|
return
|
|
def SyncCrossRealmPKAwardState(curPlayer):
|
# DWORD DayPKCountAwardState; // ÿÈÕÆ¥Åä´ÎÊý½±Àø¼Ç¼£¬¶þ½øÖÆÎ»´æ´¢ÊÇ·ñÒÑÁìÈ¡£¬°´Æ¥Åä´ÎÊýÉýÐòÅÅÐòË÷Òý´ú±í½±ÀøÎ»
|
# DWORD DayWinCountAwardState; // ÿÈÕʤÀû´ÎÊý½±Àø¼Ç¼£¬¶þ½øÖÆÎ»´æ´¢ÊÇ·ñÒÑÁìÈ¡£¬°´Ê¤Àû´ÎÊýÉýÐòÅÅÐòË÷Òý´ú±í½±ÀøÎ»
|
# DWORD DanLVAwardState; // ¶Îλ´ï±ê½±Àø¼Ç¼£¬¶þ½øÖÆÎ»´æ´¢ÊÇ·ñÒÑÁìÈ¡£¬°´¶Îλ´ú±í½±ÀøÎ»
|
# BYTE SeasonAwardState; // Èü¼¾½áËã½±ÀøÊÇ·ñÒÑÁìÈ¡
|
return
|
|
|
|
|