| | |
| | | import GameWorld
|
| | | import PlayerLLMJ
|
| | | import PlayerPrestigeSys
|
| | | import CrossServerPackLogic
|
| | | import DataRecordPack
|
| | | import PlayerSuccess
|
| | | import IpyGameDataPY
|
| | |
| | | import TurnBuff
|
| | | import FBCommon
|
| | | import CommFunc
|
| | | import CrossMsg
|
| | | import FBLogic
|
| | |
|
| | | import random
|
| | |
| | | continue
|
| | | deadCnt += 1
|
| | | return deadCnt
|
| | | |
| | | def GetBeFrozenCnt(self):
|
| | | ## 获取本阵容累计被冰冻次数
|
| | | totalCnt = 0
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | for objID in self._batHeroObjIDList:
|
| | | batObj = batObjMgr.getBatObj(objID)
|
| | | if not batObj:
|
| | | continue
|
| | | totalCnt += batObj.GetBeFrozenCnt()
|
| | | return totalCnt
|
| | |
|
| | | class BatFaction():
|
| | | ## 战斗阵营
|
| | |
| | | lineupInfo["MGSkillIDList"] = mgSkillIDList
|
| | | return lineupInfo
|
| | |
|
| | | def GetPlayerHeroBatViewLineupInfo(curPlayer, heroID, skinIndex):
|
| | | ## 获取玩家战斗预览阵容信息
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID)
|
| | | if not heroIpyData:
|
| | | return
|
| | | skinIDList = heroIpyData.GetSkinIDList()
|
| | | skinID = skinIDList[skinIndex] if len(skinIDList) > skinIndex else 0
|
| | | |
| | | heroBatAttrDict = IpyGameDataPY.GetFuncEvalCfg("HeroBatView", 1, {})
|
| | | heroViewInfo = IpyGameDataPY.GetFuncEvalCfg("HeroBatView", 2) # 预览时的武将 站位|等级|星级|突破等级|觉醒等级
|
| | | posNum = heroViewInfo[0] if len(heroViewInfo) > 0 else 2
|
| | | heroLV = heroViewInfo[1] if len(heroViewInfo) > 1 else 100
|
| | | star = heroViewInfo[2] if len(heroViewInfo) > 2 else 0
|
| | | breakLV = heroViewInfo[3] if len(heroViewInfo) > 3 else 0
|
| | | awakeLV = heroViewInfo[4] if len(heroViewInfo) > 4 else 0
|
| | | fightPower = 0
|
| | | |
| | | skillIDlist = GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV)
|
| | | |
| | | heroDict = {}
|
| | | heroDict[str(posNum)] = {
|
| | | "HeroID":heroID,
|
| | | "SkinID":skinID,
|
| | | "LV":heroLV,
|
| | | "Star":star,
|
| | | "BreakLV":breakLV,
|
| | | "AwakeLV":awakeLV,
|
| | | "FightPower":fightPower,
|
| | | "AttrDict":{str(k):v for k, v in heroBatAttrDict.items() if v > 0},
|
| | | "SkillIDList":skillIDlist,
|
| | | }
|
| | | return {"PlayerID":playerID, "Hero":heroDict}
|
| | |
|
| | | def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0, isLog=True, viewNPCID=0):
|
| | | ## 获取NPC阵容信息
|
| | | # @param lineupID: 阵容ID
|
| | |
| | | reModelID = lineupIpyData.GetReModelID()
|
| | | lvReIpyData = None
|
| | | heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
|
| | | npcStronger = IpyGameDataPY.GetIpyGameDataNotLog("NPCStronger", npcID)
|
| | | npcStronger = None
|
| | | npcStrongerList = IpyGameDataPY.GetIpyGameDataListNotLog("NPCStronger", npcID)
|
| | | if npcStrongerList and strongerLV:
|
| | | for strongerData in npcStrongerList:
|
| | | if not strongerData.GetNPCLV() or strongerLV <= strongerData.GetNPCLV():
|
| | | npcStronger = strongerData
|
| | | break
|
| | | if not npcStronger:
|
| | | npcStronger = npcStrongerList[-1] # 找不到时取最后一条
|
| | | |
| | | if npcStronger and strongerLV:
|
| | | lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, strongerLV)
|
| | | if lvReIpyData:
|
| | |
| | | playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
| | | guid = GameWorld.GetGUID()
|
| | |
|
| | | atkBatPresetType = ChConfig.MapAtkBatPresetTypeDict.get(mapID, ShareDefine.BatPreset_Main)
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkBatPresetType, exclusiveMapID=mapID)
|
| | | if mapID == ChConfig.Def_FBMapID_HeroBatView:
|
| | | if not valueList:
|
| | | return
|
| | | heroID = valueList[0]
|
| | | skinIndex = valueList[1] if len(valueList) > 1 else 0
|
| | | atkLineupInfo = GetPlayerHeroBatViewLineupInfo(curPlayer, heroID, skinIndex)
|
| | | else:
|
| | | atkBatPresetType = ChConfig.MapAtkBatPresetTypeDict.get(mapID, ShareDefine.BatPreset_Main)
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkBatPresetType, exclusiveMapID=mapID)
|
| | | if not atkLineupInfo:
|
| | | GameWorld.DebugLogEx("玩家没有主线阵容数据! mapID=%s", mapID, playerID)
|
| | | return
|
| | |
| | | isMultiMap = True
|
| | |
|
| | | if isMultiMap:
|
| | | CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
|
| | | CrossMsg.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
|
| | | else:
|
| | | SSMsg_BattleRequest(reqInfo, fromServerID)
|
| | | S2B_BattleRequest(reqInfo, fromServerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID, msgType=""):
|
| | | def S2B_BattleRequest(reqInfo, fromServerID, msgType=""):
|
| | | ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | #if msgType:
|
| | | # GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | # % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | |
|
| | | if npcLineupIDList:
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | |
| | |
|
| | | # 本地图自己处理的
|
| | | if fromServerID == GameWorld.GetGameWorld().GetServerID():
|
| | | SSMsg_BattleResult(retInfo, fromServerID)
|
| | | B2S_BattleResult(retInfo, fromServerID)
|
| | |
|
| | | # 其他服务器地图请求的,发送战斗结果回去
|
| | | else:
|
| | | CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
|
| | | CrossMsg.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleResult(retInfo, fromServerID, msgType=""):
|
| | | def B2S_BattleResult(retInfo, fromServerID, msgType=""):
|
| | | ## 收到战斗结果信息
|
| | |
|
| | | guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
|
| | | if msgType:
|
| | | GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | | #if msgType:
|
| | | # GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s" |
| | | # % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
|
| | |
|
| | | curPlayer = None
|
| | | if reqPlayerID:
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | reqType = clientData.ReqType
|
| | | reqValue = clientData.ReqValue
|
| | |
|
| | | |
| | | # 开始时补通知一次当前关卡进度, 原因:前端播放战报关卡进度吞包刷新问题
|
| | | curPlayer.SetExAttr1(PlayerControl.GetMainLevelPassValue(curPlayer), False, False) # 不通知GameServer
|
| | | PlayerControl.SetMainLevelNowValue(curPlayer, PlayerControl.GetMainLevelNowValue(curPlayer))
|
| | | |
| | |
|
| | | if reqType == 0:
|
| | | __doExitMainFight(curPlayer)
|
| | |
| | | if not lineupMainInfo:
|
| | | GameWorld.DebugLogEx("没有设置主阵容!", playerID)
|
| | | return
|
| | |
|
| | |
|
| | | strongerLV = levelIpyData.GetNPCLV()
|
| | | difficulty = levelIpyData.GetDifficulty()
|
| | |
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLogEx(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | if skillData.GetSkillType() == ChConfig.Def_SkillType_Halo and buff.GetOwnerID() != curID:
|
| | | if skillData.GetSkillType() in ChConfig.Def_HaloSkill_List and buff.GetOwnerID() != curID:
|
| | | GameWorld.DebugLogEx(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | |
|
| | |
| | | if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
|
| | | #GameWorld.DebugLogEx(" 持续类buff由触发时机决定剩余时间! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | if skillData.GetSkillType() == ChConfig.Def_SkillType_Halo and buff.GetOwnerID() != curID:
|
| | | if skillData.GetSkillType() in ChConfig.Def_HaloSkill_List and buff.GetOwnerID() != curID:
|
| | | GameWorld.DebugLogEx(" 光环buff非光源不处理! curID=%s,index=%s,skillID=%s,buffID=%s", curID, index, skillID, buffID)
|
| | | continue
|
| | | remainTime = buff.GetRemainTime()
|
| | |
| | | heroCount = 0
|
| | | batObjMgr = BattleObj.GetBatObjMgr()
|
| | | statInfo = {}
|
| | | drLineupInfo = {}
|
| | | drHeroIDDict = {}
|
| | | for faction in turnFight.factionDict.keys():
|
| | | if str(faction) not in statInfo:
|
| | | statInfo[str(faction)] = {}
|
| | | facStatInfo = statInfo[str(faction)]
|
| | | if str(faction) not in drLineupInfo:
|
| | | drLineupInfo[str(faction)] = {}
|
| | | facDRLineupInfo = drLineupInfo[str(faction)]
|
| | | if str(faction) not in drHeroIDDict:
|
| | | drHeroIDDict[str(faction)] = {}
|
| | | facDRHeroIDDict = drHeroIDDict[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)]
|
| | | if str(num) not in facDRHeroIDDict:
|
| | | facDRHeroIDDict[str(num)] = {}
|
| | | posHeroIDDict = facDRHeroIDDict[str(num)]
|
| | | batLineup = batFaction.getBatlineup(num)
|
| | | batLineup.totalHurt = 0
|
| | | facDRLineupInfo[str(num)] = batLineup.lineupInfo
|
| | | GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
|
| | | for posNum, objID in batLineup.getPosObjIDDict().items():
|
| | | if posNum == ChConfig.TFPosNum_Mingge:
|
| | |
| | | dead = 0 if batObj.IsAlive() else 1
|
| | | if heroID:
|
| | | heroCount += 1
|
| | | posHeroIDDict[str(posNum)] = heroID
|
| | | 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,
|
| | |
| | | # 流向记录
|
| | | if mapID != ChConfig.Def_FBMapID_Main and reqPlayerID:
|
| | | DataRecordPack.DR_FightStat(reqPlayerID, mapID, funcLineID, turnFight.isWin, turnFight.turnNum, turnFight.turnMax,
|
| | | heroCount, turnFight.costTime, statInfo, drLineupInfo, guid)
|
| | | heroCount, turnFight.costTime, drHeroIDDict, guid)
|
| | | return
|
| | |
|
| | | #// B4 14 查看战报 #tagCSTurnFightReportView
|