ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -138,6 +138,11 @@
            deadCnt += 1
        return deadCnt
    
    def getHeroObj(self, heroID):
        if heroID not in self.heroObjIDDict:
            return
        return BattleObj.GetBatObjMgr().getBatObj(self.heroObjIDDict[heroID])
class BatFaction():
    ## 战斗阵营
    
@@ -635,7 +640,7 @@
    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):
    ## 获取NPC阵容信息
    # @param lineupID: 阵容ID
    # @param npcLV: 成长NPC等级
@@ -657,7 +662,7 @@
        npcID = getattr(ipyData, "GetPosNPCID%s" % posNum)()
        if not npcID:
            continue
        battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty)
        battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty, isLog)
        if not battleDict:
            continue
        heroDict[str(posNum)] = battleDict
@@ -770,7 +775,7 @@
    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: 难度系数
@@ -781,19 +786,20 @@
    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
@@ -814,10 +820,10 @@
                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(), 
@@ -844,7 +850,7 @@
                  "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):
@@ -873,29 +879,29 @@
                
    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):
@@ -1186,15 +1192,18 @@
            isMultiMap = True
            
    if isMultiMap:
        CrossServerPackLogic.SendToBattleServer(ShareDefine.SSMsg_BattleRequest, reqInfo, reqPlayerID)
        CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
    else:
        SSMsg_BattleRequest(reqInfo, fromServerID)
    return
def SSMsg_BattleRequest(reqInfo, fromServerID):
def SSMsg_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 npcLineupIDList:
        turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
    else:
@@ -1216,14 +1225,17 @@
        
    # 其他服务器地图请求的,发送战斗结果回去
    else:
        CrossServerPackLogic.SendToServer(ShareDefine.SSMsg_BattleResult, retInfo, [fromServerID], playerID=reqPlayerID)
        CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
    return
def SSMsg_BattleResult(retInfo, fromServerID):
def SSMsg_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)
    curPlayer = None
    if reqPlayerID:
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(reqPlayerID)
@@ -1705,7 +1717,7 @@
            batObj.SetTiming(ChConfig.TurnTiming_Before) # 重置时机到回合前
            if turnNum > 1: # 第1回合不用刷新技能
                RefreshObjSkillByBigTurn(batObj)
                RefreshObjByBigTurn(turnFight, batObj)
                RefreshObjByBigTurn(turnFight, batObj, turnNum)
            batObj.ResetBigTurn() # 每大回合重置
            
            if not batObj.IsAlive():
@@ -1807,7 +1819,7 @@
        GameWorld.DebugLogEx("    更新技能CD: curID=%s,skillID=%s,remainTime=%s", curID, skillID, remainTime)
    return
def RefreshObjByBigTurn(turnFight, batObj):
def RefreshObjByBigTurn(turnFight, batObj, turnNum):
    ## 根据大回合开始刷新buff持续时间,每个大回合-1,第1回合不处理
    curID = batObj.GetID()
    buffMgr = batObj.GetBuffManager()
@@ -1818,7 +1830,7 @@
        skillData = buff.GetSkillData()
        lastType = skillData.GetLastTimeType()
        
        if lastType not in [ChConfig.BuffLastTimeType_BigTurn, ChConfig.BuffLastTimeType_BigTurnLayer]:
        if lastType not in [ChConfig.BuffLastTimeType_BigTurn, ChConfig.BuffLastTimeType_BigTurnLayer, ChConfig.BuffLastTimeType_BigTurnLimit]:
            continue
        
        if skillData.GetSkillType() in ChConfig.Def_LstBuff_List:
@@ -1829,12 +1841,17 @@
            continue
        
        # 每大回合固定减1回合
        if lastType == ChConfig.BuffLastTimeType_BigTurn:
        if lastType in [ChConfig.BuffLastTimeType_BigTurn, ChConfig.BuffLastTimeType_BigTurnLimit]:
            remainTime = buff.GetRemainTime()
            if remainTime <= 0:
                continue
            remainTime -= 1
            GameWorld.DebugLogEx("    更新buff回合: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
            if lastType == ChConfig.BuffLastTimeType_BigTurnLimit and remainTime > 0:
                lastTurnMax = skillData.GetLastTime()
                if lastTurnMax and turnNum > lastTurnMax:
                    remainTime = 0
                    GameWorld.DebugLogEx("        超过最大限制回合数,强制清除!: curID=%s,buffID=%s,skillID=%s,remainTime=%s", curID, buffID, skillID, remainTime)
            TurnBuff.SetBuffRemainTime(turnFight, batObj, buff, remainTime)
            
        # 每大回合固定减1层
@@ -1857,6 +1874,8 @@
    buffMgr = batObj.GetBuffManager()
    for index in range(buffMgr.GetBuffCount())[::-1]:
        buff = buffMgr.GetBuffByIndex(index)
        if not buff: # 有出现过报错,先做下防范,理论上不太可能
            continue
        buffID = buff.GetBuffID()
        skillID = buff.GetSkillID()
        skillData = buff.GetSkillData()
@@ -2022,7 +2041,7 @@
    killerObjID = killer.GetID() if killer else 0
    skillID = useSkill.GetSkillID() if useSkill else 0
    GameWorld.DebugLogEx("        %s 回合战斗主体被击杀: curID=%s,killerObjID=%s,skillID=%s", GetObjName(gameObj), objID, killerObjID, skillID)
    gameObj.SetDead()
    gameObj.SetDead(killer)
    TurnBuff.DoBuffByDead(turnFight, gameObj)
    
    clientPack = ChPyNetSendPack.tagMCTurnFightObjDead()
@@ -2175,13 +2194,15 @@
    if not os.path.exists(ReportDir):
        os.makedirs(ReportDir)
    else:
        items = os.listdir(ReportDir)
        for item in items:
            fullPath = os.path.join(ReportDir, item)
            try:
                os.remove(fullPath)
            except:
                pass
        isSaveOne = IpyGameDataPY.GetFuncCfg("TurnFightProcess", 2) # 个人战报是否只保留1份
        if isSaveOne:
            items = os.listdir(ReportDir)
            for item in items:
                fullPath = os.path.join(ReportDir, item)
                try:
                    os.remove(fullPath)
                except:
                    pass
            
    saveFilePath = os.path.join(ReportDir, "%s.tfr" % guid)
    GameWorld.DebugLogEx("战报路径=%s", saveFilePath)