ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossChampionship.py
@@ -14,117 +14,6 @@
#-------------------------------------------------------------------------------
#"""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
#
# 改为使用镜像PK,逻辑统一放 GameLogic_MirrorBattle
#