| | |
| | | import PlayerLLMJ
|
| | | import PlayerPrestigeSys
|
| | | import CrossServerPackLogic
|
| | | import PlayerSuccess
|
| | | import IpyGameDataPY
|
| | | import PlayerOnline
|
| | | import NPCCommon
|
| | |
| | | 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
|
| | | self._reqServerID = reqServerID # 可能是玩家的服务器ID,或者请求的ServerID
|
| | | self.curPlayer = None
|
| | | self.mapID = mapID
|
| | | self.funcLineID = funcLineID
|
| | |
| | | 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,
|
| | |
| | | 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 lvIpyData:
|
| | | star = lvIpyData.GetReHeroStar()
|
| | | breakLV = lvIpyData.GetReHeroBreakLV()
|
| | | awakeLV = lvIpyData.GetReHeroAwakeLV()
|
| | | if heroIpyData and lvIpyData:
|
| | | 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
|
| | |
| | | "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,
|
| | | }
|
| | |
| | | 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.DebugLog("AddBatObj %s,lv=%s,star=%s,skill=%s" % (GetObjName(batObj), lv, star, skillManager.GetSkillIDList()))
|
| | | ResetObjSkill(batObj)
|
| | |
|
| | | if npcID:
|
| | |
| | | return
|
| | |
|
| | | reqPlayerID = playerID
|
| | | playerServerID = GameWorld.GetPlayerServerID(curPlayer)
|
| | | guid = GameWorld.GetGUID()
|
| | |
|
| | | atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
|
| | |
| | |
|
| | | lineupDictA = {1:atkLineupInfo}
|
| | | lineupDictB = {1:defLineupInfo}
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, reqData=[tagType, tagID, valueList])
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, reqData=[tagType, tagID, valueList])
|
| | |
|
| | | # NPC
|
| | | else:
|
| | |
| | |
|
| | | lineupDictA = {1:atkLineupInfo}
|
| | | lineupDictB = None
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty)
|
| | | AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty)
|
| | |
|
| | | return True
|
| | |
|
| | | def AddToBattleQueue(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID=0, npcLineupIDList=[], strongerLV=0, difficulty=0, reqData=None):
|
| | | 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时用
|
| | |
| | | # pvp 或 pve 必须要满足其中一种
|
| | | return
|
| | |
|
| | | reqServerID = GameWorld.GetGameWorld().GetServerID()
|
| | | reqInfo = [guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData]
|
| | | fromServerID = GameWorld.GetGameWorld().GetServerID()
|
| | | reqInfo = [guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData]
|
| | | multiMapSet = IpyGameDataPY.GetFuncCfg("TurnFightProcess", 1)
|
| | | # 多地图战斗 0-本地图处理;1-多地图处理;2-debug模式默认本地图处理,非debug默认多地图处理
|
| | | isMultiMap = False
|
| | |
| | | if isMultiMap:
|
| | | CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
|
| | | else:
|
| | | SSMsg_BattleRequest(reqInfo, reqServerID)
|
| | | SSMsg_BattleRequest(reqInfo, fromServerID)
|
| | | return
|
| | |
|
| | | def SSMsg_BattleRequest(reqInfo, fromServerID):
|
| | | ## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | | guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
|
| | |
|
| | | if npcLineupIDList:
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, fromServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | | turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
|
| | | else:
|
| | | turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, fromServerID)
|
| | | turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID)
|
| | |
|
| | | winFaction = None
|
| | | statMsg = {}
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, reqServerID, playerLineupDict, npcLineupIDList, strongerLV, difficulty):
|
| | | def DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, playerLineupDict, npcLineupIDList, strongerLV, difficulty):
|
| | | '''执行PVE战斗,支持多小队
|
| | | '''
|
| | |
|
| | | turnMax = GetTurnMax(mapID)
|
| | |
|
| | | tfMgr = GetTurnFightMgr()
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, reqServerID)
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, playerServerID)
|
| | | guid = turnFight.guid
|
| | |
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, True)
|
| | |
| | | tfMgr.delTurnFight(guid)
|
| | | return turnFight if saveOK else None
|
| | |
|
| | | def DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID=0, reqServerID=0):
|
| | | def DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID=0, playerServerID=0):
|
| | | '''执行PVP战斗,只处理战斗,不关心功能及curPlayer相关
|
| | | @param lineupDictA: 阵营A所有阵容{阵容编号:{阵容信息}, ...}
|
| | | @param lineupDictB: 阵营B所有阵容{阵容编号:{阵容信息}, ...}
|
| | |
| | | turnMax = GetTurnMax(mapID)
|
| | |
|
| | | tfMgr = GetTurnFightMgr()
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, reqServerID)
|
| | | turnFight = tfMgr.addTurnFight(guid, mapID, funcLineID, reqPlayerID, playerServerID)
|
| | | guid = turnFight.guid
|
| | |
|
| | | turnFight.setTurnFight(mapID, funcLineID, turnMax, True)
|
| | |
| | | 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()
|
| | |
| | | cureHP = batObj.cureStat
|
| | | batLineup.totalHurt += atkHurt
|
| | | batFaction.totalHurt += atkHurt
|
| | | dead = 0 if batObj.IsAlive() else 1
|
| | | 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}
|
| | | 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}
|
| | |
|
| | | statMsg = {"winFaction":winFaction, "statInfo":statInfo}
|
| | |
|
| | |
| | | pass
|
| | |
|
| | | saveFilePath = os.path.join(ReportDir, "%s.tfr" % guid)
|
| | | GameWorld.DebugLog("__saveBatBuffer=%s" % saveFilePath)
|
| | | GameWorld.DebugLog("战报路径=%s" % saveFilePath)
|
| | |
|
| | | try:
|
| | | clientPack = ChPyNetSendPack.tagSCTurnFightReport()
|