| | |
| | | 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 = {}
|
| | |
| | | continue
|
| | | deadCnt += 1
|
| | | return deadCnt
|
| | | |
| | | def getHeroObj(self, heroID):
|
| | | if heroID not in self.heroObjIDDict:
|
| | | return
|
| | | return BattleObj.GetBatObjMgr().getBatObj(self.heroObjIDDict[heroID])
|
| | |
|
| | | class BatFaction():
|
| | | ## 战斗阵营
|
| | |
| | | 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
|
| | |
|
| | |
| | | else:
|
| | | tfObj.PosNum = posNum
|
| | | tfObj.AngreXP = batObj.GetXP()
|
| | | tfObj.FightPower = batObj.GetFightPower() % ChConfig.Def_PerPointValue
|
| | | tfObj.FightPowerEx = batObj.GetFightPower() / ChConfig.Def_PerPointValue
|
| | | tfLineup.ObjList.append(tfObj)
|
| | | tfLineup.ObjCnt = len(tfLineup.ObjList)
|
| | | tfFaction.LineupList.append(tfLineup)
|
| | |
| | | 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):
|
| | |
| | | lineupInfo = lineupDict.get("%s" % ShareDefine.Lineup_Main, {})
|
| | | return lineupInfo
|
| | |
|
| | | def GetPlayerLineupFightPower(curPlayer, lineupID):
|
| | | def GetPlayerLineupFightPower(curPlayer, lineupID=ShareDefine.Lineup_Main):
|
| | | ## 获取玩家阵容战力,一般用于直接获取阵容战力记录用
|
| | | return GetPlayerLineup(curPlayer, lineupID).fightPower
|
| | | def GetPlayerLineup(curPlayer, lineupID):
|
| | | def GetPlayerLineup(curPlayer, lineupID=ShareDefine.Lineup_Main, exclusiveMapID=0):
|
| | | ## 获取玩家阵容
|
| | | olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
|
| | | lineup = olPlayer.GetLineup(lineupID)
|
| | | lineup = olPlayer.GetLineup(lineupID, exclusiveMapID=exclusiveMapID)
|
| | | if lineup.IsEmpty():
|
| | | GameWorld.DebugLogEx("玩家没有目标阵容默认取主阵容! lineupID=%s", lineupID, curPlayer.GetPlayerID())
|
| | | lineup = olPlayer.GetLineup(ShareDefine.Lineup_Main)
|
| | | return lineup
|
| | |
|
| | | def GetPlayerLineupInfo(curPlayer, lineupID):
|
| | | def GetPlayerLineupInfo(curPlayer, lineupID, exclusiveMapID=0):
|
| | | ## 获取玩家阵容信息,可用于战斗或查看缓存,因为可能取玩家的缓存进行对战,所以统一使用json格式,前端通用
|
| | | # @param lineupID: 阵容ID
|
| | | # @param exclusiveMapID: 专享阵容的地图ID,如定军阁
|
| | | # @return: 阵容全部信息json字典,前端通用格式
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | lineup = GetPlayerLineup(curPlayer, lineupID)
|
| | | lineup = GetPlayerLineup(curPlayer, lineupID, exclusiveMapID)
|
| | | if lineup.IsEmpty():
|
| | | return {}
|
| | |
|
| | |
| | | itemIndex = hero.itemIndex
|
| | | heroLV = 1
|
| | | star = 0
|
| | | userData = "{}"
|
| | | if itemIndex >= 0 and itemIndex < curPack.GetCount():
|
| | | heroItem = curPack.GetAt(itemIndex)
|
| | | if heroItem and not heroItem.IsEmpty():
|
| | |
| | | star = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | #breakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | #awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | userData = heroItem.GetUserData()
|
| | |
|
| | | skillIDlist = []
|
| | | skillIDlist += hero.heroSkillIDList
|
| | |
| | | "SkinID":hero.skinID,
|
| | | "LV":heroLV,
|
| | | "Star":star,
|
| | | "Data":userData,
|
| | | #"BreakLV":breakLV,
|
| | | #"AwakeLV":awakeLV,
|
| | | "FightPower":hero.fightPower,
|
| | |
| | | lineupInfo = {"PlayerID":playerID, "FightPower":lineup.fightPower, "ShapeType":lineup.shapeType, "Hero":heroDict}
|
| | | return lineupInfo
|
| | |
|
| | | def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0):
|
| | | def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0, isLog=True):
|
| | | ## 获取NPC阵容信息
|
| | | # @param lineupID: 阵容ID
|
| | | # @param npcLV: 成长NPC等级
|
| | |
| | | npcID = getattr(ipyData, "GetPosNPCID%s" % posNum)()
|
| | | if not npcID:
|
| | | continue
|
| | | battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty)
|
| | | battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty, isLog)
|
| | | if not battleDict:
|
| | | continue
|
| | | heroDict[str(posNum)] = battleDict
|
| | |
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":0, "BossPosView":0}
|
| | | return lineupInfo
|
| | |
|
| | | def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0):
|
| | | def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0, isLog=True):
|
| | | ## 获取NPC战斗相关字典,支持成长NPC
|
| | | # @param strongerLV: 成长等级
|
| | | # @param difficulty: 难度系数
|
| | |
| | | npcLV = npcData.GetLV()
|
| | | star, breakLV, awakeLV = 0, 0, 0
|
| | |
|
| | | lvIpyData = None
|
| | | reModelID = lineupIpyData.GetReModelID()
|
| | | lvReIpyData = None
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | | npcStronger = IpyGameDataPY.GetIpyGameDataNotLog("NPCStronger", npcID)
|
| | | if npcStronger and strongerLV:
|
| | | lvIpyData = IpyGameDataPY.GetIpyGameData("PlayerLV", strongerLV)
|
| | | if lvIpyData:
|
| | | lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, strongerLV)
|
| | | if lvReIpyData:
|
| | | npcLV = strongerLV
|
| | | if not lvIpyData:
|
| | | lvIpyData = IpyGameDataPY.GetIpyGameData("PlayerLV", npcLV)
|
| | | if lvIpyData:
|
| | | star = lvIpyData.GetReHeroStar()
|
| | | breakLV = lvIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData and lvIpyData:
|
| | | if not lvReIpyData:
|
| | | lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, npcLV)
|
| | | if lvReIpyData:
|
| | | star = lvReIpyData.GetReHeroStar()
|
| | | breakLV = lvReIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvReIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData:
|
| | | skinIDList = heroIpyData.GetSkinIDList()
|
| | | skinID = skinIDList[0] if skinIDList else 0
|
| | | skillIDList = GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV)
|
| | |
| | | random.shuffle(randSkillIDExList)
|
| | | randSkillIDExList = randSkillIDExList[:skillExCnt]
|
| | | skillIDList += randSkillIDExList
|
| | | GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
|
| | | isLog and GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
|
| | |
|
| | | # 成长怪属性
|
| | | batAttrDict = GetNPCStrongerAttrDict(npcID, lvIpyData, npcStronger, difficulty)
|
| | | batAttrDict = GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog)
|
| | | if not batAttrDict:
|
| | | batAttrDict = {ChConfig.AttrID_Atk:npcData.GetAtk(), ChConfig.AttrID_Def:npcData.GetDef(), ChConfig.AttrID_MaxHP:npcData.GetMaxHP(),
|
| | | ChConfig.AttrID_FinalDamPer:npcData.GetFinalDamPer(), ChConfig.AttrID_FinalDamPerDef:npcData.GetFinalDamPerDef(),
|
| | |
| | | "SkillIDList":skillIDList,
|
| | | }
|
| | |
|
| | | GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,%s", npcID, strongerLV, difficulty, battleDict)
|
| | | isLog and GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,reModelID=%s,%s", npcID, strongerLV, difficulty, reModelID, battleDict)
|
| | | return battleDict
|
| | |
|
| | | def GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV):
|
| | |
| | |
|
| | | return skillIDList
|
| | |
|
| | | def GetNPCStrongerAttrDict(npcID, lvIpyData, npcStronger, difficulty):
|
| | | def GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog=True):
|
| | | ## 获取NPC成长属性
|
| | | # @param strongerLV: 成长等级
|
| | | # @param difficulty: 难度系数
|
| | |
|
| | | batAttrDict = {}
|
| | | if not lvIpyData or not npcStronger or not difficulty:
|
| | | if not lvReIpyData or not npcStronger or not difficulty:
|
| | | return batAttrDict
|
| | | lv = lvIpyData.GetLV()
|
| | | lv = lvReIpyData.GetLV()
|
| | | for attrID in ChConfig.CalcBattleAttrIDList:
|
| | | attrIpyData = IpyGameDataPY.GetIpyGameData("PlayerAttr", attrID)
|
| | | if not attrIpyData:
|
| | | continue
|
| | | attrName = attrIpyData.GetParameter()
|
| | | if not hasattr(lvIpyData, "GetRe%s" % attrName):
|
| | | if not hasattr(lvReIpyData, "GetRe%s" % attrName):
|
| | | continue
|
| | | reValue = getattr(lvIpyData, "GetRe%s" % attrName)() # 基础参考值
|
| | | reValue = getattr(lvReIpyData, "GetRe%s" % attrName)() # 基础参考值
|
| | | ratio = getattr(npcStronger, "Get%sRatio" % attrName)() if hasattr(npcStronger, "Get%sRatio" % attrName) else 1 # 属性系数
|
| | | attrValue = int(reValue * ratio * difficulty)
|
| | | batAttrDict[attrID] = attrValue
|
| | | #GameWorld.DebugLogEx(" attrID=%s,attrValue=%s,reValue=%s,ratio=%s,difficulty=%s", attrID, attrValue, reValue, ratio, difficulty)
|
| | |
|
| | | GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
|
| | | isLog and GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
|
| | | return batAttrDict
|
| | |
|
| | | def SummonLineupObjs(batLineup, faction, num, lineupInfo, reqPlayerID=0):
|
| | |
| | | if not reqRet:
|
| | | return
|
| | | funcLineID = reqRet[1] if len(reqRet) > 1 else funcLineID
|
| | | GameWorld.DebugLogEx(" funcLineID=%s", funcLineID, playerID)
|
| | |
|
| | | fbIpyData = FBCommon.GetFBIpyData(mapID)
|
| | | fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID, False)
|
| | | if fbIpyData:
|
| | | if not fbLineIpyData:
|
| | | GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
|
| | | return
|
| | | #if not fbLineIpyData:
|
| | | # GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
|
| | | # return
|
| | | if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, funcLineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
|
| | | return
|
| | |
|
| | | # 攻防方所使用的阵容ID
|
| | | atkLineupID, defLineupID = FBLogic.GetFBPlayerLineupID(curPlayer, mapID, funcLineID)
|
| | | if atkLineupID not in ShareDefine.LineupList or defLineupID not in ShareDefine.LineupList:
|
| | | return
|
| | | |
| | | if CheckFightCD(curPlayer, tick, "TurnFightReqTick"):
|
| | | return
|
| | |
|
| | |
| | | playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
| | | guid = GameWorld.GetGUID()
|
| | |
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | | atkLineupID = ShareDefine.Lineup_Main # 进攻方默认使用主阵容
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID, mapID)
|
| | | if not atkLineupInfo:
|
| | | GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s", atkLineupID, playerID)
|
| | | GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s,mapID=%s", atkLineupID, mapID, playerID)
|
| | | return
|
| | |
|
| | | # 玩家
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
|
| | | return
|
| | |
|
| | | defLineupID = ChConfig.MapLineIDDict.get(mapID, ShareDefine.Lineup_Main)
|
| | | defLineupInfo = GetCacheLineupInfo(tagViewCache, defLineupID)
|
| | | if not defLineupInfo:
|
| | | GameWorld.DebugLogEx("目标玩家没有该阵容数据! tagPlayerID=%s,defLineupID=%s", tagPlayerID, defLineupID, playerID)
|
| | |
| | | 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)
|
| | |
| | |
|
| | | for index, lineupID in enumerate(npcLineupIDList):
|
| | | turnFight.lineupIndex = index
|
| | | GameWorld.DebugLogEx("对战NPC阵容: index=%s, lineupID=%s", index, lineupID)
|
| | | GameWorld.DebugLogEx("对战NPC阵容: mapID=%s,funcLineID=%s,index=%s,lineupID=%s", mapID, funcLineID, index, lineupID)
|
| | | if index > 0:
|
| | | turnFight.nextTurnFight()
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
|
| | |
| | | batObj.SetTiming(ChConfig.TurnTiming_Before) # 重置时机到回合前
|
| | | if turnNum > 1: # 第1回合不用刷新技能
|
| | | RefreshObjSkillByBigTurn(batObj)
|
| | | RefreshObjByBigTurn(turnFight, batObj)
|
| | | RefreshObjByBigTurn(turnFight, batObj, turnNum)
|
| | | batObj.ResetBigTurn() # 每大回合重置
|
| | |
|
| | | if not batObj.IsAlive():
|
| | |
| | | if not curSkill:
|
| | | continue
|
| | | skillID = curSkill.GetSkillID()
|
| | | |
| | | # 每大回合重置能量
|
| | | if curSkill.GetEnergy():
|
| | | for eIndex in range(curSkill.GetEffectCount()):
|
| | | effect = curSkill.GetEffect(eIndex)
|
| | | if effect.GetEffectID() == ChConfig.PassiveEff_EnergySkill and effect.GetEffectValue(2) == 1:
|
| | | curSkill.SetEnergy(0)
|
| | | GameWorld.DebugLogEx(" 每大回合重置技能能量! curID=%s,skillID=%s", curID, skillID)
|
| | | break
|
| | | |
| | | preTurnUseCnt = batObj.GetSkillTurnUseCnt(skillID)
|
| | | remainTime = curSkill.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | |
| | | GameWorld.DebugLogEx(" 更新技能CD: curID=%s,skillID=%s,remainTime=%s", curID, skillID, remainTime)
|
| | | return
|
| | |
|
| | | def RefreshObjByBigTurn(turnFight, batObj):
|
| | | def RefreshObjByBigTurn(turnFight, batObj, turnNum):
|
| | | ## 根据大回合开始刷新buff持续时间,每个大回合-1,第1回合不处理
|
| | | curID = batObj.GetID()
|
| | | buffMgr = batObj.GetBuffManager()
|
| | |
| | | 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, ChConfig.BuffLastTimeType_BigTurnLimit]:
|
| | | 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 in [ChConfig.BuffLastTimeType_BigTurn, ChConfig.BuffLastTimeType_BigTurnLimit]:
|
| | | remainTime = buff.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | | continue
|
| | | remainTime -= 1
|
| | | GameWorld.DebugLogEx(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
|
| | | if lastType == ChConfig.BuffLastTimeType_BigTurnLimit and remainTime > 0:
|
| | | lastTurnMax = skillData.GetLastTime()
|
| | | if lastTurnMax and turnNum > lastTurnMax:
|
| | | remainTime = 0
|
| | | GameWorld.DebugLogEx(" 超过最大限制回合数,强制清除!: 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):
|
| | |
| | | buffMgr = batObj.GetBuffManager()
|
| | | for index in range(buffMgr.GetBuffCount())[::-1]:
|
| | | buff = buffMgr.GetBuffByIndex(index)
|
| | | if not buff: # 有出现过报错,先做下防范,理论上不太可能
|
| | | continue
|
| | | buffID = buff.GetBuffID()
|
| | | skillID = buff.GetSkillID()
|
| | | skillData = buff.GetSkillData()
|
| | |
| | | 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):
|
| | |
| | | killerObjID = killer.GetID() if killer else 0
|
| | | skillID = useSkill.GetSkillID() if useSkill else 0
|
| | | GameWorld.DebugLogEx(" %s 回合战斗主体被击杀: curID=%s,killerObjID=%s,skillID=%s", GetObjName(gameObj), objID, killerObjID, skillID)
|
| | | gameObj.SetDead()
|
| | | gameObj.SetDead(killer)
|
| | | 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
|
| | |
| | | if not os.path.exists(ReportDir):
|
| | | os.makedirs(ReportDir)
|
| | | else:
|
| | | items = os.listdir(ReportDir)
|
| | | for item in items:
|
| | | fullPath = os.path.join(ReportDir, item)
|
| | | try:
|
| | | os.remove(fullPath)
|
| | | except:
|
| | | pass
|
| | | isSaveOne = IpyGameDataPY.GetFuncCfg("TurnFightProcess", 2) # 个人战报是否只保留1份
|
| | | if isSaveOne:
|
| | | items = os.listdir(ReportDir)
|
| | | for item in items:
|
| | | fullPath = os.path.join(ReportDir, item)
|
| | | try:
|
| | | os.remove(fullPath)
|
| | | except:
|
| | | pass
|
| | |
|
| | | saveFilePath = os.path.join(ReportDir, "%s.tfr" % guid)
|
| | | GameWorld.DebugLogEx("战报路径=%s", saveFilePath)
|