| | |
| | | self.lineupInfo = {} # 传入初始化的阵容信息
|
| | | self.shapeType = 0 # 阵型
|
| | | self.fightPower = 0 # 阵容总战力
|
| | | self.minggeObj = None # 命格战斗对象
|
| | | self.posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...}, 站位编号小于0为非主战单位,如主公、红颜等
|
| | | self.heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
|
| | | self.lingshouObjIDDict = {} # 灵兽战斗单位 {位置编号:batObjID, ...}
|
| | | |
| | | self._posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...},如主公、命格、灵兽等
|
| | | self._heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
|
| | | self._batHeroObjIDList = [] # 主战武将对象ID列表
|
| | | self._minggeObjID = 0 # 命格对象ID
|
| | | self.actionNum = ActionNumStart # 行动位置,从1开始
|
| | | self.totalHurt = 0 # 阵容总输出
|
| | |
|
| | |
| | |
|
| | | def getReqPlayerID(self): return self.turnFight.getReqPlayerID() # 发起的玩家ID
|
| | |
|
| | | def isEmpty(self): return not self.posObjIDDict
|
| | | def isEmpty(self): return not self._batHeroObjIDList
|
| | |
|
| | | def setLineupInfo(self, lineupInfo):
|
| | | ## 设置阵容
|
| | |
| | | def clearLineup(self):
|
| | | ## 清除阵容
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in self.posObjIDDict.values():
|
| | | for objID in self._posObjIDDict.values():
|
| | | batObjMgr.delBatObj(objID)
|
| | | for objID in self.lingshouObjIDDict.values():
|
| | | batObjMgr.delBatObj(objID)
|
| | | if self.minggeObj:
|
| | | batObjMgr.delBatObj(self.minggeObj.GetID())
|
| | | self.lineupInfo = {}
|
| | | self.posObjIDDict = {}
|
| | | self.heroObjIDDict = {}
|
| | | self.lingshouObjIDDict = {}
|
| | | self._posObjIDDict = {}
|
| | | self._heroObjIDDict = {}
|
| | | self._batHeroObjIDList = []
|
| | | self._minggeObjID = 0
|
| | | self.fightPower = 0
|
| | | self.totalHurt = 0
|
| | | return
|
| | | |
| | | def addObj(self, batObj):
|
| | | objID = batObj.GetID()
|
| | | posNum = batObj.GetPosNum()
|
| | | heroID = batObj.GetHeroID()
|
| | | batObjType = batObj.GetBatObjType()
|
| | | self._posObjIDDict[posNum] = objID
|
| | | if heroID:
|
| | | self._heroObjIDDict[heroID] = objID
|
| | | |
| | | if batObjType == ChConfig.BatObjType_BatHero:
|
| | | if objID not in self._batHeroObjIDList:
|
| | | self._batHeroObjIDList.append(objID)
|
| | | elif batObjType == ChConfig.BatObjType_Mingge:
|
| | | self._minggeObjID = objID
|
| | | elif batObjType == ChConfig.BatObjType_Lingshou:
|
| | | pass
|
| | | return
|
| | | |
| | | def getPosObjIDDict(self): return self._posObjIDDict
|
| | | def getAllPosObjIDList(self): return self._posObjIDDict.values()
|
| | | |
| | | def getBatHeroObjIDList(self): return self._batHeroObjIDList ## 获取主战武将对象ID列表
|
| | | |
| | | def getHeroObj(self, heroID):
|
| | | if heroID not in self._heroObjIDDict:
|
| | | return
|
| | | return BattleObj.GetBatObjMgr().getBatObj(self._heroObjIDDict[heroID])
|
| | | |
| | | def getMinggeObj(self):
|
| | | if not self._minggeObjID:
|
| | | return
|
| | | return BattleObj.GetBatObjMgr().getBatObj(self._minggeObjID) |
| | |
|
| | | def getDeadObjCnt(self):
|
| | | ## 获取本阵容目前死亡队员数
|
| | | deadCnt = 0
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in self.posObjIDDict.values():
|
| | | for objID in self._batHeroObjIDList:
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | |
| | | continue
|
| | | deadCnt += 1
|
| | | return deadCnt
|
| | | |
| | | def getHeroObj(self, heroID):
|
| | | if heroID not in self.heroObjIDDict:
|
| | | return
|
| | | return BattleObj.GetBatObjMgr().getBatObj(self.heroObjIDDict[heroID])
|
| | | |
| | | def getMinggeObj(self): return self.minggeObj
|
| | |
|
| | | class BatFaction():
|
| | | ## 战斗阵营
|
| | |
| | |
|
| | | def sortActionQueue(self):
|
| | | ## 刷新出手顺序队列
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | sortList = []
|
| | | for batFaction in self.factionDict.values():
|
| | | faction = batFaction.faction
|
| | | for num, batLineup in batFaction.lineupDict.items():
|
| | | isPlayer = 1 if batLineup.ownerID else 0 # 玩家阵容优先攻击
|
| | | atkSpeed = 0
|
| | | for objID in batLineup.getBatHeroObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | atkSpeed += batObj.GetBatAttrValue(ChConfig.AttrID_AtkSpeed)
|
| | | fightPower = batLineup.fightPower
|
| | | sortValue = -(faction * 10 + num)
|
| | | sortList.append([isPlayer, fightPower, sortValue, faction, num])
|
| | | sortList.append([isPlayer, atkSpeed, fightPower, sortValue, faction, num])
|
| | | sortList.sort(reverse=True) # 战力高的先手
|
| | |
|
| | | self.actionIndex = 0
|
| | | self.actionSortList = []
|
| | | for _, _, _, faction, num in sortList:
|
| | | for sortInfo in sortList:
|
| | | faction, num = sortInfo[-2:]
|
| | | self.actionSortList.append([faction, num])
|
| | |
|
| | | GameWorld.DebugLogEx("阵容战力排序[isPlayer, fp, sortV, f, n]: %s", sortList)
|
| | |
| | | for batLineup in batFaction.lineupDict.values():
|
| | | if not allKilled:
|
| | | break
|
| | | for posNum, objID in batLineup.posObjIDDict.items():
|
| | | if posNum <= 0:
|
| | | # 非主战位置不判断
|
| | | continue
|
| | | for objID in batLineup.getBatHeroObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | |
| | | tfLineup.OwnerID = batLineup.ownerID
|
| | | tfLineup.ShapeType = batLineup.shapeType
|
| | | tfLineup.ObjList = []
|
| | | for posNum, objID in batLineup.posObjIDDict.items():
|
| | | for posNum, objID in batLineup.getPosObjIDDict().items():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | if posNum == ChConfig.TFPosNum_Mingge: # 理论上要都同步,但是前端需要同步修改,等前端要改时再同步
|
| | | continue
|
| | | tfObj = ChPyNetSendPack.tagSCTurnFightObj()
|
| | | tfObj.ObjID = batObj.GetID()
|
| | |
| | | if mgSkillIDList:
|
| | | minggeObj = batObjMgr.addBatObj()
|
| | | if minggeObj:
|
| | | batLineup.minggeObj = minggeObj
|
| | | minggeObj.SetOwnerID(lineupPlayerID)
|
| | | minggeObj.SetTFGUID(tfGUID)
|
| | | minggeObj.SetFaction(faction)
|
| | |
| | | skillManager.SkillReset()
|
| | | for skillID in mgSkillIDList:
|
| | | skillManager.LearnSkillByID(skillID)
|
| | | batLineup.addObj(minggeObj)
|
| | | GameWorld.DebugLogEx("AddBatObj 命格: faction:%s,num:%s,objID=%s,skillIDList=%s", faction, num, minggeObj.GetID(), skillManager.GetSkillIDList())
|
| | | ResetObjSkill(minggeObj)
|
| | | minggeObj.InitBatAttr({ChConfig.AttrID_MaxHP:1})
|
| | |
| | | batObj = batObjMgr.addBatObj()
|
| | | if not batObj:
|
| | | break
|
| | | objID = batObj.GetID()
|
| | | #objID = batObj.GetID()
|
| | | if npcID:
|
| | | batObj.SetNPCID(npcID)
|
| | | elif lineupPlayerID:
|
| | |
| | | for skillID in skillIDList:
|
| | | skillManager.LearnSkillByID(skillID)
|
| | |
|
| | | batLineup.posObjIDDict[posNum] = objID
|
| | | batLineup.heroObjIDDict[heroID] = objID
|
| | | batLineup.addObj(batObj)
|
| | | GameWorld.DebugLogEx("AddBatObj %s,lv=%s,star=%s,skill=%s", GetObjName(batObj), lv, star, skillManager.GetSkillIDList())
|
| | | ResetObjSkill(batObj)
|
| | |
|
| | |
| | | GameWorld.DebugLogEx("切换小队重置玩家阵容武将...")
|
| | | batLineup = batFaction.getBatlineup(1) # 只处理玩家阵容
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | for objID in batLineup.getAllPosObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | |
| | | turnFight.syncState(FightState_Fighting)
|
| | | TurnFightPerTurnBigStart(turnFight, turnNum)
|
| | |
|
| | | # 红颜
|
| | | # 灵兽
|
| | |
|
| | | if turnFight.winFaction:
|
| | |
| | | faction, num = turnFight.actionSortList[turnFight.actionIndex]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | posObjIDDict = batLineup.getPosObjIDDict()
|
| | | for posNum in range(batLineup.actionNum, PosNumMax + 1):
|
| | | #GameWorld.DebugLogEx("武将位置: faction=%s,posNum=%s", faction, posNum)
|
| | | if posNum not in batLineup.posObjIDDict:
|
| | | if posNum not in posObjIDDict:
|
| | | batLineup.actionNum = posNum + 1
|
| | | #GameWorld.DebugLogEx("没有武将: faction=%s,posNum=%s", faction, posNum)
|
| | | continue
|
| | |
|
| | | objID = batLineup.posObjIDDict[posNum]
|
| | | objID = posObjIDDict[posNum]
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | |
|
| | | # 玩家自己阵营,预判可否行动
|
| | |
| | | faction, num = turnFight.actionSortList[turnFight.actionIndex]
|
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | posObjIDDict = batLineup.getPosObjIDDict()
|
| | | for posNum in range(batLineup.actionNum, PosNumMax + 1):
|
| | | batLineup.actionNum = posNum + 1
|
| | | if posNum not in batLineup.posObjIDDict:
|
| | | if posNum not in posObjIDDict:
|
| | | continue
|
| | | objID = batLineup.posObjIDDict[posNum]
|
| | | objID = posObjIDDict[posNum]
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | TurnFightHeroTurnStart(turnFight, batObj, turnNum)
|
| | | isAction = OnObjAction(turnFight, batObj)
|
| | |
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = ActionNumStart
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | for objID in batLineup.getAllPosObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | turnFight.ResetOneActionUseSkillCnt()
|
| | | TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_FightStart)
|
| | |
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.actionNum = 1
|
| | | for objID in batLineup.posObjIDDict.values():
|
| | | for objID in batLineup.getAllPosObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | |
| | | 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():
|
| | | for objID in batLineup.getAllPosObjIDList():
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | |
| | | batFaction = turnFight.getBatFaction(faction)
|
| | | for lineupNum in batFaction.lineupDict.keys():
|
| | | batLineup = batFaction.getBatlineup(lineupNum)
|
| | | for lineupObjID in batLineup.posObjIDDict.values():
|
| | | for lineupObjID in batLineup.getBatHeroObjIDList():
|
| | | lineupObj = batObjMgr.getBatObj(lineupObjID)
|
| | | if not lineupObj.IsAlive():
|
| | | continue
|
| | |
| | | batLineup.totalHurt = 0
|
| | | facDRLineupInfo[str(num)] = batLineup.lineupInfo
|
| | | GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
|
| | | posObjIDList = [[posNum, objID] for posNum, objID in batLineup.posObjIDDict.items()]
|
| | | mgObj = batLineup.minggeObj # 命格
|
| | | if mgObj:
|
| | | posObjIDList.append([mgObj.GetPosNum(), mgObj.GetID()])
|
| | | # 灵兽
|
| | | for posNum, objID in posObjIDList:
|
| | | for posNum, objID in batLineup.getPosObjIDDict().items():
|
| | | if posNum == ChConfig.TFPosNum_Mingge:
|
| | | #命格不统计
|
| | | continue
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|