#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerCrossChampionship
|
#
|
# @todo:¿ç·þÅÅλÕù°ÔÈü
|
# @author hxp
|
# @date 2022-09-21
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ¿ç·þÅÅλÕù°ÔÈü
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2022-09-21 21:30"""
|
#-------------------------------------------------------------------------------
|
|
import GameWorld
|
import ShareDefine
|
import PlayerControl
|
import CrossRealmPlayer
|
import ChPyNetSendPack
|
import NetPackCommon
|
import IpyGameDataPY
|
import ChConfig
|
|
import random
|
import time
|
|
|
def DoChampionshipOpen(curPlayer):
|
DoPlayerLogin(curPlayer)
|
return
|
|
def DoPlayerLogin(curPlayer):
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Championship_WorshipCount):
|
Sync_ChampionshipPlayerInfo(curPlayer)
|
return
|
|
def DoPlayerOnDay(curPlayer):
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Championship_WorshipCount):
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Championship_WorshipCount, 0)
|
Sync_ChampionshipPlayerInfo(curPlayer)
|
return
|
|
#// C1 20 ¿ç·þÅÅλÏɹÙÉêÇë #tagCMChampionshipOfficialApply
|
#
|
#struct tagCMChampionshipOfficialApply
|
#{
|
# tagHead Head;
|
# BYTE ZoneID; //ÏɹÙÊý¾Ý·ÖÇøID
|
# WORD MainOfficialID; //½çÖ÷¹ÙÖ°ID
|
# WORD OfficialID; //ÉêÇë¹ÙÖ°ID
|
# BYTE Cancel; //ÊÇ·ñÈ¡ÏûÉêÇ룬ĬÈÏ0-ÉêÇ룻1-È¡ÏûÉêÇë
|
#};
|
def OnChampionshipOfficialApply(index, clientData, tick):
|
if GameWorld.IsCrossServer():
|
return
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerID = curPlayer.GetPlayerID()
|
|
zoneID = clientData.ZoneID
|
mainOfficialID = clientData.MainOfficialID
|
officialID = clientData.OfficialID
|
cancel = clientData.Cancel
|
|
realmLV = curPlayer.GetOfficialRank()
|
needRealmLV = IpyGameDataPY.GetFuncCfg("CrossChamOfficial", 3)
|
if realmLV < needRealmLV:
|
GameWorld.DebugLog("ËùÐè¾³½ç²»×㣬ÎÞ·¨ÉêÇëÏɹÙ! realmLV(%s) < %s" % (realmLV, needRealmLV), playerID)
|
return
|
|
# ·¢ËÍ¿ç·þ·þÎñÆ÷
|
dataMsg = {"zoneID":zoneID, "mainOfficialID":mainOfficialID, "officialID":officialID, "cancel":cancel,
|
"playerID":playerID, "PropData":CrossRealmPlayer.GetPlayerCrossPropDataShort(curPlayer)}
|
GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipOfficialApply, dataMsg)
|
return
|
|
|
#// C1 21 ¿ç·þÅÅλÏɹÙÌôÕ½ #tagCMChampionshipOfficialChallenge
|
#
|
#struct tagCMChampionshipOfficialChallenge
|
#{
|
# tagHead Head;
|
# BYTE ZoneID; //ÏɹÙÊý¾Ý·ÖÇøID
|
# WORD MainOfficialID; //½çÖ÷¹ÙÖ°ID
|
# WORD OfficialID; //ÌôÕ½µÄÄ¿±ê¹ÙÖ°ID
|
# DWORD PlayerID; //ÌôսʱµÄÄ¿±êÍæ¼ÒID
|
#};
|
def OnChampionshipOfficialChallenge(index, clientData, tick):
|
if GameWorld.IsCrossServer():
|
return
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerID = curPlayer.GetPlayerID()
|
|
zoneID = clientData.ZoneID
|
mainOfficialID = clientData.MainOfficialID
|
officialID = clientData.OfficialID
|
tagPlayerID = clientData.PlayerID
|
|
realmLV = curPlayer.GetOfficialRank()
|
needRealmLV = IpyGameDataPY.GetFuncCfg("CrossChamOfficial", 3)
|
if realmLV < needRealmLV:
|
GameWorld.DebugLog("ËùÐè¾³½ç²»×㣬ÎÞ·¨ÌôÕ½ÏɹÙ! realmLV(%s) < %s" % (realmLV, needRealmLV), playerID)
|
return
|
|
# ·¢ËÍ¿ç·þ·þÎñÆ÷
|
dataMsg = {"zoneID":zoneID, "mainOfficialID":mainOfficialID, "officialID":officialID,
|
"playerID":playerID, "tagPlayerID":tagPlayerID, "PropData":CrossRealmPlayer.GetPlayerCrossPropDataShort(curPlayer)}
|
GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipOfficialChallenge, dataMsg)
|
return
|
|
|
#// C1 22 ¿ç·þÅÅλ¾º²Â #tagCMChampionshipGuess
|
#
|
#struct tagCMChampionshipGuess
|
#{
|
# tagHead Head;
|
# BYTE ZoneID; //ÅÅλÊý¾Ý·ÖÇøID
|
# BYTE GuessType; //¾º²ÂÀàÐÍ 8-8Ç¿£»4-4Ç¿ÅÅλ
|
# DWORD PlayerID; //Ä¿±êÍæ¼ÒID
|
# BYTE GuessCount; //Ͷע/×·¼Ó·ÝÊý
|
# BYTE GuessRank; // ¾º²ÂÃû´Î£¬Ã»ÓÐÃû´ÎµÄ¾º²ÂĬÈÏ0£»1-´ú±íµÚÒ»Ãû
|
#};
|
def OnChampionshipGuess(index, clientData, tick):
|
if GameWorld.IsCrossServer():
|
return
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerID = curPlayer.GetPlayerID()
|
zoneID = clientData.ZoneID
|
guessType = clientData.GuessType
|
tagPlayerID = clientData.PlayerID
|
guessCount = clientData.GuessCount
|
guessRank = clientData.GuessRank
|
|
moneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("CrossChamGuess", 1)
|
guessMoney = moneyValue * guessCount
|
if guessMoney <= 0:
|
return
|
|
if not PlayerControl.HaveMoney(curPlayer, moneyType, guessMoney):
|
return
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Championship, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
# ·¢ËÍ¿ç·þ·þÎñÆ÷
|
dataMsg = {"zoneID":zoneID, "guessType":guessType, "playerID":playerID, "tagPlayerID":tagPlayerID,
|
"guessRank":guessRank, "guessMoney":guessMoney, "moneyType":moneyType, "exDataType":"ChampionshipGuess"}
|
GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipGuess, dataMsg)
|
return
|
|
|
#// C1 23 ¿ç·þÅÅλĤ°Ý #tagCMChampionshipWorship
|
#
|
#struct tagCMChampionshipWorship
|
#{
|
# tagHead Head;
|
# BYTE ZoneID; //ÏɹÙÊý¾Ý·ÖÇøID
|
# DWORD PlayerID; //Ä¿±êÍæ¼ÒID
|
#};
|
def OnChampionshipWorship(index, clientData, tick):
|
if GameWorld.IsCrossServer():
|
return
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerID = curPlayer.GetPlayerID()
|
zoneID = clientData.ZoneID
|
tagPlayerID = clientData.PlayerID
|
|
worshipCountMax = IpyGameDataPY.GetFuncCfg("CrossChamWorship", 1)
|
if worshipCountMax:
|
worshipCountToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Championship_WorshipCount)
|
if worshipCountToday >= worshipCountMax:
|
GameWorld.DebugLog("Ĥ°Ý´ÎÊý²»×ã! worshipCountToday=%s >= %s" % (worshipCountToday, worshipCountMax), curPlayer.GetPlayerID())
|
return False
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Championship, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
# ·¢ËÍ¿ç·þ·þÎñÆ÷
|
dataMsg = {"zoneID":zoneID, "playerID":playerID, "tagPlayerID":tagPlayerID, "exDataType":"OfficialWorship", "WorshipTime":int(time.time())}
|
GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipWorship, dataMsg)
|
return
|
|
def GameServer_Championship(curPlayer, msgData):
|
|
playerID = curPlayer.GetPlayerID()
|
|
msgType = msgData[0]
|
if msgType == "ChampionshipGuess":
|
dataMsg = msgData[1]
|
if not isinstance(dataMsg, dict) or "moneyType" not in dataMsg:
|
return
|
moneyType = dataMsg["moneyType"]
|
guessMoney = dataMsg["guessMoney"]
|
infoDict = dataMsg
|
PlayerControl.PayMoney(curPlayer, moneyType, guessMoney, msgType, infoDict)
|
|
elif msgType == "OfficialWorship":
|
dataMsg = msgData[1]
|
worshipTime = dataMsg["WorshipTime"]
|
worshipDouble = dataMsg.get("worshipDouble", 0)
|
if GameWorld.CheckTimeIsSameServerDayEx(worshipTime):
|
worshipCountToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Championship_WorshipCount) + 1
|
worshipCountMax = IpyGameDataPY.GetFuncCfg("CrossChamWorship", 1)
|
if worshipCountToday > worshipCountMax:
|
return
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Championship_WorshipCount, worshipCountToday)
|
GameWorld.DebugLog("¸üÐÂĤ°Ý´ÎÊý! worshipCountToday=%s" % worshipCountToday, playerID)
|
Sync_ChampionshipPlayerInfo(curPlayer)
|
|
gongdePointRange = IpyGameDataPY.GetFuncEvalCfg("CrossChamWorship", 2) # Ëæ»ú½±Àø¹¦µÂµã·¶Î§
|
if len(gongdePointRange) != 2:
|
return
|
gongdePoint = random.randint(gongdePointRange[0], gongdePointRange[1])
|
GameWorld.DebugLog("Ĥ°ÝËæ»ú¹¦µÂµã: gongdePoint=%s" % gongdePoint, playerID)
|
doubleHMList = IpyGameDataPY.GetFuncEvalCfg("CrossChamWorship", 3) # Ë«±¶Ä¤°Ýʱ¼ä·¶Î§
|
if worshipDouble and len(doubleHMList) == 2:
|
fromHour, fromMinute = doubleHMList[0]
|
toHour, toMinute = doubleHMList[1]
|
serverTime = GameWorld.GetCurrentTime()
|
curHour, curMinute = serverTime.hour, serverTime.minute
|
fromValue = fromHour * 100 + fromMinute
|
toValue = toHour * 100 + toMinute
|
curValue = curHour * 100 + curMinute
|
if fromValue <= curValue <= toValue:
|
gongdePoint *= 2
|
GameWorld.DebugLog("Ĥ°ÝË«±¶¹¦µÂµã: gongdePoint=%s" % gongdePoint, playerID)
|
else:
|
GameWorld.DebugLog("·ÇË«±¶Ä¤°ÝÆÚ¼ä: doubleHM(%s~%s), curHM=%s" % (fromValue, toValue, curValue), playerID)
|
|
if gongdePoint:
|
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_GongdePoint, gongdePoint, "OfficialWorship")
|
|
return
|
|
def Sync_ChampionshipPlayerInfo(curPlayer):
|
clientPack = ChPyNetSendPack.tagMCChampionshipPlayerInfo()
|
clientPack.WorshipCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Championship_WorshipCount)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|
|