hxp
2025-05-23 fdebf36f0d9201c6a6949a08cdfeebb718c25ce2
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_MirrorBattle
#
# @todo:¾µÏñPKÇдè
# @author hxp
# @date 2024-10-17
# @version 1.0
#
# ÏêϸÃèÊö: ¾µÏñPKÇдè
#
#-------------------------------------------------------------------------------
#"""Version = 2024-10-17 15:00"""
#-------------------------------------------------------------------------------
 
import ChConfig
import ShareDefine
import MirrorAttack
import PlayerControl
import IpyGameDataPY
import PlayerCrossRealmPK
import GameWorldProcess
import CrossRealmPlayer
import PlayerArena
import GameWorld
import FBCommon
 
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
    return MirrorAttack.OnGetMirrorBattlePos(mapID, lineId)[0]
 
def DoEnterFB(curPlayer, tick):
    playerID = curPlayer.GetPlayerID()
    GameWorld.Log("---------------- ¾µÏñÕ½¶·DoEnterFB ----------------", playerID)
    MirrorAttack.OnMirrorBattleEnterMapInit(curPlayer, tick)
    return
 
def DoExitFB(curPlayer, tick):
    ##Íæ¼ÒÍ˳ö¸±±¾
    MirrorAttack.DoExitFB(curPlayer, tick)
    return
 
def DoPlayerLeaveFB(curPlayer, tick):
    ##Íæ¼ÒÖ÷¶¯À뿪¸±±¾
    MirrorAttack.DoPlayerLeaveFB(curPlayer, tick)
    return
 
## ¸±±¾¶¨Ê±Æ÷
def OnProcess(tick):
    fbStep = GameWorld.GetGameFB().GetFBStep()
 
    # µÈ´ý¾µÏñ³õʼ»¯½×¶Î
    if fbStep == ChConfig.Def_MirrorBatState_Init:
        if tick - GameWorld.GetGameFB().GetFBStepTick() < 20 * 1000:
            return
        FBCommon.SetFBStep(ChConfig.Def_MirrorBatState_Over, tick)
        GameWorld.ErrLog("ûÓеȵ½¾µÏñ´´½¨£¬Ö±½Ó¹Ø±Õ¸±±¾!")
        GameWorldProcess.CloseFB(tick)
        
    return
 
def CheckPlayersRelation_IsFriend(curPlayer, curTagPlayer):
    return not CanAttackPlayer(curPlayer, curTagPlayer)
 
def CanAttackPlayer(curPlayer, curTagPlayer):
    battle = MirrorAttack.GetMirrorBattle(curPlayer)
    if not battle:
        return
        
    if battle.batState != ChConfig.Def_MirrorBatState_Fight:
        return
    
    if curTagPlayer:
        if curPlayer.GetFaction() == curTagPlayer.GetFaction():
            return
            
    return True
 
##´¦Àí¸±±¾ÖÐɱËÀÍæ¼ÒÂß¼­
def DoFBOnKill_Player(atkobj, defender, tick):
    GameWorld.DebugLog("¾µÏñÇдè»÷É±Íæ¼Ò: defID=%s" % (defender.GetID()), atkobj.GetID())
    return True
 
def OnMirrorBattleRequest(curPlayer, mapID, funcLineID, factionPlayerList):
    ## ¾µÏñÕ½¶·ÇëÇó
    
    if mapID == ChConfig.Def_FBMapID_CrossRealmPK:
        return __CheckRequest_CrossRealmPK(curPlayer, mapID, funcLineID)
    
    if mapID == ChConfig.Def_FBMapID_CrossChampionship:
        return __CheckRequest_CrossChampionship(curPlayer, mapID, funcLineID)
    
    return True
 
def __CheckRequest_CrossRealmPK(curPlayer, mapID, funcLineID):
    if not CrossRealmPlayer.IsCrossServerOpen():
        PlayerControl.NotifyCode(curPlayer, "CrossMatching18")
        return
    if not PlayerCrossRealmPK.CheckCanMatch(curPlayer):
        return
    if not PlayerCrossRealmPK.CheckHavePKCount(curPlayer):
        return
    return True
 
def __CheckRequest_CrossChampionship(curPlayer, mapID, funcLineID):
    
    playerID = curPlayer.GetPlayerID()
    if not CrossRealmPlayer.IsCrossServerOpen():
        PlayerControl.NotifyCode(curPlayer, "CrossMatching18")
        return
    
    stateError = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossChampionshipStateError)
    if stateError:
        GameWorld.ErrLog("¿ç·þÅÅλ״̬ÒѾ­Òì³£ÎÞ·¨½øÈë! stateError=%s" % stateError, playerID)
        return
    
    state = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossChampionshipState)
    if state not in ShareDefine.CrossChampionshipEnterStateInfo:
        GameWorld.ErrLog("µ±Ç°×´Ì¬·Ç¿ç·þÅÅλս¶·×´Ì¬ÎÞ·¨½øÈë: state=%s" % state, playerID)
        return
    groupMark = ShareDefine.CrossChampionshipEnterStateInfo[state]
    reqGroupMark = funcLineID % 100
    if reqGroupMark != groupMark:
        GameWorld.ErrLog("µ±Ç°×´Ì¬Óë¿ç·þÅÅλս¶··Ö×é²»Ò»ÖÂÎÞ·¨½øÈë: funcLineID=%s,reqGroupMark=%s != %s" % (funcLineID, reqGroupMark, groupMark), playerID)
        return
    
    return True
 
def OnMirrorBattleOver(battleID):
    ## ¾µÏñÕ½¶·½áÊø
    
    battle = MirrorAttack.GetMirrorBattleByID(battleID)
    if not battle:
        GameWorld.DebugLog("¾µÏñÕ½¶·½áËãʱս³¡Êý¾Ý²»´æÔÚ!", battleID)
        return
    mapID = battle.mapID
    funcLineID = battle.funcLineID
    isWin = battle.isWin
    curPlayerID = battle.playerID # ¸±±¾ËùÊôÍæ¼ÒID£¬¸ÃÍæ¼Ò²»Ò»¶¨²ÎÓëʵ¼ÊÕ½¶·
    tagPlayerID = battle.GetTagPlayerID()
    curPlayer = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(curPlayerID)
    if not curPlayer: # ·À·¶GetMapCopyPlayerManagerÕÒ²»µ½µÄÇé¿ö£¬²»ÔÚ1Ïߣ¬ÏµÍ³ºǫ́ս¶·Ä¬ÈÏÔÚ1Ïߣ¬·Ç1ÏßÍæ¼ÒÇëÇóµÄÇé¿ö
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPlayerID)
        
    if not curPlayer:
        GameWorld.DebugLog("¾µÏñÕ½¶·½áËãʱËùÊôÍæ¼Ò²»ÔÚÏß! curPlayerID=%s" % curPlayerID, battleID)
        return
    
    if mapID == ChConfig.Def_FBMapID_ArenaBattle:
        arenaPlayerID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ArenaBattleTagID)
        if tagPlayerID == arenaPlayerID:
            PlayerArena.SendGameServer_ArenaBattleOver(curPlayer, isWin)
        else:
            GameWorld.DebugLog("·Ç¾º¼¼³¡¶ÔÊÖ²»½áËã! tagPlayerID=%s,arenaPlayerID=%s" % (tagPlayerID, arenaPlayerID), curPlayerID)
        return
    
    if mapID == ChConfig.Def_FBMapID_CrossRealmPK:
        PlayerCrossRealmPK.SendPKOver(curPlayer, tagPlayerID, isWin)
        return
    
    if mapID == ChConfig.Def_FBMapID_CrossChampionship:
        __MirrorBattleOver_CrossChampionship(curPlayer, battle)
        return
    
    giveItemList = []
    overDict = {"isWin":isWin, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)}
    FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isWin, overDict) 
    return
 
def __MirrorBattleOver_CrossChampionship(curPlayer, battle):
    playerID = curPlayer.GetPlayerID()
    mapID = battle.mapID
    funcLineID = battle.funcLineID
    isWin = battle.isWin
    tagPlayerID = battle.GetTagPlayerID()
    curHPPer, tagHPPer = battle.CalcHPPer()
    remainTimePer = battle.CalcRemainTimePer()
    
    baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossChamMirrorPK", 2)
    baseScore = 0
    if baseScoreList and len(baseScoreList) == 2:
        baseScore = baseScoreList[0] if isWin else baseScoreList[1]
    hpScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 3)))
    GameWorld.DebugLog("    hpScore=%s,curHPPer=%s,tagHPPer=%s" % (hpScore, curHPPer, tagHPPer), playerID)
    
    timeScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 4)))
    GameWorld.DebugLog("    timeScore=%s,remainTimePer=%s%%" % (timeScore, remainTimePer), playerID)
    
    addScore = baseScore + hpScore + timeScore
    GameWorld.DebugLog("    addScore=%s,baseScore=%s" % (addScore, baseScore), playerID)
    
    pkCountMax = IpyGameDataPY.GetFuncCfg("CrossChamMirrorPK", 1)
    playerID = curPlayer.GetPlayerID()
    dataMsg = {
               "playerID":playerID,
               "tagPlayerID":tagPlayerID,
               "funcLineID":funcLineID,
               "isWin":isWin,
               "addScore":addScore,
               "baseScore":baseScore,
               "hpScore":hpScore,
               "timeScore":timeScore,
               "pkCountMax":pkCountMax,
               }
    GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipPKOver, dataMsg)
    overDict = {"isWin":isWin, "tagPlayerID":tagPlayerID, "addScore":addScore, "baseScore":baseScore, "hpScore":hpScore, "timeScore":timeScore}
    FBCommon.NotifyFBOver(curPlayer, mapID, funcLineID, isWin, overDict)
    return