| | |
| | |
|
| | | import ChConfig
|
| | | import PlayerTask
|
| | | import PlayerActivity
|
| | | import PlayerViewCache
|
| | | import ChPyNetSendPack
|
| | | import NetPackCommon
|
| | |
| | | import TurnPassive
|
| | | import TurnSkill
|
| | | import TurnBuff
|
| | | import FBCommon
|
| | | import CommFunc
|
| | | import ObjPool
|
| | | import FBLogic
|
| | |
| | | import time
|
| | | import json
|
| | |
|
| | | TimelineSet = 10000 # 单回合最大时间轴
|
| | | PosNumMax = 7 # 最大站位编号
|
| | | ActionNumStart = -1 # 起始行动位置编号,一般是从1开始,如果有加主公、红颜等则扣除相应位置值,如从0或-1开始
|
| | |
|
| | |
| | | self.lingshouObjIDDict = {} # 灵兽战斗单位 {位置编号:batObjID, ...}
|
| | | self.beautyObjIDDict = {} # 红颜战斗单位 {位置编号:batObjID, ...}
|
| | | self.actionNum = ActionNumStart # 行动位置,从1开始
|
| | | self.totalHurt = 0 # 阵容总输出
|
| | | |
| | | #特殊
|
| | | self.bossID = 0
|
| | | self.bossPosView = 0
|
| | | return
|
| | |
|
| | | def getPlayerID(self): return self.turnFight.playerID # 发起的玩家ID
|
| | |
| | | self.ownerID = lineupInfo.get("PlayerID", 0) # 阵容所属的玩家ID
|
| | | self.shapeType = lineupInfo.get("ShapeType", 0)
|
| | | 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())
|
| | | return
|
| | |
|
| | |
| | | self.lingshouObjIDDict = {}
|
| | | self.beautyObjIDDict = {}
|
| | | self.fightPower = 0
|
| | | self.totalHurt = 0
|
| | | return
|
| | | |
| | | def getDeadObjCnt(self):
|
| | | ## 获取本阵容目前死亡队员数
|
| | | deadCnt = 0
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in self.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | if batObj.IsAlive():
|
| | | continue
|
| | | deadCnt += 1
|
| | | return deadCnt
|
| | |
|
| | | class BatFaction():
|
| | | ## 战斗阵营
|
| | |
| | | self.turnFight = turnFight # TurnFight
|
| | | self.faction = faction
|
| | | self.lineupDict = {} # 该阵营所有阵容信息 {编号:BatLineup, ...}
|
| | | self.totalHurt = 0 # 阵营总输出
|
| | | return
|
| | |
|
| | | def getBatlineup(self, num=1):
|
| | |
| | | lineup = BatLineup(self.faction, num, self.turnFight)
|
| | | self.lineupDict[num] = lineup
|
| | | return lineup
|
| | | |
| | | def getTotalHurt(self): return self.totalHurt # 阵营总输出
|
| | |
|
| | | def clearLineups(self):
|
| | | ## 清除所有战斗阵容
|
| | |
| | | self.state = -1 # -1 代表未战斗
|
| | | self.turnNum = 1 # 当前第x回合,默认第1回合开始
|
| | | self.turnMax = 15 # 最大回合数
|
| | | self.turnNumStart = 0 # 已处理第x回合开始
|
| | | self.enterLogic = False # 是否已执行进场逻辑
|
| | | self.winFaction = 0 # 本场战斗结束标记,获胜阵营,为0时代表未结束,所有小队打完或失败才有结果,0-未结束,>0-获胜的阵营
|
| | | self.isWin = False
|
| | | self.batBuffer = "" # 战报buffer,战报暂时只保留最后一个小队的
|
| | | self.isNeedReport = isNeedReport # 是否需要战报
|
| | | 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.actionIndex = 0 # 行动顺序索引 |
| | | self.timeline = 0 # 时间轴节点 turnNum*1000+actionIndex*100++actionNum
|
| | | self.actionIndex = 0 # 行动顺序索引
|
| | | self.startTime = 0 # 开始时间戳,支持毫秒小数
|
| | | self.costTime = 0 # 单场战斗总耗时,支持毫秒小数
|
| | | self._oneActionUseSkillCntDict = {} # 某对象行动开始后所有对象累计使用技能次数,用于单对象单次行动中限制每个对象的最高触发技能次数 {objID:useCnt, ...}
|
| | |
|
| | | # pve 多小队 - 一般只有PVE用到
|
| | | self.lineupIndex = 0 # 当前小队索引
|
| | |
| | | self.setPVE()
|
| | | self.setPVP()
|
| | | self.msgDict = {}
|
| | | self._kvDict = {}
|
| | | self.awardData = None
|
| | | self.nextTurnFight(msgDict)
|
| | | return
|
| | |
|
| | |
| | | self.tagViewCache = tagViewCache
|
| | | return
|
| | |
|
| | | def isFBMap(self):
|
| | | ## 是否副本地图中,非主线的均视为副本
|
| | | return self.mapID not in [ChConfig.Def_FBMapID_Main, ChConfig.Def_FBMapID_MainBoss]
|
| | | |
| | | 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={}, resetByNextTeam=False):
|
| | | def nextTurnFight(self, msgDict={}):
|
| | | ## 一般用于玩家发起的战斗,在需要保留玩家阵容属性及状态的情况下,重置回合进入下一场战斗
|
| | | self.turnNum = 1
|
| | | self.turnNumStart = 0
|
| | | self.enterLogic = False
|
| | | self.winFaction = 0
|
| | | self.isWin = False
|
| | | self.msgDict.update(msgDict)
|
| | | self.timeline = 0
|
| | | self.startTime = time.time()
|
| | | self.costTime = 0
|
| | | if resetByNextTeam:
|
| | | ResetByNextTeam(self)
|
| | | ResetByNextTeam(self)
|
| | | return
|
| | |
|
| | | def haveNextLineup(self):
|
| | |
| | | GameWorld.DebugLog("阵容战力排序[isPlayer, fp, sortV, f, n]: %s" % sortList)
|
| | | GameWorld.DebugLog("阵容行动顺序[f, n]: %s" % self.actionSortList)
|
| | | return
|
| | | |
| | | def getTurnNumStartTimelin(self, turnNum): return turnNum * TimelineSet + 0 # 每回合的时间节点起点
|
| | | def getTimeline(self): return self.timeline
|
| | | def setTimeline(self, timeline, isEmpty=False):
|
| | | '''回合战斗的时间轴节点 ,即第几回合开始,每个回合支持9999个行动节点
|
| | | @param turnNum: 第x回合
|
| | | '''
|
| | | self.timeline = timeline
|
| | | GameWorld.DebugLog("时间节点更新: %s" % self.timeline)
|
| | | if isEmpty:
|
| | | # 空位置的节点可直接跳过
|
| | | return timeline
|
| | | |
| | | OnTimelineChange(self)
|
| | | return timeline
|
| | |
|
| | | def getBatFaction(self, faction=ChConfig.Def_FactionA):
|
| | | ## 默认阵营1
|
| | |
| | | ## 准备就绪,开始战斗
|
| | | self.state = FightState_Start
|
| | | self.turnNum = 1
|
| | | self.timeline = self.getTurnNumStartTimelin(self.turnNum)
|
| | | self.turnNumStart = 0
|
| | | self.syncInit()
|
| | | return
|
| | |
|
| | |
| | | tfObj.MaxHP = batObj.GetMaxHP() % ChConfig.Def_PerPointValue
|
| | | tfObj.MaxHPEx = batObj.GetMaxHP() / ChConfig.Def_PerPointValue
|
| | | tfObj.LV = batObj.GetLV()
|
| | | tfObj.PosNum = posNum
|
| | | if batLineup.bossPosView and batLineup.bossID == batObj.GetNPCID():
|
| | | tfObj.PosNum = batLineup.bossPosView
|
| | | else:
|
| | | tfObj.PosNum = posNum |
| | | tfObj.AngreXP = batObj.GetXP()
|
| | | tfLineup.ObjList.append(tfObj)
|
| | | tfLineup.ObjCnt = len(tfLineup.ObjList)
|
| | |
| | | clientPack.FactionList.append(tfFaction)
|
| | | clientPack.FactionCnt = len(clientPack.FactionList)
|
| | | self.addBatPack(clientPack)
|
| | | return
|
| | | |
| | | def syncHelp(self, msgDict):
|
| | | ## 通知帮助信息,一般是副本用
|
| | | self.syncState(self.state, msgDict)
|
| | | return
|
| | |
|
| | | def syncState(self, state, msgDict={}):
|
| | |
| | | ObjPool.GetPoolMgr().release(clientPack)
|
| | | return
|
| | |
|
| | | def ResetOneActionUseSkillCnt(self): self._oneActionUseSkillCntDict = {}
|
| | | def GetOneActionUseSkillCnt(self, objID): return self._oneActionUseSkillCntDict.get(objID, 0)
|
| | | def SetOneActionUseSkillCnt(self, objID, useCnt):
|
| | | self._oneActionUseSkillCntDict[objID] = useCnt
|
| | | return useCnt
|
| | | |
| | | class TurnFightMgr():
|
| | | ## 回合战斗管理器
|
| | |
|
| | | def __init__(self):
|
| | | self.lastRequestTick = 0
|
| | | self.turnFightDict = {} # {guid:TurnFight, ...}
|
| | | return
|
| | |
|
| | |
| | | ## 获取玩家阵容
|
| | | olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
|
| | | lineup = olPlayer.GetLineup(lineupID)
|
| | | if not lineup.lineupHeroDict:
|
| | | # 为空时默认取主阵容
|
| | | if lineup.IsEmpty():
|
| | | GameWorld.DebugLog("玩家没有目标阵容默认取主阵容! lineupID=%s" % lineupID)
|
| | | lineup = olPlayer.GetLineup(ShareDefine.Lineup_Main)
|
| | | return lineup
|
| | |
|
| | |
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | lineup = GetPlayerLineup(curPlayer, lineupID)
|
| | | if not lineup.lineupHeroDict:
|
| | | if lineup.IsEmpty():
|
| | | return {}
|
| | |
|
| | | heroDict = {}
|
| | | curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptHero)
|
| | | for posNum in lineup.lineupHeroDict.keys():
|
| | | for posNum in lineup.GetPosNumList():
|
| | | hero = lineup.GetLineupHero(posNum)
|
| | | heroID = hero.heroID
|
| | | itemIndex = hero.itemIndex
|
| | |
| | | ipyData = IpyGameDataPY.GetIpyGameData("NPCLineup", lineupID)
|
| | | if not ipyData:
|
| | | return {}
|
| | | bossID = ipyData.GetBossID()
|
| | | bossPosView = ipyData.GetBossPosView()
|
| | |
|
| | | heroDict = {}
|
| | | for posNum in range(1, 1 + 10):
|
| | | for posNum in range(1, 1 + 6):
|
| | | if not hasattr(ipyData, "GetPosNPCID%s" % posNum):
|
| | | break
|
| | | npcID = getattr(ipyData, "GetPosNPCID%s" % posNum)()
|
| | |
| | | continue
|
| | | heroDict[str(posNum)] = battleDict
|
| | |
|
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict}
|
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":bossID, "BossPosView":bossPosView}
|
| | | return lineupInfo
|
| | |
|
| | | def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0):
|
| | |
| | | else:
|
| | | heroID = 0
|
| | | skinID = 0
|
| | | skillIDList = [] + npcData.GetSkillIDList()
|
| | | skillIDList = []# + npcData.GetSkillIDList()
|
| | |
|
| | | # boss额外随机技能
|
| | | bossID = lineupIpyData.GetBossID()
|
| | |
| | | ChConfig.AttrID_ParryRate:npcData.GetParryRate(), ChConfig.AttrID_ParryRateDef:npcData.GetParryRateDef(),
|
| | | ChConfig.AttrID_SuckHPPer:npcData.GetSuckHPPer(), ChConfig.AttrID_SuckHPPerDef:npcData.GetSuckHPPerDef(),
|
| | | }
|
| | | batAttrDict.update(npcData.GetSpecAttrInfo())
|
| | | exAttrDict = npcData.GetSpecAttrInfo()
|
| | | for attrIDStr, attrValue in exAttrDict.items():
|
| | | attrID = int(attrIDStr)
|
| | | batAttrDict[attrID] = batAttrDict.get(attrID, 0) + attrValue
|
| | |
|
| | | battleDict = {"NPCID":npcID,
|
| | | "HeroID":heroID,
|
| | |
| | | angerSkillID = heroIpyData.GetAngerSkillID()
|
| | | skillIDList = [normalSkillID, angerSkillID]
|
| | |
|
| | | breakIpyDataList = IpyGameDataPY.GetIpyGameDataList("HeroBreak", heroID)
|
| | | breakIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroBreak", heroID)
|
| | | if breakIpyDataList:
|
| | | for breakIpyData in breakIpyDataList:
|
| | | if breakIpyData.GetBreakLV() > breakLV:
|
| | |
| | | if not curPlayer:
|
| | | return
|
| | |
|
| | | tfGUID = batLineup.turnFight.guid
|
| | | turnFight = batLineup.turnFight
|
| | | tfGUID = turnFight.guid
|
| | | lineupPlayerID = lineupInfo.get("PlayerID", 0) # 阵容所属玩家ID
|
| | | heroDict = lineupInfo.get("Hero", {})
|
| | |
|
| | |
| | | heroID = heroInfo.get("HeroID", 0)
|
| | | skinID = heroInfo.get("SkinID", 0)
|
| | | lv = heroInfo.get("LV", 1)
|
| | | specialty, atkDistType, country, sex, job = 0, 1, 0, 1, 0
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | | if heroIpyData:
|
| | | objName = heroIpyData.GetName()
|
| | | specialty = heroIpyData.GetSpecialty()
|
| | | atkDistType = heroIpyData.GetAtkDistType()
|
| | | objName = heroIpyData.GetName()
|
| | | country = heroIpyData.GetCountry()
|
| | | sex = heroIpyData.GetSex()
|
| | | job = heroIpyData.GetJob()
|
| | |
|
| | | if lineupPlayerID:
|
| | | fightPower = heroInfo.get("FightPower", 0)
|
| | |
| | | if not npcDataEx:
|
| | | continue
|
| | | if not heroIpyData:
|
| | | specialty = npcDataEx.GetSpecialty()
|
| | | atkDistType = npcDataEx.GetAtkDistType()
|
| | | objName = npcDataEx.GetNPCName()
|
| | | country = npcDataEx.GetCountry()
|
| | | sex = npcDataEx.GetSex()
|
| | |
|
| | | batObj = batObjMgr.addBatObj()
|
| | | if not batObj:
|
| | |
| | | batObj.SetSpecialty(specialty)
|
| | | batObj.SetCountry(country)
|
| | | batObj.SetSex(sex)
|
| | | batObj.SetJob(job)
|
| | | batObj.SetHero(heroID, skinID)
|
| | |
|
| | | skillManager = batObj.GetSkillManager()
|
| | |
| | |
|
| | | batLineup.posObjIDDict[posNum] = objID
|
| | | GameWorld.DebugLog("AddBatObj %s,skill=%s" % (GetObjName(batObj), skillManager.GetSkillIDList()))
|
| | | ResetObjSkill(batObj)
|
| | | |
| | | if npcID:
|
| | | #副本指定NPC属性
|
| | | fbNPCInitAttrDict = FBLogic.GetFBNPCInitAttr(curPlayer, turnFight, batObj)
|
| | | if fbNPCInitAttrDict:
|
| | | GameWorld.DebugLog("副本指定NPC初始化属性: npcID=%s, %s" % (npcID, fbNPCInitAttrDict))
|
| | | attrDict = {str(k):v for k, v in fbNPCInitAttrDict.items()} # 统一格式
|
| | | batObj.InitBatAttr({int(k):v for k, v in attrDict.items()}, initXP)
|
| | |
|
| | | return
|
| | |
| | | if not batObj.IsAlive():
|
| | | GameWorld.DebugLog(" 已被击杀不处理! %s" % (objName))
|
| | | continue
|
| | | GameWorld.DebugLog(" 重置武将: %s, HP:%s/%s, XP:%s" % (objName, batObj.GetHP(), batObj.GetMaxHP(), batObj.GetXP()))
|
| | | |
| | | batObj.TurnReset()
|
| | | GameWorld.DebugLog("重置武将: %s, HP:%s/%s, XP:%s" % (objName, batObj.GetHP(), batObj.GetMaxHP(), batObj.GetXP()))
|
| | |
|
| | | # 清除buff
|
| | | buffMgr = batObj.GetBuffManager()
|
| | | buffMgr.ClearBuff()
|
| | |
|
| | | # 重置CD
|
| | | # 重置技能
|
| | | ResetObjSkill(batObj)
|
| | |
|
| | | # 重刷属性、被动
|
| | | TurnBuff.RefreshBuffAttr(batObj)
|
| | | TurnPassive.RefreshPassive(batObj)
|
| | |
|
| | | return
|
| | |
|
| | | def CheckFightCD(curPlayer, tick, selfKey):
|
| | | ## 是否战斗请求CD中
|
| | | |
| | | # 所有玩家公共CD,待扩展
|
| | | tfMgr = GetTurnFightMgr()
|
| | | pubCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 1)
|
| | | if pubCD:
|
| | | if tfMgr.lastRequestTick and tick - tfMgr.lastRequestTick <= pubCD:
|
| | | GameWorld.DebugLog("回合制战斗请求服务器公共CD中!")
|
| | | PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
|
| | | return True
|
| | | |
| | | # 个人CD
|
| | | selfCD = IpyGameDataPY.GetFuncCfg("TurnFightCD", 2)
|
| | | lastTick = curPlayer.GetDictByKey(selfKey)
|
| | | if selfCD and lastTick and tick - lastTick <= selfCD:
|
| | | GameWorld.DebugLog("回合制战斗请求CD中: %s" % selfKey)
|
| | | PlayerControl.NotifyCode(curPlayer, "BattleCoolDown")
|
| | | return True
|
| | | |
| | | tfMgr.lastRequestTick = tick
|
| | | curPlayer.SetDict(selfKey, tick)
|
| | | return False
|
| | |
|
| | | #// B4 10 回合制战斗 #tagCMTurnFight
|
| | | #
|
| | |
| | | tagID = clientData.TagID
|
| | | valueList = clientData.ValueList
|
| | |
|
| | | GameWorld.DebugLog("回合制战斗请求: mapID=%s,funcLineID=%s,tagType=%s,tagID=%s,valueList=%s" |
| | | GameWorld.DebugLog("----- 回合制战斗请求: mapID=%s,funcLineID=%s,tagType=%s,tagID=%s,valueList=%s" |
| | | % (mapID, funcLineID, tagType, tagID, valueList), curPlayer.GetPlayerID())
|
| | |
|
| | | reqRet = FBLogic.OnTurnFightRequest(curPlayer, mapID, funcLineID, tagType, tagID, valueList)
|
| | | if not reqRet:
|
| | | return
|
| | | funcLineID = reqRet[1] if len(reqRet) > 1 else funcLineID
|
| | |
|
| | | fbIpyData = FBCommon.GetFBIpyData(mapID)
|
| | | fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID, False)
|
| | | if fbIpyData:
|
| | | if not fbLineIpyData:
|
| | | GameWorld.DebugLog("不存在该副本功能线路! 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
|
| | | |
| | | # 玩家
|
| | | if tagType == 1:
|
| | | OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagID)
|
| | | if not OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagID):
|
| | | return
|
| | |
|
| | | # NPC
|
| | | else:
|
| | | ret = FBLogic.GetFBNPCLineupInfo(curPlayer, mapID, funcLineID)
|
| | | if not ret:
|
| | | npcLineupIDList, strongerLV, difficulty = [], 0, 0
|
| | | if fbLineIpyData:
|
| | | npcLineupIDList = fbLineIpyData.GetLineupIDList()
|
| | | strongerLV = fbLineIpyData.GetNPCLV()
|
| | | difficulty = fbLineIpyData.GetDifficulty()
|
| | | |
| | | if not npcLineupIDList:
|
| | | ret = FBLogic.GetFBNPCLineupInfo(curPlayer, mapID, funcLineID)
|
| | | if not ret:
|
| | | return
|
| | | npcLineupIDList, strongerLV, difficulty = ret
|
| | | if not OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
|
| | | return
|
| | | npcLineupIDList, strongerLV, difficulty = ret
|
| | | OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty)
|
| | |
|
| | | return
|
| | | return True
|
| | |
|
| | | def OnTurnFightVSNPC(curPlayer, mapID, funcLineID, atkLineupID, npcLineupIDList, strongerLV, difficulty):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
| | | turnFight.lineupIndex = index
|
| | | GameWorld.DebugLog("对战NPC阵容: index=%s, lineupID=%s" % (index, lineupID))
|
| | | if index > 0:
|
| | | turnFight.nextTurnFight(resetByNextTeam=True)
|
| | | turnFight.nextTurnFight()
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
|
| | | turnFight.sortActionQueue()
|
| | | turnFight.startFight()
|
| | |
| | |
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
|
| | | SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer)
|
| | | FBLogic.OnTurnFightAward(curPlayer, turnFight, mapID, funcLineID, turnFight.awardData)
|
| | | tfMgr.delTurnFight(guid)
|
| | | return
|
| | | return True
|
| | |
|
| | | def OnTurnFightVSPlayer(curPlayer, mapID, funcLineID, atkLineupID, defLineupID, tagPlayerID):
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
| | |
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetLastBatBuffer(guid, turnFight.batBuffer)
|
| | | SyncTurnFightReport(curPlayer, guid, turnFight.batBuffer)
|
| | | FBLogic.OnTurnFightAward(curPlayer, turnFight, mapID, funcLineID, turnFight.awardData)
|
| | | tfMgr.delTurnFight(guid)
|
| | | return
|
| | | return True
|
| | |
|
| | | def GetTurnMax(mapID):
|
| | | if mapID == ChConfig.Def_FBMapID_Main:
|
| | |
| | | __doSetFightPoint(curPlayer, reqValue)
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("主线战斗请求: reqType=%s" % reqType, curPlayer.GetPlayerID())
|
| | | GameWorld.DebugLog("------------------- 主线战斗请求: reqType=%s" % reqType, curPlayer.GetPlayerID())
|
| | | clientPack = ChPyNetSendPack.tagSCTurnFightReportSign()
|
| | | clientPack.Sign = 0
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack) # 标记开始
|
| | |
| | |
|
| | | # 限制请求CD
|
| | | if tick:
|
| | | key = "MainFightReqTick"
|
| | | lastTick = curPlayer.GetDictByKey(key)
|
| | | if lastTick and tick - lastTick <= 1000:
|
| | | GameWorld.DebugLog("主线战斗请求CD中")
|
| | | if CheckFightCD(curPlayer, tick, "MainFightReqTick"):
|
| | | return
|
| | | curPlayer.SetDict(key, tick)
|
| | |
|
| | | mainFightMgr = GetMainFightMgr(curPlayer)
|
| | | turnFight = mainFightMgr.turnFight
|
| | |
| | | if nextLineupID:
|
| | | GameWorld.DebugLog("---开始进入下一小队: lineupIndex=%s,nextLineupID=%s,%s" % (turnFight.lineupIndex, nextLineupID, turnFight.lineupIDList))
|
| | |
|
| | | turnFight.nextTurnFight(resetByNextTeam=True)
|
| | | turnFight.nextTurnFight()
|
| | | # 切换小队时,玩家阵容不需要处理,保留状态
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(nextLineupID, turnFight.strongerLV, turnFight.difficulty)})
|
| | | turnFight.sortActionQueue()
|
| | |
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | turnNum = turnFight.turnNum
|
| | | turnMax = turnFight.turnMax
|
| | | turnNumStart = turnFight.turnNumStart
|
| | | for turnNum in range(turnNum, turnMax + 1):
|
| | | turnTimeline = turnFight.getTurnNumStartTimelin(turnNum) # 本回合起始时间节点
|
| | | curTimeline = turnFight.getTimeline()
|
| | | if turnFight.winFaction:
|
| | | break
|
| | |
|
| | | # 回合开始
|
| | | turnTimeline += 1 # 每回合开始算一个时间节点
|
| | | if curTimeline < turnTimeline:
|
| | | curTimeline = turnFight.setTimeline(turnTimeline)
|
| | | GameWorld.DebugLog("【----- 回合制战斗轮次: %s -----】 curTimeline=%s" % (turnNum, curTimeline))
|
| | | if turnNumStart < turnNum:
|
| | | GameWorld.DebugLog("【----- 回合制战斗轮次: %s -----】 " % (turnNum))
|
| | | turnFight.turnNum = turnNum
|
| | | turnFight.turnNumStart = turnNum
|
| | | if curPlayer:
|
| | | turnFight.syncState(FightState_Fighting)
|
| | | |
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合开始逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = 1
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightPerTurnBigStart(turnFight, batObj, turnNum)
|
| | | |
| | | TurnFightPerTurnBigStart(turnFight, turnNum)
|
| | | |
| | | # 红颜
|
| | | # 灵兽
|
| | |
|
| | | if turnFight.checkOverByKilled():
|
| | | if turnFight.winFaction:
|
| | | break
|
| | |
|
| | | # 武将
|
| | | doMax = PosNumMax * len(turnFight.actionSortList)
|
| | | doCnt = 0
|
| | | while doCnt < doMax and turnFight.actionIndex < len(turnFight.actionSortList):
|
| | | while doCnt < doMax and turnFight.actionIndex < len(turnFight.actionSortList) and not turnFight.winFaction:
|
| | | doCnt += 1
|
| | | faction, num = turnFight.actionSortList[turnFight.actionIndex]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for posNum in range(batLineup.actionNum, PosNumMax + 1):
|
| | | # 每个武将位算一个时间节点
|
| | | #GameWorld.DebugLog("武将节点: faction=%s,posNum=%s,curTimeline=%s" % (faction, posNum, curTimeline))
|
| | | #GameWorld.DebugLog("武将位置: faction=%s,posNum=%s" % (faction, posNum))
|
| | | if posNum not in batLineup.posObjIDDict:
|
| | | batLineup.actionNum = posNum + 1
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1, True)
|
| | | #GameWorld.DebugLog("空位节点: faction=%s,posNum=%s,curTimeline=%s" % (faction, posNum, curTimeline))
|
| | | #GameWorld.DebugLog("没有武将: 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("玩家阵容下一个可行动的武将,断点: curTimeline=%s,nextPosNum=%s" % (curTimeline, posNum))
|
| | | GameWorld.DebugLog("玩家阵容下一个可行动的武将,断点: nextPosNum=%s" % (posNum))
|
| | | return
|
| | |
|
| | | batLineup.actionNum = posNum + 1
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1)
|
| | | |
| | | TurnFightHeroTurnStart(turnFight, batObj, turnNum)
|
| | | if not OnObjAction(turnFight, batObj):
|
| | | isAction = OnObjAction(turnFight, batObj)
|
| | | TurnFightHeroTurnEnd(turnFight, batObj, turnNum)
|
| | | |
| | | if not isAction:
|
| | | continue
|
| | |
|
| | | if not checkBreakpoint and faction == ChConfig.Def_FactionA:
|
| | |
| | | else:
|
| | | turnFight.actionIndex += 1
|
| | |
|
| | | # 回合结束
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1) # 每回合结束算一个时间节点
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合结束逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightPerTurnBigEnd(turnFight, batObj, turnNum)
|
| | | |
| | | if turnFight.checkOverByKilled():
|
| | | if turnFight.winFaction:
|
| | | break
|
| | | |
| | | # 回合结束
|
| | | TurnFightPerTurnBigEnd(turnFight, turnNum)
|
| | |
|
| | | if not turnFight.winFaction:
|
| | | OnTurnAllOver(turnFight.guid)
|
| | |
| | | EntryLogic(turnFight)
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for turnNum in range(1, turnMax + 1):
|
| | | if turnFight.winFaction:
|
| | | break
|
| | | turnFight.turnNum = turnNum
|
| | | GameWorld.DebugLog("【----- 回合制战斗轮次: %s -----】" % turnNum)
|
| | | curTimeline = turnFight.getTurnNumStartTimelin(turnNum) # 本回合起始时间节点
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1)
|
| | | if curPlayer:
|
| | | turnFight.syncState(FightState_Fighting)
|
| | |
|
| | | # 回合开始
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合开始逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = 1
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightPerTurnBigStart(turnFight, batObj, turnNum)
|
| | | |
| | | |
| | | TurnFightPerTurnBigStart(turnFight, turnNum)
|
| | | |
| | | # 红颜
|
| | | # 灵兽
|
| | |
|
| | | if turnFight.checkOverByKilled():
|
| | | if turnFight.winFaction:
|
| | | break
|
| | |
|
| | | # 武将
|
| | | doMax = PosNumMax * len(turnFight.actionSortList)
|
| | | doCnt = 0
|
| | | while doCnt < doMax and turnFight.actionIndex < len(turnFight.actionSortList):
|
| | | while doCnt < doMax and turnFight.actionIndex < len(turnFight.actionSortList) and not turnFight.winFaction:
|
| | | doCnt += 1
|
| | | faction, num = turnFight.actionSortList[turnFight.actionIndex]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | |
| | | for posNum in range(batLineup.actionNum, PosNumMax + 1):
|
| | | batLineup.actionNum = posNum + 1
|
| | | if posNum not in batLineup.posObjIDDict:
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1, True)
|
| | | continue
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1) # 每个武将位算一个时间节点
|
| | | objID = batLineup.posObjIDDict[posNum]
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightHeroTurnStart(turnFight, batObj, turnNum)
|
| | | if not OnObjAction(turnFight, batObj):
|
| | | isAction = OnObjAction(turnFight, batObj)
|
| | | TurnFightHeroTurnEnd(turnFight, batObj, turnNum)
|
| | | if not isAction:
|
| | | continue
|
| | | |
| | | break
|
| | |
|
| | | if turnFight.actionIndex >= len(turnFight.actionSortList) - 1:
|
| | |
| | | else:
|
| | | turnFight.actionIndex += 1
|
| | |
|
| | | # 回合结束
|
| | | curTimeline = turnFight.setTimeline(curTimeline + 1) # 每回合结束算一个时间节点
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合结束逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightPerTurnBigEnd(turnFight, batObj, turnNum)
|
| | | |
| | | if turnFight.checkOverByKilled():
|
| | | if turnFight.winFaction:
|
| | | break
|
| | | |
| | | # 回合结束
|
| | | TurnFightPerTurnBigEnd(turnFight, turnNum)
|
| | |
|
| | | if not turnFight.winFaction:
|
| | | OnTurnAllOver(turnFight.guid)
|
| | |
| | | batLineup.actionNum = ActionNumStart
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_FightStart)
|
| | |
|
| | | turnFight.enterLogic = True
|
| | | return True
|
| | |
|
| | | def OnTimelineChange(turnFight):
|
| | | ## 每个时间节点变化时处理
|
| | | |
| | | nowTimeline = turnFight.getTimeline()
|
| | | def TurnFightPerTurnBigStart(turnFight, turnNum):
|
| | | ## 大回合开始时
|
| | |
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for batFaction in turnFight.factionDict.values():
|
| | | for batLineup in batFaction.lineupDict.values():
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | #GameWorld.DebugLog("OnTimelineChange! objID=%s" % (objID))
|
| | | if not batObj or not batObj.IsAlive():
|
| | | continue
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("大回合开始逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = 1
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | if not batObj.IsAlive():
|
| | | continue
|
| | | |
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | batObj.SetTiming(ChConfig.TurnTiming_Before) # 重置时机到回合前
|
| | | if turnNum > 1: # 第1回合不用刷新技能
|
| | | RefreshObjSkillByTurn(batObj)
|
| | |
|
| | | batObj.SetDict(ChConfig.Def_Obj_Dict_TurnComboNum, 0)
|
| | | batObj.SetDict(ChConfig.Def_Obj_Dict_TurnMissNum, 0)
|
| | | batObj.SetDict(ChConfig.Def_Obj_Dict_TurnParryNum, 0)
|
| | | |
| | | curID = batObj.GetID()
|
| | | skillManager = batObj.GetSkillManager()
|
| | | for index in range(0, skillManager.GetSkillCount()):
|
| | | curSkill = skillManager.GetSkillByIndex(index)
|
| | | if not curSkill:
|
| | | continue
|
| | | remainTime = curSkill.GetRemainTime()
|
| | | if not remainTime:
|
| | | continue
|
| | | calcTimeline = curSkill.GetCalcTime()
|
| | | passTurn = __calcPassturn(calcTimeline, nowTimeline, True)
|
| | | if passTurn <= 0:
|
| | | continue
|
| | | skillID = curSkill.GetSkillID()
|
| | | updRemainTime = max(0, remainTime - passTurn)
|
| | | curSkill.SetRemainTime(updRemainTime)
|
| | | curSkill.SetCalcTime(nowTimeline)
|
| | | GameWorld.DebugLog("更新技能剩余回合数: curID=%s,skillID=%s,updRemainTime=%s,calcTimeline=%s,passTurn=%s" |
| | | % (curID, skillID, updRemainTime, calcTimeline, passTurn))
|
| | | |
| | | buffMgr = batObj.GetBuffManager()
|
| | | for index in range(buffMgr.GetBuffCount())[::-1]:
|
| | | buff = buffMgr.GetBuffByIndex(index)
|
| | | buffID = buff.GetBuffID()
|
| | | skillID = buff.GetSkillID()
|
| | | skillData = buff.GetSkillData()
|
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLog(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s" % (curID, index, skillID, buffID))
|
| | | continue
|
| | | remainTime = buff.GetRemainTime()
|
| | | if not remainTime:
|
| | | # 永久buff不处理
|
| | | #GameWorld.DebugLog(" 永久buff不处理! curID=%s,index=%s,skillID=%s" % (curID, index, skillID))
|
| | | continue
|
| | | calcTimeline = buff.GetCalcTime()
|
| | | passTurn = __calcPassturn(calcTimeline, nowTimeline, False)
|
| | | if passTurn <= 0:
|
| | | #GameWorld.DebugLog(" passTurn <= 0 passTurn=%s,calcTimeline=%s,nowTimeline=%s,skillID=%s" % (passTurn, calcTimeline, nowTimeline, skillID))
|
| | | continue
|
| | | |
| | | updRemainTime = max(0, remainTime - passTurn)
|
| | | GameWorld.DebugLog("更新buff剩余回合数: curID=%s,buffID=%s,skillID=%s,updRemainTime=%s,calcTimeline=%s,passTurn=%s" |
| | | % (curID, buffID, skillID, updRemainTime, calcTimeline, passTurn))
|
| | | if updRemainTime > 0:
|
| | | buff.SetRemainTime(updRemainTime)
|
| | | buff.SetCalcTime(nowTimeline)
|
| | | TurnBuff.SyncBuffRefresh(turnFight, batObj, buff)
|
| | | else:
|
| | | TurnBuff.DoBuffDel(turnFight, batObj, buff)
|
| | | |
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_BigTurnStart)
|
| | | |
| | | return
|
| | |
|
| | | def __calcPassturn(calcTimeline, nowTimeline, equalOK):
|
| | | ## 计算已经过了的回合数
|
| | | # @param equalOK: 时间节点相同时是否算1回合,一般技能可以算,buff不算
|
| | | calcTurnNum = calcTimeline / TimelineSet
|
| | | calcTimeNode = calcTimeline % TimelineSet
|
| | | nowTurnNum = nowTimeline / TimelineSet
|
| | | nowTimeNode = nowTimeline % TimelineSet
|
| | | if equalOK:
|
| | | if nowTimeNode >= calcTimeNode:
|
| | | return max(0, nowTurnNum - calcTurnNum)
|
| | | return max(0, nowTurnNum - calcTurnNum - 1)
|
| | | else:
|
| | | if nowTimeNode > calcTimeNode:
|
| | | return max(0, nowTurnNum - calcTurnNum)
|
| | | return max(0, nowTurnNum - calcTurnNum - 1)
|
| | | return 0
|
| | |
|
| | | def TurnFightPerTurnBigStart(turnFight, batObj, turnNum):
|
| | | ## 大回合开始时
|
| | | if not batObj:
|
| | | return
|
| | | |
| | | if batObj.GetHP() <= 0:
|
| | | return
|
| | | |
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_BigTurnStart)
|
| | | return
|
| | |
|
| | | def TurnFightPerTurnBigEnd(turnFight, batObj, turnNum):
|
| | | def TurnFightPerTurnBigEnd(turnFight, turnNum):
|
| | | ## 大回合结束时
|
| | | if not batObj:
|
| | | return
|
| | |
|
| | | if batObj.GetHP() <= 0:
|
| | | return
|
| | | |
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_BigTurnEnd)
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for faction, num in turnFight.actionSortList:
|
| | | GameWorld.DebugLog("回合结束逻辑: turnNum=%s,faction=%s, num=%s" % (turnNum, faction, num))
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | if not batObj.IsAlive():
|
| | | continue
|
| | | |
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_BigTurnEnd)
|
| | | |
| | | return
|
| | |
|
| | | def TurnFightHeroTurnStart(turnFight, batObj, turnNum):
|
| | |
| | | if not batObj:
|
| | | return
|
| | |
|
| | | if batObj.GetHP() <= 0:
|
| | | if not batObj.IsAlive():
|
| | | return
|
| | |
|
| | | GameWorld.DebugLog("---[武将回合开始] : curID=%s,curHP=%s/%s" % (batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP()))
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | RefreshObjBuffTime(turnFight, batObj)
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_HeroTurnStart)
|
| | | |
| | | # 最后设置时机为回合后,说明:回合开启前的逻辑处理完后,其他的均默认为回合后
|
| | | batObj.SetTiming(ChConfig.TurnTiming_After)
|
| | | return
|
| | |
|
| | | def TurnFightHeroTurnEnd(turnFight, batObj, turnNum):
|
| | | ## 武将回合结束时,不能行动也要触发
|
| | | if not batObj:
|
| | | return
|
| | | |
| | | if not batObj.IsAlive():
|
| | | return
|
| | | |
| | | GameWorld.DebugLog("---[武将回合结束] : curID=%s,curHP=%s/%s" % (batObj.GetID(), batObj.GetHP(), batObj.GetMaxHP()))
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | RefreshObjBuffTime(turnFight, batObj)
|
| | | return
|
| | |
|
| | | def ResetObjSkill(batObj):
|
| | | ## 重置所有技能,一般是每场战斗开始的重置
|
| | | curID = batObj.GetID()
|
| | | batObj.ResetSkillUseCnt() # 使用次数
|
| | | skillManager = batObj.GetSkillManager()
|
| | | for index in range(0, skillManager.GetSkillCount()):
|
| | | curSkill = skillManager.GetSkillByIndex(index)
|
| | | if not curSkill:
|
| | | continue
|
| | | skillID = curSkill.GetSkillID()
|
| | | initCD = curSkill.GetCoolDownInit()
|
| | | if initCD:
|
| | | curSkill.SetRemainTime(initCD)
|
| | | GameWorld.DebugLog("技能初始CD: curID=%s,skillID=%s,initCD=%s" % (curID, skillID, initCD))
|
| | | elif curSkill.GetRemainTime():
|
| | | curSkill.SetRemainTime(0)
|
| | | curSkill.SetEnergy(0)
|
| | | |
| | | return
|
| | |
|
| | | def RefreshObjSkillByTurn(batObj):
|
| | | '''按回合刷新技能:默认以大回合统一减1回合
|
| | | '''
|
| | | curID = batObj.GetID()
|
| | | skillManager = batObj.GetSkillManager()
|
| | | for index in range(0, skillManager.GetSkillCount()):
|
| | | curSkill = skillManager.GetSkillByIndex(index)
|
| | | if not curSkill:
|
| | | continue
|
| | | skillID = curSkill.GetSkillID()
|
| | | preTurnUseCnt = batObj.GetSkillTurnUseCnt(skillID)
|
| | | remainTime = curSkill.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | | continue
|
| | | if preTurnUseCnt > 0:
|
| | | GameWorld.DebugLog(" 上回合有使用技能本回合不刷新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))
|
| | | |
| | | batObj.ResetSkillTurnUseCnt() # 重置回合使用次数,放刷新CD后重置
|
| | | return
|
| | |
|
| | | def RefreshObjBuffTime(turnFight, batObj):
|
| | | '''刷新buff持续时间:以武将自身回合前、回合后处理buff持续时间
|
| | | 回合前添加的buff在回合开始减1,回合后添加的buff在回合结束减1
|
| | | '''
|
| | | curID = batObj.GetID()
|
| | | curTiming = batObj.GetTiming() # 时间节点 0-回合前;1-回合后
|
| | | buffMgr = batObj.GetBuffManager()
|
| | | for index in range(buffMgr.GetBuffCount())[::-1]:
|
| | | buff = buffMgr.GetBuffByIndex(index)
|
| | | buffID = buff.GetBuffID()
|
| | | skillID = buff.GetSkillID()
|
| | | skillData = buff.GetSkillData()
|
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLog(" 持续类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))
|
| | | 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))
|
| | | 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))
|
| | | continue
|
| | | remainTime -= 1
|
| | | GameWorld.DebugLog(" 更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s,addTiming=%s" % (curID, buffID, skillID, remainTime, addTiming))
|
| | | if remainTime > 0:
|
| | | buff.SetRemainTime(remainTime)
|
| | | TurnBuff.SyncBuffRefresh(turnFight, batObj, buff)
|
| | | else:
|
| | | TurnBuff.DoBuffDel(turnFight, batObj, buff)
|
| | | return
|
| | | |
| | | def AddTurnObjCureHP(curObj, srcObj, addValue, cureHP, skillID=0):
|
| | | ## 回合对象添加治疗值
|
| | | # @param curObj: 获得治疗的对象
|
| | |
| | | % (curID, tagID, skillID, hurtValue, lostHP, curBatObj.GetHP()))
|
| | | return
|
| | |
|
| | | def OnObjAction(turnFight, curBatObj):
|
| | | def OnObjAction(turnFight, curBatObj, isExtra=False):
|
| | | ## 战斗单位行动
|
| | | # @param isExtra: 是否额外行动的
|
| | | if not curBatObj:
|
| | | return
|
| | |
|
| | |
| | | # 是否可行动状态判断
|
| | | canAction = curBatObj.CanAction()
|
| | | if not canAction:
|
| | | GameWorld.DebugLog("★回合%s %s 当前状态不可行动!" % (turnNum, objName))
|
| | | GameWorld.DebugLog("★回合%s %s 当前状态不可行动! isExtra=%s" % (turnNum, objName, isExtra))
|
| | | return
|
| | |
|
| | | atk = curBatObj.GetAtk()
|
| | | curXP = curBatObj.GetXP()
|
| | | GameWorld.DebugLog("★回合%s %s 行动 : atk=%s,curHP=%s/%s,curXP=%s" % (turnNum, objName, atk, curHP, curBatObj.GetMaxHP(), curXP))
|
| | | GameWorld.DebugLog("★回合%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)
|
| | |
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, curBatObj, ChConfig.TriggerWay_HeroActionStart)
|
| | |
| | | skillID = useSkill.GetSkillID()
|
| | | # 常规攻击优先xp
|
| | | if SkillCommon.isAngerSkill(useSkill):
|
| | | if curXP < xpMax:
|
| | | if curXP < xpMax and not useSkill.GetEffectByID(ChConfig.SkillEff_AngerSkillNoXP):
|
| | | continue
|
| | | if curBatObj.IsInState(ChConfig.BatObjState_Sneer):
|
| | | GameWorld.DebugLog("嘲讽状态下,无法主动释放怒技!") # 可被动释放怒技,如怒技追击
|
| | | if curBatObj.CheckInState(ChConfig.BatObjState_Sneer):
|
| | | GameWorld.DebugLog("嘲讽状态下,无法主动释放怒技! skillID=%s" % skillID) # 可被动释放怒技,如怒技追击
|
| | | continue
|
| | | useCnt = -1 # xp技能优先释放
|
| | | else:
|
| | | if useSkill.GetEffectByID(ChConfig.SkillEff_ActionUseInvalid): # 配置该效果时如果被嘲讽,相当于无法行动
|
| | | GameWorld.DebugLog("行动时无法释放该技能! skillID=%s" % skillID)
|
| | | continue
|
| | | useCnt = curBatObj.GetSkillUseCnt(skillID)
|
| | | useSkillList.append([useCnt, skillID, useSkill])
|
| | |
|
| | |
| | | return True
|
| | |
|
| | | def SetObjKilled(turnFight, gameObj, killer=None, useSkill=None):
|
| | | curPlayer = turnFight.curPlayer
|
| | | 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):
|
| | | return
|
| | | |
| | | objID = gameObj.GetID()
|
| | | killerObjID = killer.GetID() if killer else 0
|
| | | skillID = useSkill.GetSkillID() if useSkill else 0
|
| | |
| | | clientPack.SkillID = skillID
|
| | | turnFight.addBatPack(clientPack)
|
| | |
|
| | | curPlayer = turnFight.curPlayer
|
| | | # 暂时只算主线小怪
|
| | | if curPlayer and turnFight.mapID == ChConfig.Def_FBMapID_Main and gameObj.GetFaction() != ChConfig.Def_FactionA:
|
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_KillNPC, 1) |
| | | PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_KillNPC, 1)
|
| | | PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_KillNPC, 1)
|
| | | return True
|
| | |
|
| | | def OnTurnAllOver(guid):
|
| | |
| | | statInfo[str(faction)] = {}
|
| | | facStatInfo = statInfo[str(faction)]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batFaction.totalHurt = 0
|
| | | for num in batFaction.lineupDict.keys():
|
| | | if str(num) not in facStatInfo:
|
| | | facStatInfo[str(num)] = {}
|
| | | lineupStatInfo = facStatInfo[str(num)]
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.totalHurt = 0
|
| | | GameWorld.DebugLog("阵容明细: faction=%s,num=%s" % (faction, num))
|
| | | for posNum, objID in batLineup.posObjIDDict.items():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | |
| | | atkHurt = batObj.hurtStat
|
| | | defHurt = batObj.defStat
|
| | | 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}
|