#!/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
|
|