From 2a41f04515a5cc91e285cf00e9330dc035e26765 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期二, 16 四月 2019 16:09:14 +0800
Subject: [PATCH] 3287 【2.0】娲皇遗迹S通关异常自动退出副本

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_QueenRelics.py |  226 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 129 insertions(+), 97 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_QueenRelics.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_QueenRelics.py
index 3ae393c..780e9b1 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_QueenRelics.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_QueenRelics.py
@@ -30,6 +30,11 @@
 import ShareDefine
 import EventShell
 import EventReport
+import ChPlayer
+import FBHelpBattle
+import IpyGameDataPY
+import PlayerWeekParty
+import PlayerActLogin
 
 
 #阶段时间
@@ -41,7 +46,7 @@
 
 #当前副本地图的状态
 (
-FB_Step_Open, # 副本开启
+FB_Step_CallHelp, # 助战召唤
 FB_Step_Prepare, # 副本等待
 FB_Step_Fighting, # 副本进行中
 FB_Step_Over, # 副本结束
@@ -90,7 +95,12 @@
         GameWorld.DebugLog("上一层非最大评级过关,无法挑战下一层!lineID=%s,preLineID=%s,preLineGrade=%s,maxGrade=%s" 
                            % (lineId, preLineID, preLineGrade, maxGrade), curPlayer.GetPlayerID())
         return False
-    
+    #判断战力是否满足本层要求
+    helpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, lineId)
+    if helpIpyData:
+        if curPlayer.GetFightPower() < helpIpyData.GetFightPowerMin():
+            GameWorld.DebugLog("战力不足%s,无法挑战本层!lineID=%s" % (helpIpyData.GetFightPowerMin(), lineId), curPlayer.GetPlayerID())
+            return False
     return True
 
 ## 进入传送点
@@ -121,6 +131,12 @@
     curPlayer.ResetPos(enterX, enterY)
     return
 
+## 召唤助战完成
+def OnCallHelpBattleOK(curPlayer, tick):
+    lineID = FBCommon.GetFBPropertyMark()
+    DoQueenRelicsLinePrepare(curPlayer, lineID, tick)
+    return
+
 ## 进副本
 #  @param curPlayer
 #  @param tick
@@ -128,8 +144,7 @@
 def DoEnterFB(curPlayer, tick):
     playerID = curPlayer.GetPlayerID()
     GameWorld.DebugLog("DoEnterFB...", playerID)
-    
-    isHelpFight = FBCommon.GetIsHelpFight(curPlayer)
+
     gameFB = GameWorld.GetGameFB()
     
     if not FBCommon.GetHadDelTicket(curPlayer):
@@ -138,33 +153,21 @@
             GameWorld.ErrLog("进入副本扣除门票失败!", curPlayer.GetPlayerID())
             return 0
         FBCommon.SetHadDelTicket(curPlayer)
-        isHelpFight = FBCommon.SetIsHelpFight(curPlayer)
-        GameWorld.DebugLog("    是否助战: %s" % isHelpFight, playerID)
         
     mapID = ChConfig.Def_FBMapID_QueenRelics
     lineID = FBCommon.GetFBPropertyMark()
     reqLineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqFBFuncLine)
-    joinType = FBCommon.GetFBJoinType(curPlayer, isHelpFight)
     
-    if not FBCommon.GetHadSetFBPropertyMark() or reqLineID > lineID:
-        FBCommon.SetFBPropertyMark(reqLineID, curPlayer)
-        FBCommon.SetFBStep(FB_Step_Open, tick)
-        lineID = reqLineID
-        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_QueenRelics, lineID, ChConfig.CME_Log_Start, joinType)
-        
-    # 最后一次请求的功能线路ID比副本当前的还小,代表掉线期间队友已经打到其他层了,这时候,需要直接切换过去
-    elif reqLineID < lineID:
-        GameWorld.DebugLog("掉线期间队友已经打到其他层了,直接切换到目标功能线路ID!", playerID)
-        toPosX, toPosY = __GetQueenRelicsLinePos(mapID, lineID)
-        PlayerControl.PlayerResetWorldPosFBLineID(curPlayer, mapID, toPosX, toPosY, lineID)
-        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_QueenRelics, lineID, ChConfig.CME_Log_Start, joinType)
-        return
-    else:
-        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_QueenRelics, lineID, ChConfig.CME_Log_Start, joinType)
-        
-    #因为是组队副本,队员轮流进,所以只能设置一次
     fbStep = gameFB.GetFBStep()
-    if fbStep < FB_Step_Prepare:
+    if fbStep == FB_Step_CallHelp:
+        FBCommon.SetFBPropertyMark(reqLineID, curPlayer)
+        lineID = reqLineID
+        FBHelpBattle.SendGameServer_RefreshHelpBattlePlayer(curPlayer, mapID, lineID)
+        return
+    
+    if reqLineID > lineID:
+        FBCommon.SetFBPropertyMark(reqLineID, curPlayer)
+        lineID = reqLineID
         DoQueenRelicsLinePrepare(curPlayer, lineID, tick)
     else:
         fbLineTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_QueenRelics, lineID)
@@ -194,6 +197,14 @@
     __RefreshQueenRelicsNPC(True, False, tick, curPlayer)
     fbLineTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_QueenRelics, lineID)
     curPlayer.Sync_TimeTick(IPY_GameWorld.tttWaitStart, 0, fbLineTime[Def_PrepareTime] * 1000, True)
+    EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_QueenRelics, lineID, ChConfig.CME_Log_Start)
+    
+    helpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", ChConfig.Def_FBMapID_QueenRelics, lineID)
+    if helpIpyData:
+        gameFB.SetGameFBDict(ChConfig.FBPD_HelpBattleFBBaseHurt, helpIpyData.GetRobotBaseHurt())
+        gameFB.SetGameFBDict(ChConfig.FBPD_HelpBattleFBFightPower, helpIpyData.GetFightPowerMin())
+        GameWorld.DebugLog("    更新副本助战机器人基础伤害: lineID=%s,RobotBaseHurt=%s,fbFightPower=%s" 
+                           % (lineID, helpIpyData.GetRobotBaseHurt(), helpIpyData.GetFightPowerMin()))
     return
 
 ##副本总逻辑计时器
@@ -380,6 +391,10 @@
     FBCommon.NotifyFBHelp(curPlayer, lineID, fbHelpDict)
     return
 
+def DoFB_Npc_KillNPC(attacker, curNPC, tick):
+    __FBNPCOnKilled(curNPC, tick)
+    return
+
 ##玩家杀死NPC
 # @param curPlayer:玩家实例
 # @param curNPC:当前被杀死的NPC
@@ -387,6 +402,10 @@
 # @return 返回值无意义
 # @remarks 玩家主动离开副本.
 def DoFB_Player_KillNPC(curPlayer, curNPC, tick):
+    __FBNPCOnKilled(curNPC, tick)
+    return
+
+def __FBNPCOnKilled(curNPC, tick):
     curNPCID = curNPC.GetNPCID()
     gameFB = GameWorld.GetGameFB()
     killNPCCount = gameFB.GetGameFBDictByKey(FBKey_KillNPCCount % curNPCID) + 1
@@ -453,81 +472,90 @@
     fbLineTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_QueenRelics, lineID)
     rewardRateList = FBCommon.GetFBGradeRewardRateList(mapID)
     maxGrade = len(rewardRateList)
-    
+    curPlayer = FBCommon.GetCurSingleFBPlayer()
+    if not curPlayer:
+        return
     nextLineID = 0
     # 最高评级过关,可挑战下一关
     if isPass and grade >= maxGrade:
         nextLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID + 1, False)
         nextLineID = 0 if not nextLineIpyData else (lineID + 1) # 找不到想下一层数据代表通关
-        
+        if nextLineID:
+            helpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, nextLineID)
+            if helpIpyData and curPlayer.GetFightPower() < helpIpyData.GetFightPowerMin():
+                nextLineID = 0 #战力不足,则不可挑战下一关
+                
+            
     
     gameFB = GameWorld.GetGameFB()
     gameFB.SetGameFBDict(FBKey_NextLineID, nextLineID)
     GameWorld.DebugLog("开始过关结算: lineID=%s,grade=%s,isPass=%s,nextLineID=%s" % (lineID, grade, isPass, nextLineID))
     
-    playerManager = GameWorld.GetMapCopyPlayerManager()
-    for index in xrange(playerManager.GetPlayerCount()):
-        curPlayer = playerManager.GetPlayerByIndex(index)
-        if not curPlayer:
-            continue
-        DoFBHelp(curPlayer, tick)
+#    playerManager = GameWorld.GetMapCopyPlayerManager()
+#    for index in xrange(playerManager.GetPlayerCount()):
+#        curPlayer = playerManager.GetPlayerByIndex(index)
+#        if not curPlayer:
+#            continue
+    DoFBHelp(curPlayer, tick)
+    
+    playerID = curPlayer.GetPlayerID()
+    rewardLine = lineID #gameFB.GetPlayerGameFBDictByKey(playerID, FBPKey_RewardLine) 改成只给本层奖励
+    needSyncFBData = False
+    overDict = {}
+    if isPass:
+        curGrade = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [dataMapID])
+        if curGrade < grade:
+            GameWorld.DebugLog("    更新过关评级: dataMapID=%s,lineID=%s,curGrade=%s,rewardGrade=%s" 
+                               % (dataMapID, lineID, curGrade, grade), curPlayer.GetPlayerID())
+            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, grade, False, [dataMapID])
+            needSyncFBData = True
+    
         
-        isHelpFight = FBCommon.GetIsHelpFight(curPlayer)
-        playerID = curPlayer.GetPlayerID()
-        rewardLine = gameFB.GetPlayerGameFBDictByKey(playerID, FBPKey_RewardLine)
-        needSyncFBData = False
-        overDict = {}
-        if isPass:
-            overDict = {FBCommon.Over_costTime:costTime, FBCommon.Over_grade:grade}
-            # 助战只算单次过关
-            if isHelpFight:
-                helpPoint = FBCommon.AddFBHelpPoint(curPlayer, dataMapID)
-                overDict.update({FBCommon.Over_money:FBCommon.GetJsonMoneyList({ShareDefine.TYPE_Price_FBHelpPoint:helpPoint})})
-                
-                curGrade = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, False, [dataMapID])
-                if curGrade < grade:
-                    GameWorld.DebugLog("    助战更新过关评级: dataMapID=%s,lineID=%s,curGrade=%s,grade=%s" % (dataMapID, lineID, curGrade, grade), curPlayer.GetPlayerID())
-                    GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, lineID, grade, False, [dataMapID])
-                    needSyncFBData = True
-                    
-            else:
-                rewardRet = __GivePlayerQueenRelicsReward(curPlayer, dataMapID, rewardLine - 1, lineID, grade, maxGrade, rewardRateList)
-                if rewardRet:
-                    needSyncFBData, startRewardLineID, totalSP, rewardItemList = rewardRet
-                    overDict.update({FBCommon.Over_sp:totalSP, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(rewardItemList), 
-                                     "startRewardLineID":startRewardLineID})
-            if lineID+1 > curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FBHistoryMaxLine % dataMapID):
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FBHistoryMaxLine % dataMapID, lineID+1)
-            #成就
-            if grade >= maxGrade:
-                PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_QueenRelics, 1, [lineID+1])
-            EventShell.EventRespons_PassQueenRelecs(curPlayer, lineID, grade)
-            #任务
-            EventShell.EventRespons_FBEvent(curPlayer, "queenrelics_pass")
-        FBCommon.NotifyFBOver(curPlayer, dataMapID, lineID, isPass, overDict)
+        overDict = {FBCommon.Over_costTime:costTime, FBCommon.Over_grade:grade}
+        if not nextLineID:#没有下一层则给奖励!!
+            rewardRet = __GivePlayerQueenRelicsReward(curPlayer, dataMapID, rewardLine - 1, lineID, grade, maxGrade, rewardRateList)
+            if rewardRet:
+                startRewardLineID, totalSP, rewardItemList = rewardRet
+                overDict.update({FBCommon.Over_sp:totalSP, FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(rewardItemList), 
+                                 "startRewardLineID":startRewardLineID})
+        if lineID+1 > curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FBHistoryMaxLine % dataMapID):
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FBHistoryMaxLine % dataMapID, lineID+1)
+        #成就
+        if grade >= maxGrade:
+            PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_QueenRelics, 1, [lineID+1])
         
-        # 记录结算到的线路层,记录值+1
-        updRewardLine = lineID + 1
-        gameFB.SetPlayerGameFBDict(playerID, FBPKey_RewardLine, updRewardLine)
-        
-        if isPass and not rewardLine and not isHelpFight:
-            isInFBOnDay = gameFB.GetPlayerGameFBDictByKey(playerID, FBPKey_IsInFBOnDay)
-            if not isInFBOnDay:
-                GameWorld.DebugLog("首次结算奖励,增加挑战次数!", playerID)
-                needSyncFBData = True
-                FBCommon.AddEnterFBCount(curPlayer, dataMapID)
-            else:
-                GameWorld.DebugLog("副本中过天,不增加挑战次数!", playerID)
-                
-        # 不可再挑战下一关了
-        if not nextLineID:
-            curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, fbLineTime[Def_LeaveTime] * 1000, True)
+        EventShell.EventRespons_PassQueenRelecs(curPlayer, lineID, grade)
+        #任务
+        EventShell.EventRespons_FBEvent(curPlayer, "queenrelics_pass")
+    
+    # 记录结算到的线路层,记录值+1
+    updRewardLine = lineID + 1
+    gameFB.SetPlayerGameFBDict(playerID, FBPKey_RewardLine, updRewardLine)
+    
+    if isPass and not nextLineID:
+        isInFBOnDay = gameFB.GetPlayerGameFBDictByKey(playerID, FBPKey_IsInFBOnDay)
+        if not isInFBOnDay:
+            GameWorld.DebugLog("首次结算奖励,增加挑战次数!", playerID)
+            needSyncFBData = False
+            FBCommon.AddEnterFBCount(curPlayer, dataMapID)
+            addXianyuanCoin, reason = FBHelpBattle.DoFBAddXianyuanCoin(curPlayer, mapID, lineID)
+            overDict[FBCommon.Over_xianyuanCoin] = [addXianyuanCoin, reason]
         else:
-            curPlayer.Sync_TimeTick(IPY_GameWorld.tttFBAddTime, 0, fbLineTime[Def_LeaveTime] * 1000, True)
-            GameWorld.DebugLog("    可进入下一关: updRewardLine=%s,nextLineID=%s" % (updRewardLine, nextLineID), playerID)
-            
-        if needSyncFBData:
-            FBCommon.Sync_FBPlayerFBInfoData(curPlayer, dataMapID) # 同步信息
+            GameWorld.DebugLog("副本中过天,不增加挑战次数!", playerID)
+        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_QueenRelicsEx, 1)
+        PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_QueenRelices, 1)
+        PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_QueenRelices, 1)
+    # 不可再挑战下一关了
+    if not nextLineID:
+        curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap, 0, fbLineTime[Def_LeaveTime] * 1000, True)
+    else:
+        curPlayer.Sync_TimeTick(IPY_GameWorld.tttFBAddTime, 0, fbLineTime[Def_LeaveTime] * 1000, True)
+        GameWorld.DebugLog("    可进入下一关: updRewardLine=%s,nextLineID=%s" % (updRewardLine, nextLineID), playerID)
+        
+    if needSyncFBData:
+        FBCommon.Sync_FBPlayerFBInfoData(curPlayer, dataMapID) # 同步信息
+        
+    FBCommon.NotifyFBOver(curPlayer, dataMapID, lineID, isPass, overDict)
     return
 
 def __GivePlayerQueenRelicsReward(curPlayer, dataMapID, rewardLineID, curLineID, passGrade, maxGrade, rewardRateList):
@@ -542,18 +570,12 @@
         return
     
     startRewardLineID = rewardLineID + 1
-    needSyncFBData = False
+
     # 统计奖励,本关卡之前的都给最高级奖励, 当前层以本次评级为准
     for giveLineID in xrange(startRewardLineID, curLineID + 1):
         
         rewardGrade = maxGrade if giveLineID < curLineID else passGrade
-        curGrade = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, giveLineID, False, [dataMapID])
-        if curGrade < rewardGrade:
-            GameWorld.DebugLog("    更新过关评级: dataMapID=%s,giveLineID=%s,curGrade=%s,rewardGrade=%s" 
-                               % (dataMapID, giveLineID, curGrade, rewardGrade), curPlayer.GetPlayerID())
-            GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_PlayerFBStar_MapId, giveLineID, rewardGrade, False, [dataMapID])
-            needSyncFBData = True
-            
+                    
         lineReward = FBCommon.GetFBLineReward(dataMapID, giveLineID)
         rewardSP = lineReward[0]
         rewardItemList = lineReward[1:]
@@ -594,10 +616,10 @@
         PlayerControl.SendMailByKey("QueenRelicsMail", [curPlayer.GetPlayerID()], rewardItemList)
     else:
         for itemID, itemCount, isBind in rewardItemList:
-            ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], event=["QueenRelics", False, {}])
+            ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem], event=["QueenRelics", False, {}])
             
     GameWorld.DebugLog("    总奖励:totalSP=%s,rewardItemList=%s" % (totalSP, rewardItemList), curPlayer.GetPlayerID())
-    return needSyncFBData, startRewardLineID, totalSP, rewardItemList
+    return startRewardLineID, totalSP, rewardItemList
 
 
 ## 副本行为
@@ -638,7 +660,17 @@
     if not toLineIpyData:
         GameWorld.ErrLog("没有目标功能线路!toLineID=%s" % toLineID)
         return
+    #判断战力是否满足本层要求
+    helpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, toLineID)
+    if helpIpyData:
+        if curPlayer.GetFightPower() < helpIpyData.GetFightPowerMin():
+            GameWorld.DebugLog("战力不足%s,无法挑战下一层!toLineID=%s" % (helpIpyData.GetFightPowerMin(), toLineID), curPlayer.GetPlayerID())
+            return
     
+    if curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
+        GameWorld.Log("进入下一层时玩家是死亡状态,先复活!", curPlayer.GetPlayerID())
+        ChPlayer.PlayerRebornByType(curPlayer, ChConfig.rebornType_System, tick)
+        
     toPosX, toPosY = __GetQueenRelicsLinePos(mapID, toLineID, toLineIpyData)
     PlayerControl.PlayerResetWorldPosFBLineID(curPlayer, mapID, toPosX, toPosY, toLineID)
     

--
Gitblit v1.8.0