hxp
2 天以前 388823edfe6308cba6f76ca6dc4f20022c5cb2be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/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