From 35032f3eeedd4c4f40338d9d7aa8cfa93f7266b9 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 14 四月 2020 14:36:16 +0800
Subject: [PATCH] 8405 【后端】成就系统开发(修复领取通行证奖励未同步领取记录bug)

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerAssist.py |  106 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 78 insertions(+), 28 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerAssist.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerAssist.py
index a23b1ff..390f82b 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerAssist.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerAssist.py
@@ -145,6 +145,25 @@
         
     return
 
+def OnPlayerTeamChange(curPlayer):
+    ## 玩家队伍变更
+    
+    if curPlayer.GetTeamID():
+        return
+    playerID = curPlayer.GetPlayerID()
+    
+    assistMgr = PyDataManager.GetPlayerAssistPyManager()
+    if playerID not in assistMgr.playerNoSaveDBAssistDict:
+        return
+    playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]
+    
+    for assistObj in playerAssistList[::-1]:
+        gameMap = GameWorld.GetMap(assistObj.MapID)
+        if gameMap and gameMap.GetMapFBType() == ChConfig.fbtTeam:
+            OnCancelPlayerRequestAssist(assistObj, "LeaveTeam", True)
+            
+    return
+
 def OnInitAssistData(dbData, isSaveDB):
     ## 加载协助数据额外处理
     setattr(dbData, "IsSaveDB", isSaveDB) # 是否保存数据库,离线可协助的需要存库,如挖矿类
@@ -229,7 +248,10 @@
     if not playerMap:
         return
     if playerMap.GetMapFBType() != ChConfig.fbtNull:
-        playerLineID = curPlayer.GetFBID()
+        if mapID == ChConfig.Def_FBMapID_SealDemon:
+            playerLineID = PlayerControl.GetFBFuncLineID(curPlayer)
+        else:
+            playerLineID = curPlayer.GetFBID()
         if playerMapID != mapID or playerLineID != lineID:
             #副本中无法协助
             PlayerControl.NotifyCode(curPlayer, "AssistFBLimit")
@@ -335,13 +357,6 @@
     NetPackCommon.SendFakePack(assistPlayer, assistPack)
     return
 
-def SetPlayerStartAssistTeamFB(curPlayer, queryData):
-    ## 开始协助组队副本 - 玩家进入副本后才真正进入协助状态
-    
-    #mapID, lineID, tagPlayerID = queryData
-    
-    return
-
 def MapServer_PlayerAssistLogic(curPlayer, msgList, tick):
     ## 地图同步的协助信息逻辑处理
     
@@ -403,7 +418,18 @@
     
     # 开始协助组队副本
     elif queryType == "OnStartAssistTeamFB":
-        SetPlayerStartAssistTeamFB(curPlayer, queryData)
+        mapID, lineID, tagPlayerID = queryData
+        GameWorld.DebugLog("    开始协助副本: mapID=%s,lineID=%s,tagPlayerID=%s" % (mapID, lineID, tagPlayerID), playerID)
+        # 副本协助暂时只处理设置协助目标ID
+        PlayerControl.SetAssistTagPlayerID(curPlayer, tagPlayerID)
+        return
+    
+    # 取消协助组队副本
+    elif queryType == "OnCancelAssistTeamFB":
+        mapID, lineID, reason = queryData
+        GameWorld.DebugLog("    开始协助副本: mapID=%s,lineID=%s,reason=%s" % (mapID, lineID, reason), playerID)
+        # 副本协助暂时只处理设置协助目标ID
+        PlayerControl.SetAssistTagPlayerID(curPlayer, 0)
         return
     
     #QueryPlayerResult_PlayerAssist(curPlayer, queryType, queryData, result)
@@ -423,12 +449,12 @@
     familyID = curPlayer.GetFamilyID()
     if not familyID:
         return
-    mapID, lineID, npcID, objID = queryData
+    mapID, lineID, npcID, objID, npcLV = queryData
     
     playerID = curPlayer.GetPlayerID()
     
-    assistObj = None
-    addNewAssist = True
+    reqAssistObj = None
+    addNewAssist = False
     assistMgr = PyDataManager.GetPlayerAssistPyManager()
     if playerID in assistMgr.playerNoSaveDBAssistDict:
         playerAssistList = assistMgr.playerNoSaveDBAssistDict[playerID]
@@ -438,19 +464,28 @@
             if npcID != assistObj.NPCID or lineID != assistObj.LineID or objID != assistObj.ObjID:
                 OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistBoss", True)
             else:
-                addNewAssist = False
+                reqAssistObj = assistObj
             break
         
-    if addNewAssist:
-        assistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID, objID)
+    if not reqAssistObj:
+        addNewAssist = True
+        reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID, objID)
         
-    if not assistObj:
+    if not reqAssistObj:
         return
     
     # 通知本仙盟玩家
-    PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([assistObj]))
+    PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))
     # 求助信息已发送,请等待盟友支援
     PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")
+    
+    # 广播仙盟请求
+    requestCount = 1
+    if not addNewAssist:
+        requestCount = min(curPlayer.GetDictByKey("AssistBossRequestCount") + 1, 999)
+    curPlayer.SetDict("AssistBossRequestCount", requestCount)
+    notifyNum = (requestCount - 1) % 3
+    PlayerControl.FamilyNotify(familyID, "AssistBossRequest%s" % notifyNum, [curPlayer.GetName(), mapID, npcLV, npcID])
     return
 
 def __DoRequestAssistTeamFB(curPlayer, queryData):
@@ -463,7 +498,7 @@
     
     playerID = curPlayer.GetPlayerID()
     
-    assistObj = None
+    reqAssistObj = None
     addNewAssist = False
     assistMgr = PyDataManager.GetPlayerAssistPyManager()
     if playerID in assistMgr.playerNoSaveDBAssistDict:
@@ -473,21 +508,28 @@
                 continue
             if mapID != assistObj.MapID or lineID != assistObj.LineID:
                 OnCancelPlayerRequestAssist(assistObj, "RequestNewAssistTeamFB", True)
-                addNewAssist = True
-                break
-    else:
+            else:
+                reqAssistObj = assistObj
+            break
+        
+    if not reqAssistObj:
         addNewAssist = True
+        reqAssistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID)
         
-    if addNewAssist:
-        assistObj = __AddNewAssist(assistMgr, curPlayer, mapID, lineID)
-        
-    if not assistObj:
+    if not reqAssistObj:
         return
     
     # 通知本仙盟玩家
-    PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([assistObj]))
+    PlayerFamily.SendFamilyFakePack(familyID, GetAssistInfoListPack([reqAssistObj]))
     # 求助信息已发送,请等待盟友支援
     PlayerControl.NotifyCode(curPlayer, "AssistRequestOK")
+    # 广播仙盟请求
+    requestCount = 1
+    if not addNewAssist:
+        requestCount = min(curPlayer.GetDictByKey("AssistFBRequestCount") + 1, 999)
+    curPlayer.SetDict("AssistFBRequestCount", requestCount)
+    notifyNum = (requestCount - 1) % 3
+    PlayerControl.FamilyNotify(familyID, "AssistFBRequest%s" % notifyNum, [curPlayer.GetName(), mapID])
     return
 
 def __AddNewAssist(assistMgr, curPlayer, mapID, lineID, npcID=0, objID=0, exData="", isSaveDB=0):
@@ -536,6 +578,7 @@
     for assistObj in familyAssistList:
         assistInfo = ChPyNetSendPack.tagGCAssistInfo()
         assistInfo.AssistGUID = assistObj.GUID
+        assistInfo.PlayerID = assistObj.PlayerID
         assistInfo.PlayerName = assistObj.PlayerName
         assistInfo.Job = assistObj.Job
         assistInfo.LV = assistObj.LV
@@ -591,8 +634,6 @@
         if assistObj in playerAssistList:
             playerAssistList.remove(assistObj)
             
-    SyncFamilyClearAssist(familyID, assistGUID)
-    
     # 取消boss协助
     if assistType == AssistType_Boss:
         
@@ -613,6 +654,8 @@
         # 暂不需要处理
         pass
     
+    # 放最后    
+    SyncFamilyClearAssist(familyID, assistGUID)
     return
 
 def OnCancelPlayerAssist(cancelPlayer, cancelPlayerID, assistObj, reason, isGameServer, isNotify=True):
@@ -648,7 +691,14 @@
         assistObj.AssistPlayerIDList.remove(cancelPlayerID)
         
     if cancelPlayer:
+        isTagPlayerReason = reason.startswith("RequestPlayerCancel_")
         PlayerControl.SetAssistTagPlayerID(cancelPlayer, 0)
+        overPack = ChPyNetSendPack.tagGCAssistOver()
+        overPack.IsTagPlayerReason = isTagPlayerReason
+        overPack.Reason = reason[len("RequestPlayerCancel_"):] if isTagPlayerReason else reason 
+        overPack.ReasonLen = len(overPack.Reason)
+        overPack.AssistGUID = assistGUID
+        NetPackCommon.SendFakePack(cancelPlayer, overPack)
         
     # 取消boss协助
     if assistObj.AssistType == AssistType_Boss:

--
Gitblit v1.8.0