| | |
| | | import PlayerLLMJ
|
| | | import PlayerPrestigeSys
|
| | | import CrossServerPackLogic
|
| | | import DataRecordPack
|
| | | import PlayerSuccess
|
| | | import IpyGameDataPY
|
| | | import PlayerOnline
|
| | |
| | | import TurnBuff
|
| | | import FBCommon
|
| | | import CommFunc
|
| | | import ObjPool
|
| | | import FBLogic
|
| | |
|
| | | import random
|
| | |
| | | self.faction = faction # 所属阵营
|
| | | self.num = num # 该阵容所在阵营中的编号,不同阵营可重复,多V多
|
| | | self.ownerID = 0 # 阵容所属玩家ID,可能为0,0代表非玩家阵容
|
| | | self.lineupInfo = {} # 传入初始化的阵容信息
|
| | | self.shapeType = 0 # 阵型
|
| | | self.fightPower = 0 # 阵容总战力
|
| | | self.posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...}, 站位编号小于0为非主战单位,如主公、红颜等
|
| | |
| | | ## 设置阵容
|
| | | # @param lineupInfo: 阵容信息
|
| | | self.clearLineup()
|
| | | self.lineupInfo = lineupInfo
|
| | | self.ownerID = lineupInfo.get("PlayerID", 0) # 阵容所属的玩家ID
|
| | | self.shapeType = lineupInfo.get("ShapeType", 0)
|
| | | self.fightPower = lineupInfo.get("FightPower", 0)
|
| | |
| | | batObjMgr.delBatObj(objID)
|
| | | for objID in self.beautyObjIDDict.values():
|
| | | batObjMgr.delBatObj(objID)
|
| | | self.lineupInfo = {}
|
| | | self.posObjIDDict = {}
|
| | | self.heroObjIDDict = {}
|
| | | self.lingshouObjIDDict = {}
|
| | |
| | | break
|
| | |
|
| | | if allKilled:
|
| | | self.winFaction = ChConfig.Def_FactionA if faction == ChConfig.Def_FactionB else ChConfig.Def_FactionB
|
| | | if self.mapID in ChConfig.PlayerWinMapIDList:
|
| | | self.winFaction = ChConfig.Def_FactionA
|
| | | else:
|
| | | self.winFaction = ChConfig.Def_FactionA if faction == ChConfig.Def_FactionB else ChConfig.Def_FactionB
|
| | | DoTurnFightOver(self.guid)
|
| | | return self.winFaction
|
| | |
|
| | |
| | | GameWorld.DebugLogEx("回合战斗过程封包: %s, len:%s", headStr, buffLen)
|
| | | self.batBuffer += CommFunc.WriteWORD("", buffLen)
|
| | | self.batBuffer += packBuff
|
| | | ObjPool.GetPoolMgr().release(clientPack)
|
| | | else:
|
| | | GameWorld.DebugLogEx("回合战斗过程封包: %s", headStr)
|
| | | # 有玩家的统一每个包单独发送,同样也支持战报统计
|
| | | if self.curPlayer:
|
| | | NetPackCommon.SendFakePack(self.curPlayer, clientPack)
|
| | | else:
|
| | | ObjPool.GetPoolMgr().release(clientPack)
|
| | | return
|
| | |
|
| | | def ResetOneActionUseSkillCnt(self): self._oneActionUseSkillCntDict = {}
|
| | |
| | | return
|
| | |
|
| | | def addTurnFight(self, guid, mapID, funcLineID=0, reqPlayerID=0, reqServerID=0):
|
| | | tf = ObjPool.GetPoolMgr().acquire(TurnFight, guid, mapID, funcLineID, reqPlayerID, reqServerID)
|
| | | tf = TurnFight(guid, mapID, funcLineID, reqPlayerID, reqServerID)
|
| | | if not tf:
|
| | | tf = TurnFight(guid, mapID, funcLineID, reqPlayerID, reqServerID) # 一般是不可能,为了点出代码
|
| | | self.turnFightDict[tf.guid] = tf
|
| | |
| | | return
|
| | | turnFight.exitFight()
|
| | | self.turnFightDict.pop(guid, None)
|
| | | ObjPool.GetPoolMgr().release(turnFight)
|
| | | return
|
| | |
|
| | | def getTurnFight(self, guid):
|
| | |
| | | star = lvIpyData.GetReHeroStar()
|
| | | breakLV = lvIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData and lvIpyData:
|
| | | if heroIpyData:
|
| | | skinIDList = heroIpyData.GetSkinIDList()
|
| | | skinID = skinIDList[0] if skinIDList else 0
|
| | | skillIDList = GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV)
|
| | |
| | | isMultiMap = True
|
| | |
|
| | | if isMultiMap:
|
| | | CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
|
| | | CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
|
| | | else:
|
| | | SSMsg_BattleRequest(reqInfo, fromServerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID):
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID, msgType=""):
|
| | | ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | | |
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | |
| | | if npcLineupIDList:
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | | else:
|
| | |
| | |
|
| | | # 其他服务器地图请求的,发送战斗结果回去
|
| | | else:
|
| | | CrossServerPackLogic.SendToServer(ShareDefine.SSMsg_BattleResult, retInfo, [fromServerID], playerID=reqPlayerID)
|
| | | CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleResult(retInfo, fromServerID):
|
| | | def SSMsg_BattleResult(retInfo, fromServerID, msgType=""):
|
| | | ## 收到战斗结果信息
|
| | |
|
| | | guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
|
| | | |
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | |
| | | curPlayer = None
|
| | | if reqPlayerID:
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(reqPlayerID)
|
| | |
| | | buffID = buff.GetBuffID()
|
| | | skillID = buff.GetSkillID()
|
| | | skillData = buff.GetSkillData()
|
| | | if skillData.GetLastTimeType() != ChConfig.BuffLastTimeType_BigTurn:
|
| | | lastType = skillData.GetLastTimeType()
|
| | | |
| | | if lastType not in [ChConfig.BuffLastTimeType_BigTurn, ChConfig.BuffLastTimeType_BigTurnLayer]:
|
| | | continue
|
| | | |
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLogEx(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | if skillData.GetSkillType() == ChConfig.Def_SkillType_Halo and buff.GetOwnerID() != curID:
|
| | | GameWorld.DebugLogEx(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | remainTime = buff.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | | continue
|
| | | remainTime -= 1
|
| | | GameWorld.DebugLogEx(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
|
| | | TurnBuff.SetBuffRemainTime(turnFight, batObj, buff, remainTime)
|
| | | |
| | | # 每大回合固定减1回合
|
| | | if lastType == ChConfig.BuffLastTimeType_BigTurn:
|
| | | remainTime = buff.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | | continue
|
| | | remainTime -= 1
|
| | | GameWorld.DebugLogEx(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
|
| | | TurnBuff.SetBuffRemainTime(turnFight, batObj, buff, remainTime)
|
| | | |
| | | # 每大回合固定减1层
|
| | | elif skillData.GetLastTimeType() == ChConfig.BuffLastTimeType_BigTurnLayer:
|
| | | curLayer = buff.GetLayer()
|
| | | if curLayer <= 0:
|
| | | continue
|
| | | updLayer = curLayer - 1
|
| | | GameWorld.DebugLogEx(" 更新buff层级: curID=%s,buffID=%s,skillID=%s,updLayer=%s", curID, buffID, skillID, updLayer)
|
| | | TurnBuff.DoBuffLayerChange(turnFight, batObj, buff, updLayer)
|
| | | |
| | | return
|
| | |
|
| | | def RefreshObjBuffTime(turnFight, batObj):
|
| | |
| | | break
|
| | |
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, curBatObj, ChConfig.TriggerWay_HeroActionEnd)
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for faction in [ChConfig.Def_FactionA, ChConfig.Def_FactionB]:
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | for lineupNum in batFaction.lineupDict.keys():
|
| | | batLineup = batFaction.getBatlineup(lineupNum)
|
| | | for lineupObjID in batLineup.posObjIDDict.values():
|
| | | lineupObj = batObjMgr.getBatObj(lineupObjID)
|
| | | if not lineupObj.IsAlive():
|
| | | continue
|
| | | if lineupObj.GetFaction() != curBatObj.GetFaction():
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, lineupObj, ChConfig.TriggerWay_EnemyAction, curBatObj)
|
| | | else:
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, lineupObj, ChConfig.TriggerWay_FriendAction, curBatObj)
|
| | | return True
|
| | |
|
| | | def SetObjKilled(turnFight, gameObj, killer=None, useSkill=None):
|
| | |
| | | gameObj.SetDead()
|
| | | TurnBuff.DoBuffByDead(turnFight, gameObj)
|
| | |
|
| | | clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagMCTurnFightObjDead)
|
| | | clientPack = ChPyNetSendPack.tagMCTurnFightObjDead()
|
| | | clientPack.ObjID = objID
|
| | | clientPack.KillerObjID = killerObjID
|
| | | clientPack.SkillID = skillID
|
| | |
| | |
|
| | | if turnFight.getReqPlayerID():
|
| | | # 玩家发起的,未击杀对方,算玩家输
|
| | | turnFight.winFaction = ChConfig.Def_FactionB
|
| | | if turnFight.mapID in ChConfig.PlayerWinMapIDList:
|
| | | turnFight.winFaction = ChConfig.Def_FactionA
|
| | | else:
|
| | | turnFight.winFaction = ChConfig.Def_FactionB
|
| | | else:
|
| | | # 系统场次,按一定规则来,这里先随机
|
| | | turnFight.winFaction = random.choice([ChConfig.Def_FactionA, ChConfig.Def_FactionB])
|
| | |
| | | turnFight.isWin = (winFaction == ChConfig.Def_FactionA)
|
| | | mapID = turnFight.mapID
|
| | | funcLineID = turnFight.funcLineID
|
| | | reqPlayerID = turnFight.getReqPlayerID()
|
| | | GameWorld.DebugLogEx("--- 战斗结束处理 ---, winFaction=%s, costTime=%ss, %s", winFaction, turnFight.costTime, guid)
|
| | | if mapID != ChConfig.Def_FBMapID_Main:
|
| | | GameWorld.Log("战斗耗时: %ss, mapID=%s,funcLineID=%s,turnNum=%s/%s" % (turnFight.costTime, mapID, funcLineID, turnFight.turnNum, turnFight.turnMax))
|
| | |
|
| | | # 统计明细
|
| | | heroCount = 0
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | statInfo = {}
|
| | | drLineupInfo = {}
|
| | | for faction in turnFight.factionDict.keys():
|
| | | if str(faction) not in statInfo:
|
| | | statInfo[str(faction)] = {}
|
| | | facStatInfo = statInfo[str(faction)]
|
| | | if str(faction) not in drLineupInfo:
|
| | | drLineupInfo[str(faction)] = {}
|
| | | facDRLineupInfo = drLineupInfo[str(faction)]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batFaction.totalHurt = 0
|
| | | for num in batFaction.lineupDict.keys():
|
| | |
| | | lineupStatInfo = facStatInfo[str(num)]
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.totalHurt = 0
|
| | | facDRLineupInfo[str(num)] = batLineup.lineupInfo
|
| | | GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
|
| | | for posNum, objID in batLineup.posObjIDDict.items():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | heroCount += 1
|
| | | objID = batObj.GetID()
|
| | | npcID = batObj.GetNPCID()
|
| | | heroID = batObj.GetHeroID()
|
| | |
| | | FBLogic.OnTurnFightOver(turnFight, mapID, funcLineID, statMsg)
|
| | |
|
| | | turnFight.syncState(FightState_Award, statMsg)
|
| | | |
| | | # 流向记录
|
| | | if mapID != ChConfig.Def_FBMapID_Main and reqPlayerID:
|
| | | DataRecordPack.DR_FightStat(reqPlayerID, mapID, funcLineID, turnFight.isWin, turnFight.turnNum, turnFight.turnMax, |
| | | heroCount, turnFight.costTime, statInfo, drLineupInfo)
|
| | | return
|
| | |
|
| | | #// B4 14 查看战报 #tagCSTurnFightReportView
|