| | |
| | | import GameWorld
|
| | | import PlayerLLMJ
|
| | | import PlayerPrestigeSys
|
| | | import CrossServerPackLogic
|
| | | import PlayerSuccess
|
| | | import IpyGameDataPY
|
| | | import PlayerOnline
|
| | | import NPCCommon
|
| | |
| | | import random
|
| | | import time
|
| | | import json
|
| | | import os
|
| | |
|
| | | g_gmTestFightReq = []
|
| | |
|
| | |
| | | self.bossPosView = 0
|
| | | return
|
| | |
|
| | | def getPlayerID(self): return self.turnFight.playerID # 发起的玩家ID
|
| | | def getReqPlayerID(self): return self.turnFight.getReqPlayerID() # 发起的玩家ID
|
| | |
|
| | | def isEmpty(self): return not self.posObjIDDict
|
| | |
|
| | |
| | | self.fightPower = lineupInfo.get("FightPower", 0)
|
| | | self.bossID = lineupInfo.get("BossID", 0)
|
| | | self.bossPosView = lineupInfo.get("BossPosView", 0)
|
| | | SummonLineupObjs(self, self.faction, self.num, lineupInfo, self.getPlayerID())
|
| | | SummonLineupObjs(self, self.faction, self.num, lineupInfo, self.getReqPlayerID())
|
| | | return
|
| | |
|
| | | def clearLineup(self):
|
| | |
| | | 2. 以单阵容方式轮流出场战斗,该方式同样可以使用方式1的逻辑实现,固优先使用方式1战斗逻辑,方便扩展
|
| | | '''
|
| | |
|
| | | def __init__(self, mapID=0, funcLineID=0, playerID=0, isNeedReport=False):
|
| | | self.guid = GameWorld.GetGUID() # 某场战斗的唯一guid,可用于存储记录如战报等
|
| | | self.playerID = playerID # 可能为0,系统后台自动处理的战斗时为0,某个玩家发起则为发起玩家ID,同个玩家ID可能同时存在多场战斗,如主线+其他
|
| | | self.curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID) if playerID else None
|
| | | def __init__(self, guid, mapID=0, funcLineID=0, reqPlayerID=0, reqServerID=0):
|
| | | self.guid = guid # 某场战斗的唯一guid,可用于存储记录如战报等
|
| | | self._reqPlayerID = reqPlayerID # 可能为0,系统后台自动处理的战斗时为0,某个玩家发起则为发起玩家ID,同个玩家ID可能同时存在多场战斗,如主线+其他
|
| | | self._reqServerID = reqServerID # 可能是玩家的服务器ID,或者请求的ServerID
|
| | | self.curPlayer = None
|
| | | self.mapID = mapID
|
| | | self.funcLineID = funcLineID
|
| | | self.state = -1 # -1 代表未战斗
|
| | |
| | | self.winFaction = 0 # 本场战斗结束标记,获胜阵营,为0时代表未结束,所有小队打完或失败才有结果,0-未结束,>0-获胜的阵营
|
| | | self.isWin = False
|
| | | self.batBuffer = "" # 战报buffer,战报暂时只保留最后一个小队的
|
| | | self.isNeedReport = isNeedReport # 是否需要战报
|
| | | self.dateStr = "" # 战报所在文件夹日期
|
| | | self._isNeedReport = False # 是否需要战报
|
| | | self.statMsg = {} # 战斗结果统计信息
|
| | | self.msgDict = {} # 扩展信息字典,一般由MapID绑定的功能决定信息内容 {k:v, ...}
|
| | | self._kvDict = {} # 自定义信息字典,不会被重置 {k:v, ...}
|
| | | self.awardData = None # 战斗奖励设置的数据,可以是任意数据格式,由功能自行决定,会传递给 OnTurnFightAward 处理
|
| | |
|
| | | self.factionDict = {} # 战斗阵营 {faction:BatFaction, ...},一般是只有两个阵营,faction为1或2,每个阵营支持多个阵容
|
| | | self.actionSortList = [] # 阵容行动顺序 [[faction, num], ...]
|
| | |
| | | self.strongerLV = 0 # npc成长等级
|
| | | self.difficulty = 0 # npc难度
|
| | |
|
| | | # pvp 目标
|
| | | self.tagPlayerID = 0
|
| | | self.tagViewCache = None
|
| | | # pvp
|
| | | self._isPVP = False
|
| | | return
|
| | |
|
| | | def setTurnFight(self, mapID, funcLineID, turnMax, isNeedReport=False, msgDict={}):
|
| | | def setTurnFight(self, mapID, funcLineID, turnMax, isNeedReport=False, curPlayer=None, msgDict={}):
|
| | | ## 设置本场回合战斗设定
|
| | | self.mapID = mapID
|
| | | self.funcLineID = funcLineID
|
| | | self.turnMax = turnMax # 最大回合数
|
| | | self.isNeedReport = isNeedReport
|
| | | self._isNeedReport = isNeedReport
|
| | | self.curPlayer = curPlayer
|
| | | self.setPVE()
|
| | | self.setPVP()
|
| | | self.msgDict = {}
|
| | | self._kvDict = {}
|
| | | self.awardData = None
|
| | | self.nextTurnFight(msgDict)
|
| | | return
|
| | | |
| | | def getReqPlayerID(self): return self._reqPlayerID
|
| | | def getReqServerID(self): return self._reqServerID
|
| | |
|
| | | def setPVE(self, lineupIDList=[], strongerLV=0, difficulty=0):
|
| | | self.lineupIndex = 0
|
| | | self.lineupIDList = lineupIDList
|
| | | self.strongerLV = strongerLV
|
| | | self.difficulty = difficulty
|
| | | self._isPVP = False
|
| | | return
|
| | |
|
| | | def setPVP(self, tagPlayerID=0, tagViewCache=None):
|
| | | self.tagPlayerID = tagPlayerID
|
| | | self.tagViewCache = tagViewCache
|
| | | def setPVP(self):
|
| | | self._isPVP = True
|
| | | return
|
| | |
|
| | | def getPVPPlayerID(self): return self.tagPlayerID # 获取PVP目标玩家ID,也可用于判断是否PVP
|
| | | def isPVP(self): return self._isPVP
|
| | |
|
| | | def isFBMap(self):
|
| | | ## 是否副本地图中,非主线的均视为副本
|
| | |
| | |
|
| | | def GetDictByKey(self, key): return self._kvDict.get(key, 0)
|
| | | def SetDict(self, key, value): self._kvDict[key] = value
|
| | | |
| | | #def setPVPTeam(self):
|
| | | # return
|
| | |
|
| | | def nextTurnFight(self, msgDict={}):
|
| | | ## 一般用于玩家发起的战斗,在需要保留玩家阵容属性及状态的情况下,重置回合进入下一场战斗
|
| | |
| | | for _, _, _, faction, num in sortList:
|
| | | self.actionSortList.append([faction, num])
|
| | |
|
| | | GameWorld.DebugLog("阵容战力排序[isPlayer, fp, sortV, f, n]: %s" % sortList)
|
| | | GameWorld.DebugLog("阵容行动顺序[f, n]: %s" % self.actionSortList)
|
| | | GameWorld.DebugLogEx("阵容战力排序[isPlayer, fp, sortV, f, n]: %s", sortList)
|
| | | GameWorld.DebugLogEx("阵容行动顺序[f, n]: %s", self.actionSortList)
|
| | | return
|
| | |
|
| | | def getBatFaction(self, faction=ChConfig.Def_FactionA):
|
| | |
| | |
|
| | | def syncState(self, state, msgDict={}):
|
| | | self.state = state
|
| | | if state == FightState_Award:
|
| | | self.statMsg = msgDict
|
| | | msg = json.dumps(msgDict, ensure_ascii=False)
|
| | | msg = msg.replace(" ", "")
|
| | | clientPack = ChPyNetSendPack.tagMCTurnFightState()
|
| | |
| | | headStr = "%02x%02x" % (clientPack.Head.Cmd, clientPack.Head.SubCmd)
|
| | | else:
|
| | | headStr = "%02x%02x" % (clientPack.Cmd, clientPack.SubCmd)
|
| | | if self.isNeedReport:
|
| | | if self._isNeedReport:
|
| | | packBuff = clientPack.GetBuffer()
|
| | | buffLen = len(packBuff)
|
| | | GameWorld.DebugLog("回合战斗过程封包: %s, len:%s" % (headStr, buffLen))
|
| | | #GameWorld.DebugLogEx("回合战斗过程封包: %s, len:%s, %s", headStr, buffLen, CommFunc.B2Hex(packBuff))
|
| | | GameWorld.DebugLogEx("回合战斗过程封包: %s, len:%s", headStr, buffLen)
|
| | | self.batBuffer += CommFunc.WriteWORD("", buffLen)
|
| | | self.batBuffer += packBuff
|
| | | ObjPool.GetPoolMgr().release(clientPack)
|
| | | else:
|
| | | GameWorld.DebugLog("回合战斗过程封包: %s" % (headStr))
|
| | | GameWorld.DebugLogEx("回合战斗过程封包: %s", headStr)
|
| | | # 有玩家的统一每个包单独发送,同样也支持战报统计
|
| | | if self.curPlayer:
|
| | | NetPackCommon.SendFakePack(self.curPlayer, clientPack)
|
| | |
| | | self.turnFightDict = {} # {guid:TurnFight, ...}
|
| | | return
|
| | |
|
| | | def addTurnFight(self, mapID, funcLineID=0, playerID=0, isNeedReport=False):
|
| | | tf = ObjPool.GetPoolMgr().acquire(TurnFight, mapID, funcLineID, playerID, isNeedReport)
|
| | | def addTurnFight(self, guid, mapID, funcLineID=0, reqPlayerID=0, reqServerID=0):
|
| | | tf = ObjPool.GetPoolMgr().acquire(TurnFight, guid, mapID, funcLineID, reqPlayerID, reqServerID)
|
| | | if not tf:
|
| | | tf = TurnFight(mapID, funcLineID, playerID, isNeedReport) # 一般是不可能,为了点出代码
|
| | | tf = TurnFight(guid, mapID, funcLineID, reqPlayerID, reqServerID) # 一般是不可能,为了点出代码
|
| | | self.turnFightDict[tf.guid] = tf
|
| | | return tf
|
| | |
|
| | |
| | | self.levelNum = 0 # 关卡编号
|
| | | self.waveMax = 6 # 本关最大波数,每波有多个小队,每个小队即为一张战斗 TurnFight
|
| | | self.wave = 0 # 当前刷怪波,注意不是玩家当前进度波,比如被击杀会回退一波
|
| | | self.turnFight = GetTurnFightMgr().addTurnFight(ChConfig.Def_FBMapID_Main, 0, playerID)
|
| | | self.turnFight = GetTurnFightMgr().addTurnFight(GameWorld.GetGUID(), ChConfig.Def_FBMapID_Main, 0, playerID)
|
| | |
|
| | | # 主线小怪战斗额外数据,一般用于分割与主线战斗表现无关的附加功能内容
|
| | | self.useZhanchui = 0
|
| | |
| | | olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
|
| | | lineup = olPlayer.GetLineup(lineupID)
|
| | | if lineup.IsEmpty():
|
| | | GameWorld.DebugLog("玩家没有目标阵容默认取主阵容! lineupID=%s" % lineupID, curPlayer.GetPlayerID())
|
| | | GameWorld.DebugLogEx("玩家没有目标阵容默认取主阵容! lineupID=%s", lineupID, curPlayer.GetPlayerID())
|
| | | lineup = olPlayer.GetLineup(ShareDefine.Lineup_Main)
|
| | | return lineup
|
| | |
|
| | |
| | | hero = lineup.GetLineupHero(posNum)
|
| | | heroID = hero.heroID
|
| | | itemIndex = hero.itemIndex
|
| | | userData = ""
|
| | | heroLV = 1
|
| | | star = 0
|
| | | if itemIndex >= 0 and itemIndex < curPack.GetCount():
|
| | | heroItem = curPack.GetAt(itemIndex)
|
| | | if heroItem and not heroItem.IsEmpty():
|
| | | userData = heroItem.GetUserData()
|
| | | heroLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroLV)
|
| | | star = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | #breakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | #awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | |
|
| | | skillIDlist = []
|
| | | skillIDlist += hero.heroSkillIDList
|
| | |
| | | "HeroID":heroID,
|
| | | "SkinID":hero.skinID,
|
| | | "LV":heroLV,
|
| | | "Data":userData,
|
| | | "Star":star,
|
| | | #"BreakLV":breakLV,
|
| | | #"AwakeLV":awakeLV,
|
| | | "FightPower":hero.fightPower,
|
| | | "AttrDict":{str(k):v for k, v in hero.heroBatAttrDict.items() if v > 0},
|
| | | "SkillIDList":skillIDlist,
|
| | |
| | |
|
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":bossID, "BossPosView":bossPosView}
|
| | | return lineupInfo
|
| | |
|
| | | def GMTestPVP(curPlayer, tagPlayerID=0):
|
| | | ## GM测试PVP战斗
|
| | | if not tagPlayerID:
|
| | | tagPlayerID = curPlayer.GetPlayerID()
|
| | | |
| | | guid = GameWorld.GetGUID()
|
| | | mapID, funcLineID = 0, 0
|
| | | |
| | | tagViewCache = PlayerViewCache.FindBattleViewCache(tagPlayerID)
|
| | | if not tagViewCache:
|
| | | PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
|
| | | return
|
| | | defLineupInfo = GetCacheLineupInfo(tagViewCache, ShareDefine.Lineup_Main)
|
| | | lineupDictA = {1:GetPlayerLineupInfo(curPlayer, ShareDefine.Lineup_Main)}
|
| | | lineupDictB = {1:defLineupInfo}
|
| | | turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB)
|
| | | return turnFight.costTime if turnFight else None
|
| | |
|
| | | def GMTestFight(curPlayer, heroIDList, isAllSkill):
|
| | | ## GM测试战斗,指定武将
|
| | |
| | | return
|
| | | heroID = npcData.GetRelatedHeroID()
|
| | | npcLV = npcData.GetLV()
|
| | | star, breakLV, awakeLV = 0, 0, 0
|
| | |
|
| | | lvIpyData = None
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | |
| | | npcLV = strongerLV
|
| | | if not lvIpyData:
|
| | | lvIpyData = IpyGameDataPY.GetIpyGameData("PlayerLV", npcLV)
|
| | | |
| | | if heroIpyData and lvIpyData:
|
| | | if lvIpyData:
|
| | | star = lvIpyData.GetReHeroStar()
|
| | | breakLV = lvIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData:
|
| | | skinIDList = heroIpyData.GetSkinIDList()
|
| | | skinID = skinIDList[0] if skinIDList else 0
|
| | | skillIDList = GetNPCHeroSkillIDList(heroID, heroIpyData, lvIpyData.GetReHeroBreakLV(), lvIpyData.GetReHeroAwakeLV())
|
| | | skillIDList = GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV)
|
| | | else:
|
| | | heroID = 0
|
| | | skinID = 0
|
| | |
| | | random.shuffle(randSkillIDExList)
|
| | | randSkillIDExList = randSkillIDExList[:skillExCnt]
|
| | | skillIDList += randSkillIDExList
|
| | | GameWorld.DebugLog("阵容boss技能: %s, 随机附加技能: %s" % (skillIDList, randSkillIDExList))
|
| | | GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
|
| | |
|
| | | # 成长怪属性
|
| | | batAttrDict = GetNPCStrongerAttrDict(npcID, lvIpyData, npcStronger, difficulty)
|
| | |
| | | "HeroID":heroID,
|
| | | "SkinID":skinID,
|
| | | "LV":npcLV,
|
| | | "Star":star,
|
| | | #"BreakLV":breakLV,
|
| | | #"AwakeLV":awakeLV,
|
| | | "AttrDict":{str(k):v for k, v in batAttrDict.items() if v > 0},
|
| | | "SkillIDList":skillIDList,
|
| | | }
|
| | |
|
| | | GameWorld.DebugLog("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,%s" % (npcID, strongerLV, difficulty, battleDict))
|
| | | GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,%s", npcID, strongerLV, difficulty, battleDict)
|
| | | return battleDict
|
| | |
|
| | | def GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV):
|
| | |
| | | ratio = getattr(npcStronger, "Get%sRatio" % attrName)() if hasattr(npcStronger, "Get%sRatio" % attrName) else 1 # 属性系数
|
| | | attrValue = int(reValue * ratio * difficulty)
|
| | | batAttrDict[attrID] = attrValue
|
| | | #GameWorld.DebugLog(" attrID=%s,attrValue=%s,reValue=%s,ratio=%s,difficulty=%s" % (attrID, attrValue, reValue, ratio, difficulty))
|
| | | #GameWorld.DebugLogEx(" attrID=%s,attrValue=%s,reValue=%s,ratio=%s,difficulty=%s", attrID, attrValue, reValue, ratio, difficulty)
|
| | |
|
| | | GameWorld.DebugLog("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s" % (npcID, lv, difficulty, batAttrDict))
|
| | | GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
|
| | | return batAttrDict
|
| | |
|
| | | def SummonLineupObjs(batLineup, faction, num, lineupInfo, playerID=0):
|
| | | def SummonLineupObjs(batLineup, faction, num, lineupInfo, reqPlayerID=0):
|
| | | '''召唤阵容战斗实例
|
| | | @param faction: 所属阵营,目前支持两个阵营,1或2
|
| | | @param num: 战斗阵容在该阵营上的编号,1V1时默认1,多对多时1~n
|
| | | @param lineupInfo: 阵容信息
|
| | | @param playerID: 发起的玩家ID,系统场次为0
|
| | | @param reqPlayerID: 发起的玩家ID,系统场次为0
|
| | | '''
|
| | | lineupPlayerID = lineupInfo.get("PlayerID", 0) # 阵容所属玩家ID
|
| | | npcLineupID = lineupInfo.get("NPCLineupID", 0)
|
| | | GameWorld.DebugLog("SummonLineupObjs faction:%s,num:%s,npcLineupID=%s,lineupPlayerID=%s" % (faction, num, npcLineupID, lineupPlayerID), playerID)
|
| | | if playerID:
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if not curPlayer:
|
| | | return
|
| | | |
| | | GameWorld.DebugLogEx("SummonLineupObjs faction:%s,num:%s,npcLineupID=%s,lineupPlayerID=%s", faction, num, npcLineupID, lineupPlayerID)
|
| | | |
| | | turnFight = batLineup.turnFight
|
| | | tfGUID = turnFight.guid
|
| | | heroDict = lineupInfo.get("Hero", {})
|
| | |
| | | heroID = heroInfo.get("HeroID", 0)
|
| | | skinID = heroInfo.get("SkinID", 0)
|
| | | lv = heroInfo.get("LV", 1)
|
| | | star = heroInfo.get("Star", 0)
|
| | | specialty, atkDistType, country, sex, job = 0, 1, 0, 1, 0
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | | if heroIpyData:
|
| | |
| | | batObj.SetLineupPos(posNum, num)
|
| | | batObj.SetFightPower(fightPower)
|
| | | batObj.SetLV(lv)
|
| | | batObj.SetStar(star)
|
| | | batObj.SetAtkDistType(atkDistType)
|
| | | batObj.SetSpecialty(specialty)
|
| | | batObj.SetCountry(country)
|
| | |
| | |
|
| | | batLineup.posObjIDDict[posNum] = objID
|
| | | batLineup.heroObjIDDict[heroID] = objID
|
| | | GameWorld.DebugLog("AddBatObj %s,skill=%s" % (GetObjName(batObj), skillManager.GetSkillIDList()))
|
| | | GameWorld.DebugLogEx("AddBatObj %s,lv=%s,star=%s,skill=%s", GetObjName(batObj), lv, star, skillManager.GetSkillIDList())
|
| | | ResetObjSkill(batObj)
|
| | |
|
| | | if npcID:
|
| | | #副本指定NPC属性
|
| | | fbNPCInitAttrDict = FBLogic.GetFBNPCInitAttr(curPlayer, turnFight, batObj)
|
| | | fbNPCInitAttrDict = FBLogic.GetFBNPCInitAttr(turnFight, batObj)
|
| | | if fbNPCInitAttrDict:
|
| | | GameWorld.DebugLog("副本指定NPC初始化属性: npcID=%s, %s" % (npcID, fbNPCInitAttrDict))
|
| | | GameWorld.DebugLogEx("副本指定NPC初始化属性: npcID=%s, %s", npcID, fbNPCInitAttrDict)
|
| | | attrDict = {str(k):v for k, v in fbNPCInitAttrDict.items()} # 统一格式
|
| | | #attrDict[str(ChConfig.AttrID_MaxHP)] = 10000000000
|
| | | batObj.InitBatAttr({int(k):v for k, v in attrDict.items()}, initXP)
|
| | |
|
| | | return
|
| | |
| | | batFaction = turnFight.getBatFaction(ChConfig.Def_FactionA)
|
| | | if not batFaction:
|
| | | return
|
| | | GameWorld.DebugLog("切换小队重置玩家阵容武将...")
|
| | | GameWorld.DebugLogEx("切换小队重置玩家阵容武将...")
|
| | | batLineup = batFaction.getBatlineup(1) # 只处理玩家阵容
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | |
| | | continue
|
| | | objName = GetObjName(batObj)
|
| | | if not batObj.IsAlive():
|
| | | GameWorld.DebugLog(" 已被击杀不处理! %s" % (objName))
|
| | | GameWorld.DebugLogEx(" 已被击杀不处理! %s", objName)
|
| | | continue
|
| | | GameWorld.DebugLog("重置武将: %s, HP:%s/%s, XP:%s" % (objName, batObj.GetHP(), batObj.GetMaxHP(), batObj.GetXP()))
|
| | | GameWorld.DebugLogEx("重置武将: %s, HP:%s/%s, XP:%s", objName, batObj.GetHP(), batObj.GetMaxHP(), batObj.GetXP())
|
| | |
|
| | | # 清除buff
|
| | | buffMgr = batObj.GetBuffManager()
|
| | |
| | | pubCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 1)
|
| | | if pubCD:
|
| | | if tfMgr.lastRequestTick and tick - tfMgr.lastRequestTick <= pubCD:
|
| | | GameWorld.DebugLog("回合制战斗请求服务器公共CD中!")
|
| | | GameWorld.DebugLogEx("回合制战斗请求服务器公共CD中!")
|
| | | PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
|
| | | return True
|
| | |
|
| | |
| | | selfCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 2)
|
| | | lastTick = curPlayer.GetDictByKey(selfKey)
|
| | | if selfCD and lastTick and tick - lastTick <= selfCD:
|
| | | GameWorld.DebugLog("回合制战斗请求CD中: %s" % selfKey)
|
| | | GameWorld.DebugLogEx("回合制战斗请求CD中: %s", selfKey)
|
| | | PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
|
| | | return True
|
| | |
|
| | |
| | | ''' 本战斗会一次性处理完所有小队战斗,以战报的形式下发,目前除了主线小怪分段战斗外,均使用该战斗
|
| | | '''
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | mapID = clientData.MapID
|
| | | funcLineID = clientData.FuncLineID
|
| | | tagType = clientData.TagType
|
| | | tagID = clientData.TagID
|
| | | valueList = clientData.ValueList
|
| | |
|
| | | GameWorld.DebugLog("----- 回合制战斗请求: mapID=%s,funcLineID=%s,tagType=%s,tagID=%s,valueList=%s" |
| | | % (mapID, funcLineID, tagType, tagID, valueList), curPlayer.GetPlayerID())
|
| | | GameWorld.DebugLogEx("----- 回合制战斗请求: mapID=%s,funcLineID=%s,tagType=%s,tagID=%s,valueList=%s", mapID, funcLineID, tagType, tagID, valueList, playerID)
|
| | |
|
| | | reqRet = FBLogic.OnTurnFightRequest(curPlayer, mapID, funcLineID, tagType, tagID, valueList)
|
| | | if not reqRet:
|
| | |
| | | fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID, False)
|
| | | if fbIpyData:
|
| | | if not fbLineIpyData:
|
| | | GameWorld.DebugLog("不存在该副本功能线路! mapID=%s,funcLineID=%s" % (mapID, funcLineID))
|
| | | GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
|
| | | return
|
| | | if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, funcLineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
|
| | | return
|
| | |
| | | if CheckFightCD(curPlayer, tick, "TurnFightReqTick"):
|
| | | return
|
| | |
|
| | | reqPlayerID = playerID
|
| | | playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
| | | guid = GameWorld.GetGUID()
|
| | | |
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | | if not atkLineupInfo:
|
| | | GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s", atkLineupID, playerID)
|
| | | return
|
| | | |
| | | # 玩家
|
| | | if tagType == 1:
|
| | | if not OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagID):
|
| | | tagPlayerID = tagID
|
| | | tagViewCache = PlayerViewCache.FindBattleViewCache(tagPlayerID)
|
| | | if not tagViewCache:
|
| | | # 跨服玩家待扩展
|
| | | GameWorld.DebugLogEx("目标玩家没有缓存数据! tagPlayerID=%s", tagPlayerID, playerID)
|
| | | PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
|
| | | return
|
| | | |
| | | defLineupInfo = GetCacheLineupInfo(tagViewCache, defLineupID)
|
| | | if not defLineupInfo:
|
| | | GameWorld.DebugLogEx("目标玩家没有该阵容数据! tagPlayerID=%s,defLineupID=%s", tagPlayerID, defLineupID, playerID)
|
| | | PlayerControl.NotifyCode(curPlayer, "TagNoLineup")
|
| | | return
|
| | | |
| | | lineupDictA = {1:atkLineupInfo}
|
| | | lineupDictB = {1:defLineupInfo}
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, reqData=[tagType, tagID, valueList])
|
| | |
|
| | | # NPC
|
| | | else:
|
| | |
| | | if not ret:
|
| | | return
|
| | | npcLineupIDList, strongerLV, difficulty = ret
|
| | | if not OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
|
| | | |
| | | if not npcLineupIDList:
|
| | | return
|
| | | |
| | | #if mapID == ChConfig.Def_FBMapID_MainBoss:
|
| | | # # 停止主线小怪战斗、清空
|
| | | # mainFightMgr = GetMainFightMgr(curPlayer)
|
| | | # mainTF = mainFightMgr.turnFight
|
| | | # if mainTF.isInFight():
|
| | | # mainTF.exitFight()
|
| | | |
| | | lineupDictA = {1:atkLineupInfo}
|
| | | lineupDictB = None
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty)
|
| | |
|
| | | return True
|
| | |
|
| | | def OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("OnTurnFightVSNPC: mapID=%s,funcLineID=%s,atkLineupID=%s,npcLineupIDList=%s,strongerLV=%s,difficulty=%s" |
| | | % (mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty), playerID)
|
| | | if not npcLineupIDList:
|
| | | def AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID=0, playerServerID=0, npcLineupIDList=[], strongerLV=0, difficulty=0, reqData=None):
|
| | | '''添加进战斗请求队列,这里做战斗分发处理,由当前服务器根据当前服务器情况分配到本机子的其他战斗地图,或直接本地图处理
|
| | | @param lineupDictA: 阵营A所有阵容{阵容编号:{阵容信息}, ...}
|
| | | @param lineupDictB: 阵营B所有阵容{阵容编号:{阵容信息}, ...},pvp时用
|
| | | @param reqPlayerID: 请求的玩家ID,如果是系统自动处理的战斗场次,则为0
|
| | | @param npcLineupIDList: pve时用,要对战的npc阵容ID列表
|
| | | @param strongerLV: pve时用,npc属性成长等级
|
| | | @param difficulty: pve时用,npc属性难度系数
|
| | | @param reqData: 每场战斗自定义的请求信息,由功能自己决定,任意结构,透传参数
|
| | | '''
|
| | | |
| | | if not lineupDictA:
|
| | | return
|
| | |
|
| | | lineupMainInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | | if not lineupMainInfo:
|
| | | GameWorld.DebugLog("玩家没有该阵容数据! atkLineupID=%s" % atkLineupID, playerID)
|
| | | if not lineupDictB and not npcLineupIDList:
|
| | | # pvp 或 pve 必须要满足其中一种
|
| | | return
|
| | | |
| | | fromServerID = GameWorld.GetGameWorld().GetServerID()
|
| | | reqInfo = [guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData]
|
| | | multiMapSet = IpyGameDataPY.GetFuncCfg("TurnFightProcess", 1)
|
| | | #multiMapSet = 0
|
| | | # 多地图战斗 0-本地图处理;1-多地图处理;2-debug模式默认本地图处理,非debug默认多地图处理
|
| | | isMultiMap = False
|
| | | if multiMapSet == 1:
|
| | | isMultiMap = True
|
| | | elif multiMapSet == 2:
|
| | | if not GameWorld.GetGameWorld().GetDebugLevel():
|
| | | isMultiMap = True
|
| | | |
| | | if isMultiMap:
|
| | | CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
|
| | | else:
|
| | | SSMsg_BattleRequest(reqInfo, fromServerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID):
|
| | | ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | | |
| | | if npcLineupIDList:
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | | else:
|
| | | turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID)
|
| | | |
| | | winFaction = None
|
| | | statMsg = {}
|
| | | dateStr = ""
|
| | | if turnFight:
|
| | | statMsg = turnFight.statMsg
|
| | | winFaction = turnFight.winFaction
|
| | | dateStr = turnFight.dateStr
|
| | | |
| | | retInfo = [guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData]
|
| | | |
| | | # 本地图自己处理的
|
| | | if fromServerID == GameWorld.GetGameWorld().GetServerID():
|
| | | SSMsg_BattleResult(retInfo, fromServerID)
|
| | | |
| | | # 其他服务器地图请求的,发送战斗结果回去
|
| | | else:
|
| | | CrossServerPackLogic.SendToServer(ShareDefine.SSMsg_BattleResult, retInfo, [fromServerID], playerID=reqPlayerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleResult(retInfo, fromServerID):
|
| | | ## 收到战斗结果信息
|
| | | |
| | | guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
|
| | | |
| | | curPlayer = None
|
| | | if reqPlayerID:
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(reqPlayerID)
|
| | | if not curPlayer:
|
| | | # 收到战斗结果时玩家已离线,不处理,可视为该战斗无效,玩家重新请求
|
| | | return
|
| | | |
| | | if winFaction == None:
|
| | | if curPlayer:
|
| | | PlayerControl.NotifyCode(curPlayer, "BattleFail")
|
| | | return
|
| | | |
| | | # 根据战斗结果结算奖励
|
| | | awardDict = {}
|
| | | FBLogic.OnTurnFightAward(curPlayer, guid, mapID, funcLineID, winFaction, statMsg, dateStr, reqData, awardDict)
|
| | | |
| | | if curPlayer:
|
| | | isWin = winFaction == ChConfig.Def_FactionA
|
| | | SyncTurnFightRet(curPlayer, guid, mapID, funcLineID, reqData, isWin, statMsg, dateStr, awardDict)
|
| | | |
| | | return
|
| | |
|
| | | def DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, playerLineupDict, npcLineupIDList, strongerLV, difficulty):
|
| | | '''执行PVE战斗,支持多小队
|
| | | '''
|
| | |
|
| | | turnMax = GetTurnMax(mapID)
|
| | | if mapID == ChConfig.Def_FBMapID_MainBoss:
|
| | | # 停止主线小怪战斗、清空
|
| | | mainFightMgr = GetMainFightMgr(curPlayer)
|
| | | mainTF = mainFightMgr.turnFight
|
| | | if mainTF.isInFight():
|
| | | mainTF.exitFight()
|
| | | |
| | | |
| | | tfMgr = GetTurnFightMgr()
|
| | | turnFight = tfMgr.addTurnFight(mapID, funcLineID, playerID)
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, playerServerID)
|
| | | guid = turnFight.guid
|
| | |
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, True)
|
| | | turnFight.setPVE(npcLineupIDList, strongerLV, difficulty)
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionA, {1:lineupMainInfo})
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionA, playerLineupDict)
|
| | |
|
| | | for index, lineupID in enumerate(npcLineupIDList):
|
| | | turnFight.lineupIndex = index
|
| | | GameWorld.DebugLog("对战NPC阵容: index=%s, lineupID=%s" % (index, lineupID))
|
| | | GameWorld.DebugLogEx("对战NPC阵容: index=%s, lineupID=%s", index, lineupID)
|
| | | if index > 0:
|
| | | turnFight.nextTurnFight()
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
|
| | | turnFight.sortActionQueue()
|
| | | turnFight.startFight()
|
| | |
|
| | | __processTurnFight(turnFight.guid)
|
| | | __processTurnFight(turnFight)
|
| | |
|
| | | if not turnFight.isWin:
|
| | | break
|
| | |
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
|
| | | SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer) # 同步战报
|
| | | #在同步战报后再处理结算奖励,与战斗表现分离
|
| | | FBLogic.OnTurnFightAward(curPlayer, turnFight, mapID, funcLineID, turnFight.awardData)
|
| | | saveOK = __saveBatBuffer(turnFight)
|
| | | tfMgr.delTurnFight(guid)
|
| | | return True
|
| | | return turnFight if saveOK else None
|
| | |
|
| | | def OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagPlayerID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.DebugLog("OnTurnFightVSPlayer: mapID=%s,funcLineID=%s,atkLineupID=%s,defLineupID=%s,tagPlayerID=%s" |
| | | % (mapID, funcLineID, atkLineupID, defLineupID, tagPlayerID), playerID)
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | | if not atkLineupInfo:
|
| | | GameWorld.DebugLog("玩家没有该阵容数据! atkLineupID=%s" % atkLineupID, playerID)
|
| | | return
|
| | | |
| | | tagViewCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | if not tagViewCache:
|
| | | GameWorld.DebugLog("目标玩家没有缓存数据! tagPlayerID=%s" % tagPlayerID, playerID)
|
| | | PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
|
| | | return
|
| | | defLineupInfo = GetCacheLineupInfo(tagViewCache, defLineupID)
|
| | | if not defLineupInfo:
|
| | | GameWorld.DebugLog("目标玩家没有该阵容数据! tagPlayerID=%s,defLineupID=%s" % (tagPlayerID, defLineupID), playerID)
|
| | | PlayerControl.NotifyCode(curPlayer, "TagNoLineup")
|
| | | return
|
| | | #@CommFunc.DoCProfile
|
| | | def DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID=0, playerServerID=0):
|
| | | '''执行PVP战斗,只处理战斗,不关心功能及curPlayer相关
|
| | | @param lineupDictA: 阵营A所有阵容{阵容编号:{阵容信息}, ...}
|
| | | @param lineupDictB: 阵营B所有阵容{阵容编号:{阵容信息}, ...}
|
| | | @param reqPlayerID: 请求的玩家ID,如果是系统自动处理的战斗场次,则为0
|
| | | '''
|
| | |
|
| | | turnMax = GetTurnMax(mapID)
|
| | |
|
| | | tfMgr = GetTurnFightMgr()
|
| | | turnFight = tfMgr.addTurnFight(mapID, funcLineID, playerID)
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, playerServerID)
|
| | | guid = turnFight.guid
|
| | |
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, True)
|
| | | turnFight.setPVP(tagPlayerID, tagViewCache)
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionA, {1:atkLineupInfo})
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:defLineupInfo})
|
| | | turnFight.setPVP()
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionA, lineupDictA)
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, lineupDictB)
|
| | | turnFight.sortActionQueue()
|
| | | turnFight.startFight()
|
| | |
|
| | | __processTurnFight(turnFight.guid)
|
| | | __processTurnFight(turnFight)
|
| | |
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
|
| | | SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer)
|
| | | FBLogic.OnTurnFightAward(curPlayer, turnFight, mapID, funcLineID, turnFight.awardData)
|
| | | saveOK = __saveBatBuffer(turnFight)
|
| | | tfMgr.delTurnFight(guid)
|
| | | return True
|
| | | return turnFight if saveOK else None
|
| | |
|
| | | def GetTurnMax(mapID):
|
| | | if mapID == ChConfig.Def_FBMapID_Main:
|
| | |
| | | __doSetFightPoint(curPlayer, reqValue)
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("------------------- 主线战斗请求: reqType=%s" % reqType, curPlayer.GetPlayerID())
|
| | | GameWorld.DebugLogEx("------------------- 主线战斗请求: reqType=%s", reqType, curPlayer.GetPlayerID())
|
| | | mainFightMgr = GetMainFightMgr(curPlayer)
|
| | | mainFightMgr.resetMainFightExDataRec() # 请求时补重置,防止异常时重复结算逻辑
|
| | |
|
| | |
| | | PlayerLLMJ.AddUseZhanchui(curPlayer, useZhanchui)
|
| | | PlayerPrestigeSys.AddRealmTaskValue(curPlayer, PlayerPrestigeSys.RealmTaskType_UseXiantao, useZhanchui)
|
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_CutTree, useZhanchui)
|
| | | PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_OSACutTree, useZhanchui)
|
| | | PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_CutTree, useZhanchui)
|
| | |
|
| | | # 历练秘境额外经验
|
| | |
| | | if killNPCCnt > 0:
|
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_KillNPC, killNPCCnt)
|
| | | PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_KillNPC, killNPCCnt)
|
| | | PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_OSAKillNPC, killNPCCnt)
|
| | |
|
| | | # 结算逻辑最后重置数据
|
| | | mainFightMgr.resetMainFightExDataRec()
|
| | |
| | |
|
| | | def __doSetFightPoint(curPlayer, fightPoint):
|
| | | ## 设置消耗倍值
|
| | | GameWorld.DebugLog("设置战锤消耗倍值: %s" % fightPoint)
|
| | | GameWorld.DebugLogEx("设置战锤消耗倍值: %s", fightPoint)
|
| | | needTreeLVList = IpyGameDataPY.GetFuncEvalCfg("AutoGuaji", 1)
|
| | | if fightPoint < 1 or fightPoint > len(needTreeLVList):
|
| | | return
|
| | | needTreeLV = needTreeLVList[fightPoint - 1]
|
| | | treeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLV)
|
| | | if treeLV < needTreeLV:
|
| | | GameWorld.DebugLog("祝福树等级不足: treeLV=%s < %s" % (treeLV, needTreeLV))
|
| | | GameWorld.DebugLogEx("祝福树等级不足: treeLV=%s < %s", treeLV, needTreeLV)
|
| | | return
|
| | | curPlayer.SetFightPoint(fightPoint)
|
| | | return
|
| | |
| | | # @param isRestStart: 是否从休息状态重新开始的
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | chapterID, levelNum, wave = PlayerControl.GetMainLevelNowInfo(curPlayer)
|
| | | GameWorld.DebugLog("请求关卡波战斗: chapterID=%s,levelNum=%s,wave=%s,isRestStart=%s" % (chapterID, levelNum, wave, isRestStart), playerID)
|
| | | GameWorld.DebugLogEx("请求关卡波战斗: chapterID=%s,levelNum=%s,wave=%s,isRestStart=%s", chapterID, levelNum, wave, isRestStart, playerID)
|
| | | fightPoint = max(curPlayer.GetFightPoint(), 1)
|
| | | if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_Xiantao, fightPoint):
|
| | | GameWorld.DebugLog("战锤不足,无法开始!")
|
| | | GameWorld.DebugLogEx("战锤不足,无法开始!")
|
| | | return
|
| | | chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID)
|
| | | if not chapterIpyData:
|
| | |
| | |
|
| | | lineupMainInfo = GetPlayerLineupInfo(curPlayer, ShareDefine.Lineup_Main)
|
| | | if not lineupMainInfo:
|
| | | GameWorld.DebugLog("没有设置主阵容!", playerID)
|
| | | GameWorld.DebugLogEx("没有设置主阵容!", playerID)
|
| | | return
|
| | |
|
| | | strongerLV = levelIpyData.GetNPCLV()
|
| | |
| | | mainFightMgr.wave = wave
|
| | | mapID, funcLineID = ChConfig.Def_FBMapID_Main, PlayerControl.ComMainLevelValue(chapterID, levelNum, wave)
|
| | | turnMax = GetTurnMax(mapID)
|
| | | GameWorld.DebugLog("设置起始关卡波: 关卡%s-%s,波=%s/%s,lineupIDList=%s,mapID=%s,funcLineID=%s,lineupID=%s,strongerLV=%s,difficulty=%s" |
| | | % (chapterID, levelNum, wave, waveMax, lineupIDList, mapID, funcLineID, lineupID, strongerLV, difficulty), playerID)
|
| | | GameWorld.DebugLogEx("设置起始关卡波: 关卡%s-%s,波=%s/%s,lineupIDList=%s,mapID=%s,funcLineID=%s,lineupID=%s,strongerLV=%s,difficulty=%s", |
| | | chapterID, levelNum, wave, waveMax, lineupIDList, mapID, funcLineID, lineupID, strongerLV, difficulty, playerID)
|
| | |
|
| | | turnFight = mainFightMgr.turnFight
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, False)
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, False, curPlayer)
|
| | | turnFight.setPVE(lineupIDList, strongerLV, difficulty)
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionA, {1:lineupMainInfo})
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
|
| | |
| | | if winFaction:
|
| | | nextLineupID = turnFight.nextLineupID()
|
| | | if nextLineupID:
|
| | | GameWorld.DebugLog("---开始进入下一小队: lineupIndex=%s,nextLineupID=%s,%s" % (turnFight.lineupIndex, nextLineupID, turnFight.lineupIDList))
|
| | | GameWorld.DebugLogEx("---开始进入下一小队: lineupIndex=%s,nextLineupID=%s,%s", turnFight.lineupIndex, nextLineupID, turnFight.lineupIDList)
|
| | |
|
| | | turnFight.nextTurnFight()
|
| | | # 切换小队时,玩家阵容不需要处理,保留状态
|
| | |
| | | # 小怪战斗,每次消耗1个战锤
|
| | | fightPoint = max(curPlayer.GetFightPoint(), 1) # 主线战斗消耗倍值,默认1
|
| | | if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_Xiantao, fightPoint):
|
| | | GameWorld.DebugLog("回合开始时战锤不足!")
|
| | | GameWorld.DebugLogEx("回合开始时战锤不足!")
|
| | | return
|
| | |
|
| | | # 以下均是处理关卡小怪分段实时战斗
|
| | |
| | |
|
| | | # 回合开始
|
| | | if turnNumStart < turnNum:
|
| | | GameWorld.DebugLog("【----- 回合制战斗轮次: %s -----】 " % (turnNum))
|
| | | GameWorld.DebugLogEx("【----- 回合制战斗轮次: %s -----】 ", turnNum)
|
| | | turnFight.turnNum = turnNum
|
| | | turnFight.turnNumStart = turnNum
|
| | | if curPlayer:
|
| | |
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for posNum in range(batLineup.actionNum, PosNumMax + 1):
|
| | | #GameWorld.DebugLog("武将位置: faction=%s,posNum=%s" % (faction, posNum))
|
| | | #GameWorld.DebugLogEx("武将位置: faction=%s,posNum=%s", faction, posNum)
|
| | | if posNum not in batLineup.posObjIDDict:
|
| | | batLineup.actionNum = posNum + 1
|
| | | #GameWorld.DebugLog("没有武将: faction=%s,posNum=%s" % (faction, posNum))
|
| | | #GameWorld.DebugLogEx("没有武将: faction=%s,posNum=%s", faction, posNum)
|
| | | continue
|
| | |
|
| | | objID = batLineup.posObjIDDict[posNum]
|
| | |
| | | # 玩家自己阵营,预判可否行动
|
| | | if checkBreakpoint and faction == ChConfig.Def_FactionA and batObj:
|
| | | if batObj.CanAction():
|
| | | GameWorld.DebugLog("玩家阵容下一个可行动的武将,断点: nextPosNum=%s" % (posNum))
|
| | | GameWorld.DebugLogEx("玩家阵容下一个可行动的武将,断点: nextPosNum=%s", posNum)
|
| | | return
|
| | |
|
| | | batLineup.actionNum = posNum + 1
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def __processTurnFight(guid):
|
| | | def __processTurnFight(turnFight):
|
| | | ## 一次性处理完一个小队的战斗
|
| | | turnFight = GetTurnFightMgr().getTurnFight(guid)
|
| | | curPlayer = turnFight.curPlayer
|
| | | turnMax = turnFight.turnMax
|
| | | EntryLogic(turnFight)
|
| | |
| | | if turnFight.winFaction:
|
| | | break
|
| | | turnFight.turnNum = turnNum
|
| | | GameWorld.DebugLog("【----- 回合制战斗轮次: %s -----】" % turnNum)
|
| | | GameWorld.DebugLogEx("【----- 回合制战斗轮次: %s -----】", turnNum)
|
| | | if curPlayer:
|
| | | turnFight.syncState(FightState_Fighting)
|
| | |
|
| | | # 回合开始
|
| | | TurnFightPerTurnBigStart(turnFight, turnNum)
|
| | | |
| | | # 红颜
|
| | | # 灵兽
|
| | | |
| | | |
| | | if turnFight.winFaction:
|
| | | break
|
| | |
|
| | |
| | | ## 执行进场逻辑
|
| | | if turnFight.enterLogic:
|
| | | return
|
| | | GameWorld.DebugLog("执行进场逻辑...")
|
| | | GameWorld.DebugLogEx("执行进场逻辑...")
|
| | |
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for faction, num in turnFight.actionSortList:
|
| | |
| | |
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("大回合开始逻辑: turnNum=%s,faction=%s,num=%s" % (turnNum, faction, num))
|
| | | GameWorld.DebugLogEx("大回合开始逻辑: turnNum=%s,faction=%s,num=%s", turnNum, faction, num)
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = 1
|
| | |
| | |
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合结束逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | GameWorld.DebugLogEx("回合结束逻辑: turnNum=%s,faction=%s, num=%s", turnNum, faction, num)
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | |
| | | if not batObj.IsAlive():
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("---[武将回合开始] : curID=%s,curHP=%s/%s" % (batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP()))
|
| | | GameWorld.DebugLogEx("---[武将回合开始] : curID=%s,curHP=%s/%s", batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP())
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | RefreshObjBuffTime(turnFight, batObj)
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_HeroTurnStart)
|
| | |
| | | if not batObj.IsAlive():
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("---[武将回合结束] : curID=%s,curHP=%s/%s" % (batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP()))
|
| | | GameWorld.DebugLogEx("---[武将回合结束] : curID=%s,curHP=%s/%s", batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP())
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | RefreshObjBuffTime(turnFight, batObj)
|
| | | return
|
| | |
| | | initCD = curSkill.GetCoolDownInit()
|
| | | if initCD:
|
| | | curSkill.SetRemainTime(initCD)
|
| | | GameWorld.DebugLog("技能初始CD: curID=%s,skillID=%s,initCD=%s" % (curID, skillID, initCD))
|
| | | GameWorld.DebugLogEx("技能初始CD: curID=%s,skillID=%s,initCD=%s", curID, skillID, initCD)
|
| | | elif curSkill.GetRemainTime():
|
| | | curSkill.SetRemainTime(0)
|
| | | curSkill.SetEnergy(0)
|
| | |
| | | if remainTime <= 0:
|
| | | continue
|
| | | if preTurnUseCnt > 0:
|
| | | GameWorld.DebugLog(" 上回合有使用技能本回合不刷新CD: curID=%s,skillID=%s,remainTime=%s,preTurnUseCnt=%s" % (curID, skillID, remainTime, preTurnUseCnt))
|
| | | GameWorld.DebugLogEx(" 上回合有使用技能本回合不刷新CD: curID=%s,skillID=%s,remainTime=%s,preTurnUseCnt=%s", curID, skillID, remainTime, preTurnUseCnt)
|
| | | continue
|
| | | remainTime -= 1
|
| | | curSkill.SetRemainTime(remainTime)
|
| | | GameWorld.DebugLog(" 更新技能CD: curID=%s,skillID=%s,remainTime=%s" % (curID, skillID, remainTime))
|
| | | GameWorld.DebugLogEx(" 更新技能CD: curID=%s,skillID=%s,remainTime=%s", curID, skillID, remainTime)
|
| | | return
|
| | |
|
| | | def RefreshObjByBigTurn(turnFight, batObj):
|
| | |
| | | if skillData.GetLastTimeType() != ChConfig.BuffLastTimeType_BigTurn:
|
| | | continue
|
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLog(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s" % (curID, index, skillID, buffID))
|
| | | #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.DebugLog(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s" % (curID, index, skillID, buffID))
|
| | | 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.DebugLog(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s" % (curID, buffID, skillID, remainTime))
|
| | | GameWorld.DebugLogEx(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
|
| | | TurnBuff.SetBuffRemainTime(turnFight, batObj, buff, remainTime)
|
| | | return
|
| | |
|
| | |
| | | if skillData.GetLastTimeType() != ChConfig.BuffLastTimeType_Default:
|
| | | continue
|
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLog(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s" % (curID, index, skillID, buffID))
|
| | | #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.DebugLog(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s" % (curID, index, skillID, buffID))
|
| | | GameWorld.DebugLogEx(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | remainTime = buff.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | | # 永久buff不处理
|
| | | #GameWorld.DebugLog(" 永久buff不处理! curID=%s,index=%s,skillID=%s" % (curID, index, skillID))
|
| | | #GameWorld.DebugLogEx(" 永久buff不处理! curID=%s,index=%s,skillID=%s", curID, index, skillID)
|
| | | continue
|
| | | addTiming = buff.GetAddTiming()
|
| | | if not buff.GetRefreshState():
|
| | | GameWorld.DebugLog(" 未刷新过的buff更新为刷新过! curID=%s,index=%s,skillID=%s,buffID=%s,addTiming=%s" % (curID, index, skillID, buffID, addTiming))
|
| | | GameWorld.DebugLogEx(" 未刷新过的buff更新为刷新过! curID=%s,index=%s,skillID=%s,buffID=%s,addTiming=%s", curID, index, skillID, buffID, addTiming)
|
| | | buff.SetRefreshState(1)
|
| | | continue
|
| | | if addTiming != curTiming:
|
| | | GameWorld.DebugLog(" buff添加时机不同不处理! curID=%s,index=%s,skillID=%s,buffID=%s,addTiming=%s" % (curID, index, skillID, buffID, addTiming))
|
| | | GameWorld.DebugLogEx(" buff添加时机不同不处理! curID=%s,index=%s,skillID=%s,buffID=%s,addTiming=%s", curID, index, skillID, buffID, addTiming)
|
| | | continue
|
| | | remainTime -= 1
|
| | | GameWorld.DebugLog(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s,addTiming=%s" % (curID, buffID, skillID, remainTime, addTiming))
|
| | | GameWorld.DebugLogEx(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s,addTiming=%s", curID, buffID, skillID, remainTime, addTiming)
|
| | | TurnBuff.SetBuffRemainTime(turnFight, batObj, buff, remainTime)
|
| | | return
|
| | |
|
| | |
| | | curID = curObj.GetID()
|
| | | srcID = srcObj.GetID()
|
| | | updStatValue = srcObj.StatCureValue(cureHP)
|
| | | GameWorld.DebugLog(" 统计治疗: curID=%s,srcID=%s,skillID=%s,addValue=%s,cureHP=%s,updStatValue=%s" |
| | | % (curID, srcID, skillID, addValue, cureHP, updStatValue))
|
| | | GameWorld.DebugLogEx(" 统计治疗: curID=%s,srcID=%s,skillID=%s,addValue=%s,cureHP=%s,updStatValue=%s", |
| | | curID, srcID, skillID, addValue, cureHP, updStatValue)
|
| | |
|
| | | return
|
| | |
|
| | |
| | | tagID = tagBatObj.GetID()
|
| | | if curID != tagID:
|
| | | updStatValue = curBatObj.StatHurtValue(hurtValue)
|
| | | GameWorld.DebugLog(" 统计输出: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,updStatValue=%s,tagHP=%s,lostType=%s" |
| | | % (curID, tagID, skillID, hurtValue, lostHP, updStatValue, tagBatObj.GetHP(), lostType))
|
| | | GameWorld.DebugLogEx(" 统计输出: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,updStatValue=%s,tagHP=%s,lostType=%s", |
| | | curID, tagID, skillID, hurtValue, lostHP, updStatValue, tagBatObj.GetHP(), lostType)
|
| | |
|
| | | if tagBatObj:
|
| | | updStatValue = tagBatObj.StatDefValue(hurtValue)
|
| | | GameWorld.DebugLog(" 统计承伤: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,updStatValue=%s,curHP=%s,lostType=%s" |
| | | % (tagID, curID, skillID, hurtValue, lostHP, updStatValue, tagBatObj.GetHP(), lostType))
|
| | | GameWorld.DebugLogEx(" 统计承伤: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,updStatValue=%s,curHP=%s,lostType=%s", |
| | | tagID, curID, skillID, hurtValue, lostHP, updStatValue, tagBatObj.GetHP(), lostType)
|
| | |
|
| | | else:
|
| | | # 如换血类技能,自残的伤害不算输出
|
| | | GameWorld.DebugLog(" 自残: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,curHP=%s" |
| | | % (curID, tagID, skillID, hurtValue, lostHP, curBatObj.GetHP()))
|
| | | GameWorld.DebugLogEx(" 自残: curID=%s,tagID=%s,skillID=%s,hurtValue=%s,lostHP=%s,curHP=%s", |
| | | curID, tagID, skillID, hurtValue, lostHP, curBatObj.GetHP())
|
| | | return
|
| | |
|
| | | def OnObjAction(turnFight, curBatObj, isExtra=False):
|
| | |
| | | # 是否可行动状态判断
|
| | | canAction = curBatObj.CanAction()
|
| | | if not canAction:
|
| | | GameWorld.DebugLog("★回合%s %s 当前状态不可行动! isExtra=%s" % (turnNum, objName, isExtra))
|
| | | GameWorld.DebugLogEx("★回合%s %s 当前状态不可行动! isExtra=%s", turnNum, objName, isExtra)
|
| | | return
|
| | |
|
| | | atk = curBatObj.GetAtk()
|
| | | curXP = curBatObj.GetXP()
|
| | | GameWorld.DebugLog("★回合%s %s %s行动 : atk=%s,curHP=%s/%s,curXP=%s" % (turnNum, objName, "额外" if isExtra else "", atk, curHP, curBatObj.GetMaxHP(), curXP))
|
| | | GameWorld.DebugLogEx("★回合%s %s %s行动 : atk=%s,curHP=%s/%s,curXP=%s", turnNum, objName, "额外" if isExtra else "", atk, curHP, curBatObj.GetMaxHP(), curXP)
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | turnFight.syncObjAction(turnNum, objID)
|
| | |
|
| | |
| | | xpMax = IpyGameDataPY.GetFuncCfg("AngerXP", 2)
|
| | | skillManager = curBatObj.GetSkillManager()
|
| | | useSkillList = []
|
| | | #GameWorld.DebugLog('skillCount=%s' % skillManager.GetSkillCount(), npcID)
|
| | | #GameWorld.DebugLogEx('skillCount=%s', skillManager.GetSkillCount(), npcID)
|
| | | for index in range(0, skillManager.GetSkillCount()):
|
| | | useSkill = skillManager.GetSkillByIndex(index)
|
| | | if not useSkill:
|
| | |
| | | if curXP < xpMax and not useSkill.GetEffectByID(ChConfig.SkillEff_AngerSkillNoXP):
|
| | | continue
|
| | | if curBatObj.CheckInState(ChConfig.BatObjState_Sneer):
|
| | | GameWorld.DebugLog("嘲讽状态下,无法主动释放怒技! skillID=%s" % skillID) # 可被动释放怒技,如怒技追击
|
| | | GameWorld.DebugLogEx("嘲讽状态下,无法主动释放怒技! skillID=%s", skillID) # 可被动释放怒技,如怒技追击
|
| | | continue
|
| | | useCnt = -1 # xp技能优先释放
|
| | | else:
|
| | | if useSkill.GetEffectByID(ChConfig.SkillEff_ActionUseInvalid): # 配置该效果时如果被嘲讽,相当于无法行动
|
| | | GameWorld.DebugLog("行动时无法释放该技能! skillID=%s" % skillID)
|
| | | GameWorld.DebugLogEx("行动时无法释放该技能! skillID=%s", skillID)
|
| | | continue
|
| | | useCnt = curBatObj.GetSkillUseCnt(skillID)
|
| | | useSkillList.append([useCnt, skillID, useSkill])
|
| | |
|
| | | useSkillList.sort() # 按使用次数优先升序排,使用次数低的优先判断使用
|
| | | #GameWorld.DebugLog(' 技能使用顺序 = useSkillList%s' % str(useSkillList), npcID)
|
| | | #GameWorld.DebugLogEx(' 技能使用顺序 = useSkillList%s', str(useSkillList), npcID)
|
| | |
|
| | | for useInfo in useSkillList:
|
| | | useSkill = useInfo[-1]
|
| | |
| | | npcID = gameObj.GetNPCID()
|
| | |
|
| | | # 非主线的PVE目标怪物
|
| | | if npcID and curPlayer and turnFight.isFBMap() and gameObj.GetFaction() != ChConfig.Def_FactionA:
|
| | | if not FBLogic.OnFBNPCKilledBefore(curPlayer, turnFight, gameObj, killer, useSkill):
|
| | | if npcID and turnFight.getReqPlayerID() and turnFight.isFBMap() and gameObj.GetFaction() != ChConfig.Def_FactionA:
|
| | | if not FBLogic.OnFBNPCKilledBefore(turnFight, gameObj, killer, useSkill):
|
| | | return
|
| | |
|
| | | objID = gameObj.GetID()
|
| | | killerObjID = killer.GetID() if killer else 0
|
| | | skillID = useSkill.GetSkillID() if useSkill else 0
|
| | | GameWorld.DebugLog(" %s 回合战斗主体被击杀: curID=%s,killerObjID=%s,skillID=%s" % (GetObjName(gameObj), objID, killerObjID, skillID))
|
| | | GameWorld.DebugLogEx(" %s 回合战斗主体被击杀: curID=%s,killerObjID=%s,skillID=%s", GetObjName(gameObj), objID, killerObjID, skillID)
|
| | | gameObj.SetDead()
|
| | | TurnBuff.DoBuffByDead(turnFight, gameObj)
|
| | |
|
| | |
| | |
|
| | | def OnTurnAllOver(guid):
|
| | | ## 所有回合已经全部执行完毕
|
| | | GameWorld.DebugLog("所有回合结束")
|
| | | GameWorld.DebugLogEx("所有回合结束")
|
| | | turnFight = GetTurnFightMgr().getTurnFight(guid)
|
| | | if not turnFight:
|
| | | return
|
| | |
| | | if turnFight.winFaction:
|
| | | return
|
| | |
|
| | | if turnFight.playerID:
|
| | | if turnFight.getReqPlayerID():
|
| | | # 玩家发起的,未击杀对方,算玩家输
|
| | | turnFight.winFaction = ChConfig.Def_FactionB
|
| | | else:
|
| | |
| | | turnFight.isWin = (winFaction == ChConfig.Def_FactionA)
|
| | | mapID = turnFight.mapID
|
| | | funcLineID = turnFight.funcLineID
|
| | | GameWorld.DebugLog("--- 战斗结束处理 ---, winFaction=%s, costTime=%ss, %s" % (winFaction, turnFight.costTime, guid))
|
| | | GameWorld.DebugLogEx("--- 战斗结束处理 ---, winFaction=%s, costTime=%ss, %s", winFaction, turnFight.costTime, guid)
|
| | | if mapID != ChConfig.Def_FBMapID_Main:
|
| | | GameWorld.Log("战斗耗时: %ss, mapID=%s,funcLineID=%s" % (turnFight.costTime, mapID, funcLineID))
|
| | | GameWorld.Log("战斗耗时: %ss, mapID=%s,funcLineID=%s,turnNum=%s/%s" % (turnFight.costTime, mapID, funcLineID, turnFight.turnNum, turnFight.turnMax))
|
| | |
|
| | | # 统计明细
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | |
| | | lineupStatInfo = facStatInfo[str(num)]
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.totalHurt = 0
|
| | | GameWorld.DebugLog("阵容明细: faction=%s,num=%s" % (faction, num))
|
| | | GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
|
| | | for posNum, objID in batLineup.posObjIDDict.items():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | |
| | | cureHP = batObj.cureStat
|
| | | batLineup.totalHurt += atkHurt
|
| | | batFaction.totalHurt += atkHurt
|
| | | GameWorld.DebugLog(" Pos:%s ID=%s,npcID=%s,heroID=%s,HP=%s/%s, 输出=%s,承伤=%s,治疗=%s" |
| | | % (posNum, objID, npcID, heroID, batObj.GetHP(), batObj.GetMaxHP(), atkHurt, defHurt, cureHP))
|
| | | lineupStatInfo[str(posNum)] = {"ObjID":objID, "HeroID":heroID, "NPCID":npcID, "AtkHurt":atkHurt, "DefHurt":defHurt, "CureHP":cureHP}
|
| | | dead = 0 if batObj.IsAlive() else 1
|
| | | GameWorld.DebugLogEx(" Pos:%s ID=%s,npcID=%s,heroID=%s,HP=%s/%s, 输出=%s,承伤=%s,治疗=%s", |
| | | posNum, objID, npcID, heroID, batObj.GetHP(), batObj.GetMaxHP(), atkHurt, defHurt, cureHP)
|
| | | lineupStatInfo[str(posNum)] = {"ObjID":objID, "HeroID":heroID, "NPCID":npcID, "AtkHurt":atkHurt, "DefHurt":defHurt, "CureHP":cureHP, |
| | | "LV":batObj.GetLV(), "Star":batObj.GetStar(), "Skin":batObj.GetSkinID(), "Dead":dead}
|
| | |
|
| | | overMsg = {"winFaction":winFaction, "statInfo":statInfo}
|
| | | curPlayer = turnFight.curPlayer
|
| | | statMsg = {"winFaction":winFaction, "statInfo":statInfo}
|
| | |
|
| | | FBLogic.OnTurnFightOver(curPlayer, turnFight, mapID, funcLineID, overMsg)
|
| | | FBLogic.OnTurnFightOver(turnFight, mapID, funcLineID, statMsg)
|
| | |
|
| | | turnFight.syncState(FightState_Award, overMsg)
|
| | | turnFight.syncState(FightState_Award, statMsg)
|
| | | return
|
| | |
|
| | | #// B4 14 查看战报 #tagCSTurnFightReportView
|
| | |
| | | clientPack.Len = len(clientPack.Report)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def __saveBatBuffer(turnFight):
|
| | | ## 持久化战报
|
| | | |
| | | reqPlayerID = turnFight.getReqPlayerID()
|
| | | reqServerID = turnFight.getReqServerID()
|
| | | |
| | | guid = turnFight.guid
|
| | | ReportRoot = "C:\TurnFightReport"
|
| | | |
| | | dateStr = GameWorld.ChangeTimeNumToStr(int(time.time()), "%Y%m%d") |
| | | ReportDir = os.path.join(ReportRoot, "S%s" % reqServerID, dateStr, "%s" % reqPlayerID, "%s" % turnFight.mapID)
|
| | | 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
|
| | | |
| | | saveFilePath = os.path.join(ReportDir, "%s.tfr" % guid)
|
| | | GameWorld.DebugLogEx("战报路径=%s", saveFilePath)
|
| | | |
| | | try:
|
| | | clientPack = ChPyNetSendPack.tagSCTurnFightReport()
|
| | | clientPack.GUID = guid
|
| | | clientPack.Report = turnFight.batBuffer
|
| | | clientPack.Len = len(clientPack.Report)
|
| | | fp = open(saveFilePath, "wb")
|
| | | fp.write(clientPack.GetBuffer())
|
| | | fp.close()
|
| | | except:
|
| | | return
|
| | | |
| | | turnFight.dateStr = dateStr
|
| | | return True
|
| | |
|
| | | def SyncTurnFightRet(curPlayer, guid, mapID, funcLineID, reqData, isWin, statMsg, dateStr, awardDict):
|
| | | tagType, tagID, valueList = 0, 0, []
|
| | | if reqData and len(reqData) == 3:
|
| | | tagType, tagID, valueList = reqData
|
| | | clientPack = ChPyNetSendPack.tagSCTurnFightRet()
|
| | | clientPack.MapID = mapID
|
| | | clientPack.FuncLineID = funcLineID
|
| | | clientPack.TagType = tagType
|
| | | clientPack.TagID = tagID
|
| | | clientPack.ValueList = valueList
|
| | | clientPack.ValueCount = len(clientPack.ValueList)
|
| | | |
| | | clientPack.IsWin = isWin
|
| | | clientPack.AwardMsg = json.dumps(awardDict, ensure_ascii=False).replace(" ", "")
|
| | | clientPack.AwardLen = len(clientPack.AwardMsg)
|
| | | clientPack.BatStatMsg = json.dumps(statMsg, ensure_ascii=False).replace(" ", "")
|
| | | clientPack.BatLen = len(clientPack.BatStatMsg)
|
| | | clientPack.PathDate = dateStr
|
| | | clientPack.GUID = guid
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
|