| | |
| | | else:
|
| | | tfObj.PosNum = posNum
|
| | | tfObj.AngreXP = batObj.GetXP()
|
| | | tfObj.FightPower = batObj.GetFightPower() % ChConfig.Def_PerPointValue
|
| | | tfObj.FightPowerEx = batObj.GetFightPower() / ChConfig.Def_PerPointValue
|
| | | tfLineup.ObjList.append(tfObj)
|
| | | tfLineup.ObjCnt = len(tfLineup.ObjList)
|
| | | tfFaction.LineupList.append(tfLineup)
|
| | |
| | | lineupInfo = lineupDict.get("%s" % ShareDefine.Lineup_Main, {})
|
| | | return lineupInfo
|
| | |
|
| | | def GetPlayerLineupFightPower(curPlayer, lineupID):
|
| | | def GetPlayerLineupFightPower(curPlayer, lineupID=ShareDefine.Lineup_Main):
|
| | | ## 获取玩家阵容战力,一般用于直接获取阵容战力记录用
|
| | | return GetPlayerLineup(curPlayer, lineupID).fightPower
|
| | | def GetPlayerLineup(curPlayer, lineupID):
|
| | | def GetPlayerLineup(curPlayer, lineupID=ShareDefine.Lineup_Main, exclusiveMapID=0):
|
| | | ## 获取玩家阵容
|
| | | olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
|
| | | lineup = olPlayer.GetLineup(lineupID)
|
| | | lineup = olPlayer.GetLineup(lineupID, exclusiveMapID=exclusiveMapID)
|
| | | if lineup.IsEmpty():
|
| | | GameWorld.DebugLogEx("玩家没有目标阵容默认取主阵容! lineupID=%s", lineupID, curPlayer.GetPlayerID())
|
| | | lineup = olPlayer.GetLineup(ShareDefine.Lineup_Main)
|
| | | return lineup
|
| | |
|
| | | def GetPlayerLineupInfo(curPlayer, lineupID):
|
| | | def GetPlayerLineupInfo(curPlayer, lineupID, exclusiveMapID=0):
|
| | | ## 获取玩家阵容信息,可用于战斗或查看缓存,因为可能取玩家的缓存进行对战,所以统一使用json格式,前端通用
|
| | | # @param lineupID: 阵容ID
|
| | | # @param exclusiveMapID: 专享阵容的地图ID,如定军阁
|
| | | # @return: 阵容全部信息json字典,前端通用格式
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | lineup = GetPlayerLineup(curPlayer, lineupID)
|
| | | lineup = GetPlayerLineup(curPlayer, lineupID, exclusiveMapID)
|
| | | if lineup.IsEmpty():
|
| | | return {}
|
| | |
|
| | |
| | | itemIndex = hero.itemIndex
|
| | | heroLV = 1
|
| | | star = 0
|
| | | userData = "{}"
|
| | | if itemIndex >= 0 and itemIndex < curPack.GetCount():
|
| | | heroItem = curPack.GetAt(itemIndex)
|
| | | if heroItem and not heroItem.IsEmpty():
|
| | |
| | | star = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
|
| | | #breakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
|
| | | #awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
|
| | | userData = heroItem.GetUserData()
|
| | |
|
| | | skillIDlist = []
|
| | | skillIDlist += hero.heroSkillIDList
|
| | |
| | | "SkinID":hero.skinID,
|
| | | "LV":heroLV,
|
| | | "Star":star,
|
| | | "Data":userData,
|
| | | #"BreakLV":breakLV,
|
| | | #"AwakeLV":awakeLV,
|
| | | "FightPower":hero.fightPower,
|
| | |
| | | lineupInfo = {"PlayerID":playerID, "FightPower":lineup.fightPower, "ShapeType":lineup.shapeType, "Hero":heroDict}
|
| | | return lineupInfo
|
| | |
|
| | | def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0):
|
| | | def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0, isLog=True, viewNPCID=0):
|
| | | ## 获取NPC阵容信息
|
| | | # @param lineupID: 阵容ID
|
| | | # @param npcLV: 成长NPC等级
|
| | | # @param difficulty: 成长NPC难度系数
|
| | | # @param viewNPCID: 查看指定的NPCID,供前端查询NPC属性用
|
| | | # @return: 阵容全部信息json字典,前端通用格式
|
| | | lineupInfo = GetGMTestNPCLineupInfo(lineupID, strongerLV, difficulty)
|
| | | if lineupInfo:
|
| | |
| | | npcID = getattr(ipyData, "GetPosNPCID%s" % posNum)()
|
| | | if not npcID:
|
| | | continue
|
| | | battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty)
|
| | | if viewNPCID and viewNPCID != npcID:
|
| | | continue
|
| | | battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty, isLog)
|
| | | if not battleDict:
|
| | | continue
|
| | | heroDict[str(posNum)] = battleDict
|
| | | if viewNPCID:
|
| | | break
|
| | |
|
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":bossID, "BossPosView":bossPosView}
|
| | | return lineupInfo
|
| | |
| | | lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":0, "BossPosView":0}
|
| | | return lineupInfo
|
| | |
|
| | | def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0):
|
| | | def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0, isLog=True):
|
| | | ## 获取NPC战斗相关字典,支持成长NPC
|
| | | # @param strongerLV: 成长等级
|
| | | # @param difficulty: 难度系数
|
| | |
| | | npcLV = npcData.GetLV()
|
| | | star, breakLV, awakeLV = 0, 0, 0
|
| | |
|
| | | lvIpyData = None
|
| | | reModelID = lineupIpyData.GetReModelID()
|
| | | lvReIpyData = None
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | | npcStronger = IpyGameDataPY.GetIpyGameDataNotLog("NPCStronger", npcID)
|
| | | if npcStronger and strongerLV:
|
| | | lvIpyData = IpyGameDataPY.GetIpyGameData("PlayerLV", strongerLV)
|
| | | if lvIpyData:
|
| | | lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, strongerLV)
|
| | | if lvReIpyData:
|
| | | npcLV = strongerLV
|
| | | if not lvIpyData:
|
| | | lvIpyData = IpyGameDataPY.GetIpyGameData("PlayerLV", npcLV)
|
| | | if lvIpyData:
|
| | | star = lvIpyData.GetReHeroStar()
|
| | | breakLV = lvIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvIpyData.GetReHeroAwakeLV()
|
| | | if not lvReIpyData:
|
| | | lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, npcLV)
|
| | | if lvReIpyData:
|
| | | star = lvReIpyData.GetReHeroStar()
|
| | | breakLV = lvReIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvReIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData:
|
| | | skinIDList = heroIpyData.GetSkinIDList()
|
| | | skinID = skinIDList[0] if skinIDList else 0
|
| | |
| | | random.shuffle(randSkillIDExList)
|
| | | randSkillIDExList = randSkillIDExList[:skillExCnt]
|
| | | skillIDList += randSkillIDExList
|
| | | GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
|
| | | isLog and GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
|
| | |
|
| | | # 成长怪属性
|
| | | batAttrDict = GetNPCStrongerAttrDict(npcID, lvIpyData, npcStronger, difficulty)
|
| | | batAttrDict = GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog)
|
| | | if not batAttrDict:
|
| | | batAttrDict = {ChConfig.AttrID_Atk:npcData.GetAtk(), ChConfig.AttrID_Def:npcData.GetDef(), ChConfig.AttrID_MaxHP:npcData.GetMaxHP(),
|
| | | ChConfig.AttrID_FinalDamPer:npcData.GetFinalDamPer(), ChConfig.AttrID_FinalDamPerDef:npcData.GetFinalDamPerDef(),
|
| | |
| | | "SkinID":skinID,
|
| | | "LV":npcLV,
|
| | | "Star":star,
|
| | | #"BreakLV":breakLV,
|
| | | #"AwakeLV":awakeLV,
|
| | | "BreakLV":breakLV,
|
| | | "AwakeLV":awakeLV,
|
| | | "AttrDict":{str(k):v for k, v in batAttrDict.items() if v > 0},
|
| | | "SkillIDList":skillIDList,
|
| | | }
|
| | |
|
| | | GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,%s", npcID, strongerLV, difficulty, battleDict)
|
| | | isLog and GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,reModelID=%s,%s", npcID, strongerLV, difficulty, reModelID, battleDict)
|
| | | return battleDict
|
| | |
|
| | | def GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV):
|
| | |
| | |
|
| | | return skillIDList
|
| | |
|
| | | def GetNPCStrongerAttrDict(npcID, lvIpyData, npcStronger, difficulty):
|
| | | def GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog=True):
|
| | | ## 获取NPC成长属性
|
| | | # @param strongerLV: 成长等级
|
| | | # @param difficulty: 难度系数
|
| | |
|
| | | batAttrDict = {}
|
| | | if not lvIpyData or not npcStronger or not difficulty:
|
| | | if not lvReIpyData or not npcStronger or not difficulty:
|
| | | return batAttrDict
|
| | | lv = lvIpyData.GetLV()
|
| | | lv = lvReIpyData.GetLV()
|
| | | for attrID in ChConfig.CalcBattleAttrIDList:
|
| | | attrIpyData = IpyGameDataPY.GetIpyGameData("PlayerAttr", attrID)
|
| | | if not attrIpyData:
|
| | | continue
|
| | | attrName = attrIpyData.GetParameter()
|
| | | if not hasattr(lvIpyData, "GetRe%s" % attrName):
|
| | | if not hasattr(lvReIpyData, "GetRe%s" % attrName):
|
| | | continue
|
| | | reValue = getattr(lvIpyData, "GetRe%s" % attrName)() # 基础参考值
|
| | | reValue = getattr(lvReIpyData, "GetRe%s" % attrName)() # 基础参考值
|
| | | ratio = getattr(npcStronger, "Get%sRatio" % attrName)() if hasattr(npcStronger, "Get%sRatio" % attrName) else 1 # 属性系数
|
| | | attrValue = int(reValue * ratio * difficulty)
|
| | | batAttrDict[attrID] = attrValue
|
| | | #GameWorld.DebugLogEx(" attrID=%s,attrValue=%s,reValue=%s,ratio=%s,difficulty=%s", attrID, attrValue, reValue, ratio, difficulty)
|
| | |
|
| | | GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
|
| | | isLog and GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
|
| | | return batAttrDict
|
| | |
|
| | | def SummonLineupObjs(batLineup, faction, num, lineupInfo, reqPlayerID=0):
|
| | |
| | | if not reqRet:
|
| | | return
|
| | | funcLineID = reqRet[1] if len(reqRet) > 1 else funcLineID
|
| | | GameWorld.DebugLogEx(" funcLineID=%s", funcLineID, playerID)
|
| | |
|
| | | fbIpyData = FBCommon.GetFBIpyData(mapID)
|
| | | fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID, False)
|
| | | if fbIpyData:
|
| | | if not fbLineIpyData:
|
| | | GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
|
| | | return
|
| | | #if not fbLineIpyData:
|
| | | # GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
|
| | | # return
|
| | | if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, funcLineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
|
| | | return
|
| | |
|
| | | # 攻防方所使用的阵容ID
|
| | | atkLineupID, defLineupID = FBLogic.GetFBPlayerLineupID(curPlayer, mapID, funcLineID)
|
| | | if atkLineupID not in ShareDefine.LineupList or defLineupID not in ShareDefine.LineupList:
|
| | | return
|
| | | |
| | | if CheckFightCD(curPlayer, tick, "TurnFightReqTick"):
|
| | | return
|
| | |
|
| | |
| | | playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
| | | guid = GameWorld.GetGUID()
|
| | |
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | | atkLineupID = ShareDefine.Lineup_Main # 进攻方默认使用主阵容
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID, mapID)
|
| | | if not atkLineupInfo:
|
| | | GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s", atkLineupID, playerID)
|
| | | GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s,mapID=%s", atkLineupID, mapID, playerID)
|
| | | return
|
| | |
|
| | | # 玩家
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
|
| | | return
|
| | |
|
| | | defLineupID = ChConfig.MapLineIDDict.get(mapID, ShareDefine.Lineup_Main)
|
| | | defLineupInfo = GetCacheLineupInfo(tagViewCache, defLineupID)
|
| | | if not defLineupInfo:
|
| | | GameWorld.DebugLogEx("目标玩家没有该阵容数据! tagPlayerID=%s,defLineupID=%s", tagPlayerID, defLineupID, playerID)
|
| | |
| | |
|
| | | for index, lineupID in enumerate(npcLineupIDList):
|
| | | turnFight.lineupIndex = index
|
| | | GameWorld.DebugLogEx("对战NPC阵容: index=%s, lineupID=%s", index, lineupID)
|
| | | GameWorld.DebugLogEx("对战NPC阵容: mapID=%s,funcLineID=%s,index=%s,lineupID=%s", mapID, funcLineID, index, lineupID)
|
| | | if index > 0:
|
| | | turnFight.nextTurnFight()
|
| | | turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
|
| | |
| | | if not curSkill:
|
| | | continue
|
| | | skillID = curSkill.GetSkillID()
|
| | | |
| | | # 每大回合重置能量
|
| | | if curSkill.GetEnergy():
|
| | | for eIndex in range(curSkill.GetEffectCount()):
|
| | | effect = curSkill.GetEffect(eIndex)
|
| | | if effect.GetEffectID() == ChConfig.PassiveEff_EnergySkill and effect.GetEffectValue(2) == 1:
|
| | | curSkill.SetEnergy(0)
|
| | | GameWorld.DebugLogEx(" 每大回合重置技能能量! curID=%s,skillID=%s", curID, skillID)
|
| | | break
|
| | | |
| | | preTurnUseCnt = batObj.GetSkillTurnUseCnt(skillID)
|
| | | remainTime = curSkill.GetRemainTime()
|
| | | if remainTime <= 0:
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, "FightReportExpired")
|
| | | return
|
| | |
|
| | | #// B4 16 查看NPC属性 #tagCSViewNPCAttr
|
| | | #
|
| | | #struct tagCSViewNPCAttr
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD MapID; // 自定义地图ID,可用于绑定战斗地图场景功能(如主线boss、爬塔、竞技场等)
|
| | | # DWORD FuncLineID; // MapID对应的扩展值,如具体某个关卡等
|
| | | # DWORD ViewNPCID; // 指定查看某个NPCID,发0则查看该关卡阵容所有NPC
|
| | | #};
|
| | | def OnViewNPCAttr(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | mapID = clientData.MapID
|
| | | funcLineID = clientData.FuncLineID
|
| | | viewNPCID = clientData.ViewNPCID |
| | | SyncLineupNPCAttr(curPlayer, mapID, funcLineID, viewNPCID)
|
| | | return
|
| | |
|
| | | def SyncLineupNPCAttr(curPlayer, mapID, funcLineID, viewNPCID=0):
|
| | | lineupIDList = []
|
| | | strongerLV, difficulty = 0, 0
|
| | | |
| | | if mapID == ChConfig.Def_FBMapID_MainBoss:
|
| | | chapterID = funcLineID / 100
|
| | | levelNum = funcLineID % 100
|
| | | levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
|
| | | if not levelIpyData:
|
| | | return
|
| | | lineupIDList = levelIpyData.GetBossLineupIDList() # Boss波阵容ID列表,小队1阵容ID|小队2阵容ID|...
|
| | | strongerLV = levelIpyData.GetNPCLV()
|
| | | difficulty = levelIpyData.GetDifficulty()
|
| | | |
| | | else:
|
| | | fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID)
|
| | | if fbLineIpyData:
|
| | | lineupIDList = fbLineIpyData.GetLineupIDList()
|
| | | strongerLV = fbLineIpyData.GetNPCLV()
|
| | | difficulty = fbLineIpyData.GetDifficulty()
|
| | | else:
|
| | | ret = FBLogic.GetFBNPCLineupInfo(curPlayer, mapID, funcLineID)
|
| | | if not ret:
|
| | | return
|
| | | lineupIDList, strongerLV, difficulty = ret
|
| | | |
| | | if not lineupIDList:
|
| | | return
|
| | | |
| | | npcAttrList = []
|
| | | for lineupID in lineupIDList:
|
| | | lineupInfo = GetNPCLineupInfo(lineupID, strongerLV, difficulty, False, viewNPCID=viewNPCID)
|
| | | if not lineupInfo:
|
| | | continue
|
| | | heroDict = lineupInfo["Hero"]
|
| | | for posNum, attrInfo in heroDict.items():
|
| | | posNum = int(posNum)
|
| | | npcAttr = ChPyNetSendPack.tagSCViewNPCAttr()
|
| | | npcAttr.PosNum = posNum
|
| | | npcAttr.NPCID = attrInfo["NPCID"]
|
| | | npcAttr.HeroID = attrInfo["HeroID"]
|
| | | npcAttr.LV = attrInfo["LV"]
|
| | | npcAttr.Star = attrInfo["Star"]
|
| | | npcAttr.BreakLV = attrInfo["BreakLV"]
|
| | | npcAttr.AwakeLV = attrInfo["AwakeLV"]
|
| | | npcAttr.AttrMsg = json.dumps(attrInfo["AttrDict"], ensure_ascii=False).replace(" ", "")
|
| | | npcAttr.AttrLen = len(npcAttr.AttrMsg)
|
| | | npcAttrList.append(npcAttr)
|
| | | if not npcAttrList:
|
| | | return
|
| | | clientPack = ChPyNetSendPack.tagSCViewNPCAttrRet()
|
| | | clientPack.MapID = mapID
|
| | | clientPack.FuncLineID = funcLineID
|
| | | clientPack.ViewNPCID = viewNPCID
|
| | | clientPack.NPCAttrList = npcAttrList
|
| | | clientPack.NPCCnt = len(clientPack.NPCAttrList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def SyncTurnFightReport(curPlayer, guid, reprot):
|
| | | ## 通知完整战报
|
| | | clientPack = ChPyNetSendPack.tagSCTurnFightReport()
|