From 88effa2034b78c46426b2e7f7924a9493da9af4f Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期一, 03 十二月 2018 16:22:15 +0800
Subject: [PATCH] 5161 子 【1.3.100】修复在仙盟任务副本中退出仙盟还能继续任务的BUG

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py |  141 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 101 insertions(+), 40 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
index e766f97..7a14d03 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
@@ -34,6 +34,8 @@
 import IPY_GameWorld
 import PlayerActivity
 
+import time
+
 def DoPlayerOnDay(curPlayer):
     checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
     checkInCount = checkInInfo / 10 # 累计登记
@@ -44,7 +46,19 @@
         SyncCheckInState(curPlayer, 0, False)
     
     # 重置每日已获得仙缘币
-    PlayerControl.SetTodayXianyuanCoin(curPlayer, 0)
+    ondaySetXianyuanCoin = 0
+    ondayLoginSetXianyuanCoin = curPlayer.GetDictByKey(ChConfig.Def_PDict_TodayXianyuanCoinOnLogin)
+    if ondayLoginSetXianyuanCoin:
+        # 这里做时间比较,预防玩家登录后就没有再切换地图,再次在该地图过天会导致设置值错误问题
+        loginAddCoinTime = curPlayer.GetDictByKey(ChConfig.Def_PDict_LoginAddTodayXianyuanCoinTime)
+        if GameWorld.CheckTimeIsSameServerDayEx(loginAddCoinTime):
+            ondaySetXianyuanCoin = ondayLoginSetXianyuanCoin
+            GameWorld.DebugLog("玩家过天时,登录增加仙缘币有值,仍然是同一天,仙缘币重置为登录时增加的仙缘币!ondayLoginSetXianyuanCoin=%s" % ondayLoginSetXianyuanCoin)
+        else:
+            GameWorld.DebugLog("玩家过天时,登录增加仙缘币有值,但是不是同一天了,仙缘币重置为0!")
+    PlayerControl.SetTodayXianyuanCoin(curPlayer, ondaySetXianyuanCoin)
+    GameWorld.DebugLog("玩家过天设置今日已获得仙缘币: ondaySetXianyuanCoin=%s,ondayLoginSetXianyuanCoin=%s" 
+                       % (ondaySetXianyuanCoin, ondayLoginSetXianyuanCoin))
     return
 
 def DoPlayerLogin(curPlayer):
@@ -382,7 +396,7 @@
 
 def __OnHelpBattleRecord(curPlayer, msgList, tick):
     ## 助战记录同步
-    cmd, helpRecordList = msgList
+    cmd, helpRecordList, isLogin = msgList
     playerID = curPlayer.GetPlayerID()
     GameWorld.DebugLog("__OnHelpBattleRecord %s,helpRecordList=%s" % (cmd, helpRecordList), playerID)
     
@@ -420,12 +434,16 @@
     NetPackCommon.SendFakePack(curPlayer, recordPack)
     
     addDataDict = {"HelpList":drList}
-    GameWorld.DebugLog("    addXianyuanCoinTotal=%s,addXianyuanCoinTotalTotay=%s,totalHelpCount=%s" 
-                       % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay, totalHelpCount), playerID)
+    GameWorld.DebugLog("    addXianyuanCoinTotal=%s,addXianyuanCoinTotalTotay=%s,totalHelpCount=%s,isLogin=%s" 
+                       % (addXianyuanCoinTotal, addXianyuanCoinTotalTotay, totalHelpCount, isLogin), playerID)
     PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, addXianyuanCoinTotal, addDataDict=addDataDict, isSysHint=False)
     if addXianyuanCoinTotalTotay:
         PlayerControl.AddTodayXianyuanCoin(curPlayer, addXianyuanCoinTotalTotay)
-    
+        if isLogin:
+            curPlayer.SetDict(ChConfig.Def_PDict_TodayXianyuanCoinOnLogin, addXianyuanCoinTotalTotay)
+            curPlayer.SetDict(ChConfig.Def_PDict_LoginAddTodayXianyuanCoinTime, int(time.time()))
+            GameWorld.Log("    登录时今日助战信息: addXianyuanCoinTotalTotay=%s" % (addXianyuanCoinTotalTotay), playerID)
+            
     # 更新总助战次数,更新排行榜
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleTotalCount, totalHelpCount)
     if totalHelpCount >= IpyGameDataPY.GetFuncCfg("HelpBattleRefresh", 4):
@@ -474,20 +492,25 @@
     #                       % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
     #    return
     
-    relationAdd, relationPlayerID, relationPlayerName = 0, 0, ""
+    relation, relationAdd, relationPlayerID, relationPlayerName = 0, 0, 0, ""
     
     fbType = GameWorld.GetMap().GetMapFBType()
     if fbType == IPY_GameWorld.fbtSingle:
+        gameFB = GameWorld.GetGameFB()
         helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
-        for helpPlayerInfoDict in helpBattlePlayerDict.values():
+        for helpPlayerID, helpPlayerInfoDict in helpBattlePlayerDict.items():
+            objID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_HelpBattleFBObjID % helpPlayerID)
+            if not objID:
+                continue
             relation = helpPlayerInfoDict.get("Relation", 0)
             if not relation:
                 continue
             relationAddList = relationCoinAddDict.get(str(relation), [])
             relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
     elif fbType == IPY_GameWorld.fbtTeam:
-        relationAdd, relationPlayerID, relationPlayerName = __GetTeamFBMemRelationInfo(curPlayer, relationCoinAddDict, isHelp)
-        
+        if playerID in PyGameData.g_teamFBMemRelationAddDict:
+            relation, relationAdd, relationPlayerID, relationPlayerName = PyGameData.g_teamFBMemRelationAddDict.pop(playerID)
+            
     coinAdd = 0
     if baseFBPoint:
         coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.0)
@@ -507,62 +530,100 @@
     msgPack = ChPyNetSendPack.tagMCAddXianyuanCoinMsg()
     msgPack.MapID = mapID
     msgPack.FuncLineID = lineID
+    msgPack.Relation = relation
+    msgPack.RelationCoinAdd = relationAdd
     msgPack.XianyuanCoinAdd = coinAddReal
+    msgPack.Reason = reason
     msgPack.CallPlayerID = relationPlayerID
     msgPack.CallPlayerName = relationPlayerName
     msgPack.NameLen = len(msgPack.CallPlayerName)
-    msgPack.Reason = reason
     NetPackCommon.SendFakePack(curPlayer, msgPack)
     return coinAddReal, reason
 
-def __GetTeamFBMemRelationInfo(curPlayer, relationCoinAddDict, isHelp):
+def __GetTeamFBMemRelationInfo(curPlayer, isHelp, leavePlayerID):
+    ## 计算队员间相互加成信息,离线玩家不算
+    relation = 0
     relationAdd = 0 # 社交关系加成
     relationPlayerID = 0
     relationPlayerName = ""
     teamID = curPlayer.GetTeamID()
     if teamID not in PyGameData.g_teamFBMemRelationDict:
-        return relationAdd, relationPlayerID, relationPlayerName
+        return relation, relationAdd, relationPlayerID, relationPlayerName
     
+    playerManager = GameWorld.GetMapCopyPlayerManager()
     friendList, memFamilyIDDict, memNameDict = PyGameData.g_teamFBMemRelationDict[teamID]
     relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # 社交关系优先级
+    relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...} 
     playerID = curPlayer.GetPlayerID()
     familyID = curPlayer.GetFamilyID()
     if isHelp:
         # 助战的随便取一位优先级最高的即可
-        for checkRelation in relationList:
-            memRelation, relationPlayerID = 0, 0
-            if checkRelation == 1:
-                for memPlayerID in memFamilyIDDict.keys():
-                    if [playerID, memPlayerID] in friendList:
-                        memRelation = checkRelation
-                        relationPlayerID = memPlayerID
-                        break
-            if checkRelation == 2:
-                for memPlayerID, memFamilyID in memFamilyIDDict.items():
-                    if playerID != memPlayerID and familyID and familyID == memFamilyID:
-                        memRelation = checkRelation
-                        relationPlayerID = memPlayerID
-                        break
-            if memRelation and relationPlayerID:
-                relationAddList = relationCoinAddDict.get(str(memRelation), [])
-                relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
-                relationPlayerName = memNameDict[relationPlayerID]
-                return relationAdd, relationPlayerID, relationPlayerName
+        for memPlayerID, memFamilyID in memFamilyIDDict.items():
+            memRelation, relationPlayerID = __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID)
+            if not memRelation:
+                continue
+            relation = memRelation
+            relationAddList = relationCoinAddDict.get(str(memRelation), [])
+            relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
+            relationPlayerName = memNameDict[relationPlayerID]
+            return relation, relationAdd, relationPlayerID, relationPlayerName
+        
     else:
         # 非助战享受所有队员加成
         for memPlayerID, memFamilyID in memFamilyIDDict.items():
-            memRelation = 0
-            for checkRelation in relationList:
-                if [playerID, memPlayerID] in friendList:
-                    memRelation = checkRelation
-                    break
-                if playerID != memPlayerID and familyID and familyID == memFamilyID:
-                    memRelation = checkRelation
-                    break
+            memRelation = __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID)[0]
             if not memRelation:
                 continue
+            if memRelation == relationList[0]:
+                relation = memRelation
+            elif relation:
+                relation = memRelation
             relationAddList = relationCoinAddDict.get(str(memRelation), [])
             relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
             
-    return relationAdd, relationPlayerID, relationPlayerName
+    return relation, relationAdd, relationPlayerID, relationPlayerName
+
+def __GetTemMemRelation(playerManager, playerID, familyID, memPlayerID, memFamilyID, relationList, friendList, leavePlayerID):
+    ## 离线玩家不算社交关系
+    if leavePlayerID and memPlayerID == leavePlayerID:
+        return 0, 0
+    memPlayer = playerManager.FindPlayerByID(memPlayerID)
+    if memPlayer == None or memPlayer.IsEmpty():
+        return 0, 0
+    for checkRelation in relationList:
+        if checkRelation == 1:
+            if [playerID, memPlayerID] in friendList:
+                return checkRelation, memPlayerID
+        if checkRelation == 2:
+            if playerID != memPlayerID and familyID and familyID == memFamilyID:
+                return checkRelation, memPlayerID            
+    return 0, 0
+
+def RefershTeamFBMemRelation(tick, leavePlayerID=0):
+    ## 刷新组队副本队员关系
+    playerManager = GameWorld.GetMapCopyPlayerManager()
+    for i in xrange(playerManager.GetPlayerCount()):
+        player = playerManager.GetPlayerByIndex(i)
+        if player == None or player.IsEmpty():
+            continue
+        if leavePlayerID and player.GetPlayerID() == leavePlayerID:
+            PyGameData.g_teamFBMemRelationAddDict.pop(leavePlayerID, 0)
+            continue
+        relation, relationAdd, relationPlayerID, relationPlayerName = __GetTeamFBMemRelationInfo(player, FBCommon.GetIsHelpFight(player), leavePlayerID)
+        PyGameData.g_teamFBMemRelationAddDict[player.GetPlayerID()] = [relation, relationAdd, relationPlayerID, relationPlayerName]
+        
+    for index in xrange(playerManager.GetPlayerCount()):
+        player = playerManager.GetPlayerByIndex(index)
+        if player == None or player.IsEmpty():
+            continue
+        if leavePlayerID and player.GetPlayerID() == leavePlayerID:
+            continue
+        FBLogic.DoFBHelp(player, tick)
+        
+    return
+
+def GetTeamFBMemRelationInfo(playerID):
+    if playerID not in PyGameData.g_teamFBMemRelationAddDict:
+        return 0, 0
+    return PyGameData.g_teamFBMemRelationAddDict[playerID][:2]
 

--
Gitblit v1.8.0