hxp
2024-12-10 cc3b988b52ba3f473862d289ec58e7873e35d713
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_CrossChampionship
#
# @todo:¿ç·þÅÅλÕù°ÔÈü
# @author hxp
# @date 2022-09-21
# @version 1.0
#
# ÏêϸÃèÊö: ¿ç·þÅÅλÕù°ÔÈü
#
#-------------------------------------------------------------------------------
#"""Version = 2022-09-21 21:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
import MirrorAttack
import IPY_GameWorld
import PlayerControl
import CrossRealmPlayer
import IpyGameDataPY
import ShareDefine
import FBCommon
import GameObj
 
 
###´¦Àí¸±±¾ÖÐɱËÀÍæ¼ÒÂß¼­
def DoFBOnKill_Player(atkobj, defender, tick):
    GameWorld.DebugLog("¾µÏñÇдè»÷É±Íæ¼Ò: defID=%s" % (defender.GetID()), atkobj.GetID())
    return True
 
def OnMirrorBattleRequest(curPlayer, mapID, funcLineID):
    ## ¾µÏñÕ½¶·ÇëÇó
    
    playerID = curPlayer.GetPlayerID()
    if GameWorld.IsCrossServer():
        return
    
    if not CrossRealmPlayer.IsCrossServerOpen():
        PlayerControl.NotifyCode(curPlayer, "CrossMatching18")
        return
    
    if curPlayer.GetPlayerAction() == IPY_GameWorld.paDie or GameObj.GetHP(curPlayer) == 0:
        GameWorld.DebugLog("ÒÑËÀÍö£¬ÎÞ·¨½øÐпç·þÅÅλÈü!", playerID)
        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:
        return
    mapID = battle.mapID
    funcLineID = battle.funcLineID
    isWin = battle.isWin
    curPlayerID = battle.requestID # ¸±±¾ËùÊôÍæ¼ÒID£¬¸ÃÍæ¼Ò²»Ò»¶¨²ÎÓëʵ¼ÊÕ½¶·
    tagPlayerID = battle.GetTagPlayerID()
    fightTickRemain = battle.fightTickRemain
    curHPPer = 0 # ×Ô¼ºÊ£ÓàѪÁ¿°Ù·Ö±È 0~100£¬Ö§³ÖСÊýµã
    tagHPPer = 0 # ¶Ô·½Ê£ÓàѪÁ¿°Ù·Ö±È 0~100£¬Ö§³ÖСÊýµã
    
    curPlayer = None
    playerMgr = GameWorld.GetMapCopyPlayerManager()
    for playerID, faction in battle.playerFactionDict.items():
        player = playerMgr.FindPlayerByID(playerID)
        if not player:
            continue
        realPlayerID = player.GetRealPlayerID()
        hp = GameObj.GetHP(player)
        hpMax = GameObj.GetMaxHP(player)
        hpPer = hp / float(hpMax) * 100
        GameWorld.DebugLog("    Ê£ÓàѪÁ¿: %s/%s,hpPer=%s%%,playerID=%s,realPlayerID=%s,faction=%s" 
                           % (hp, hpMax, hpPer, playerID, realPlayerID, faction), battleID)
        if not realPlayerID and curPlayerID == playerID:
            curPlayer = player
            curHPPer = hpPer
        if tagPlayerID == realPlayerID:
            tagHPPer = hpPer
            
    if not curPlayer:
        return
    
    baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossChamMirrorPK", 2)
    baseScore = 0
    if baseScoreList and len(baseScoreList) == 2:
        baseScore = baseScoreList[0] if battle.isWin else baseScoreList[1]
    hpScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 3)))
    GameWorld.DebugLog("    hpScore=%s,curHPPer=%s,tagHPPer=%s" % (hpScore, curHPPer, tagHPPer), battleID)
    remainTimePer = fightTickRemain / float(battle.fightTickMax) * 100 # Ê£ÓàÕ½¶·Ê±¼ä°Ù·Ö±È
    timeScore = int(eval(IpyGameDataPY.GetFuncCompileCfg("CrossChamMirrorPK", 4)))
    addScore = baseScore + hpScore + timeScore
    GameWorld.DebugLog("    timeScore=%s,remainTimePer=%s%%,fightTickRemain=%s,fightTickMax=%s" % (timeScore, remainTimePer, fightTickRemain, battle.fightTickMax), battleID)
    
    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