From c67a2d59e881e3d1df1a4142983e76e8fb5db24a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 28 十二月 2018 21:26:28 +0800
Subject: [PATCH] 5424 【后端】【1.4】跨服竞技场开发(匹配规则优化,优先匹配同段位的,同段位不足两个人的支持按段位区间匹配)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py |  569 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 348 insertions(+), 221 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index bf03785..f09873c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -64,13 +64,12 @@
 import PlayerGameEvent
 import EventReport
 import PlayerTeHui
-import GameLogic_XMZZ
+import PlayerGatherSoul
 import PlayerSuccess
 import PlayerPet
 import PlayerGreatMaster
 import ItemControler
 import GameFuncComm
-import PlayerMergeEvent
 import IpyGameDataPY
 import PlayerRune
 import GameLogic_DuJie
@@ -83,9 +82,14 @@
 import PlayerFamilyTech
 import PlayerCostRebate
 import PlayerFairyCeremony
+import PlayerCrossRealmPK
+import FunctionNPCCommon
+import CrossRealmPlayer
 import ChNetSendPack
 import PlayerState
 import QuestCommon
+import PlayerDogz
+import ChPlayer
 import GMShell
 
 import random
@@ -159,7 +163,7 @@
 # notifyCnt 代表广播周围玩家的数量,0为全部广播 -1为指定列表随机, 其他数字为指定指
 def PyNotifyAll(curPlayer, sendPack, notifySelf=True, notifyCnt=0):
     if notifyCnt == -1:
-        notifyCnt = random.choice((10, 10, 15, 15, 20, 25, 30, 50))
+        notifyCnt = 8
     #GameWorld.DebugLog("PyNotifyAll %s"%notifyCnt)
 
     curPlayer.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength(), notifySelf, notifyCnt)
@@ -227,7 +231,7 @@
 #  @return 无返回值
 def WorldNotify(country, msgMark, msgParamList=[], lineID=0, mergeMinOSD=-1, mergeMaxOSD=-1, mergeMapInfo=[]):
     # 如果是跨服服务器,则广播子服
-    if GameWorld.IsMergeServer():
+    if GameWorld.IsCrossServer():
         sendMsg = str([country, msgMark, msgParamList, lineID, mergeMinOSD, mergeMaxOSD, mergeMapInfo])
         GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'MergeWorldNotify',
                                                                   sendMsg, len(sendMsg))
@@ -307,34 +311,38 @@
     return
 
 #---------------------------------------------------------------------
-def SendMailBatch(mailTypeKey, batchPlayerIDList, batchAddItemList=[], batchParamList=[], batchGold=[], batchGoldPaper=[], batchSilver=[]):
+def SendMailBatch(mailTypeKey, batchPlayerIDList, batchAddItemList=[], batchParamList=[], batchGold=[], batchGoldPaper=[], batchSilver=[], batchDetail=[]):
     '''批量发送邮件, 用于瞬间需要发送多封(大量)邮件的,比如一些公共副本活动等结算时
     @param mailTypeKey: 邮件模板key
     @param batchPlayerIDList: [playerIDList, playerIDList, ...]
     @param batchAddItemList: [addItemList, addItemList, ...]
     @param batchParamList: [paramList, paramList, ...]
     @param batchGold: [batchGold, batchGold, ...]
-    @param batchGold: [batchGoldPaper, batchGoldPaper, ...]
-    @param batchGold: [batchSilver, batchSilver, ...]
+    @param batchGoldPaper: [batchGoldPaper, batchGoldPaper, ...]
+    @param batchSilver: [batchSilver, batchSilver, ...]
+    @param batchDetail: [记录邮件流向用, ...]
     '''
-    msgInfo = str([mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver])
+    msgInfo = str([mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver, batchDetail])
     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMailBatch", msgInfo, len(msgInfo))
     GameWorld.Log("SendMailBatch %s, batchPlayerIDList=%s, batchAddItemList=%s, batchParamList=%s, batchGold=%s, batchGoldPaper=%s, batchSilver=%s" 
                   % (mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList, batchGold, batchGoldPaper, batchSilver))
     return
 
-def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0):
+def SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList=[], gold=0, goldPaper=0, silver=0, detail=""):
+    '''
+    @param detail: 记录邮件流向用
+    '''
     if not mailTypeKey:
         mailTypeKey = ShareDefine.DefaultLackSpaceMailType
     
     content = "<MailTemplate>%s</MailTemplate>%s" % (mailTypeKey, json.dumps(paramList, ensure_ascii=False))
-    SendMail("", content, 30, playerIDList, addItemList, gold, goldPaper, silver)
+    SendMail("", content, 30, playerIDList, addItemList, gold, goldPaper, silver, detail)
     return
 
 ## 功能发放物品补偿/奖励邮件
 #  @param addItemList [(itemID, itemCnt, isBind), {或物品信息字典}, ...]
 #  @return
-def SendMail(title, content, getDays, playerIDList, addItemList, gold=0, goldPaper=0, silver=0):
+def SendMail(title, content, getDays, playerIDList, addItemList, gold=0, goldPaper=0, silver=0, detail=""):
     if not playerIDList:
         return
     
@@ -346,7 +354,7 @@
         return
     
     # 跨服服务器不允许发送邮件
-    if GameWorld.IsMergeServer():
+    if GameWorld.IsCrossServer():
         return
     
     itemCountDict = {}
@@ -376,7 +384,7 @@
     for key, itemCnt in itemCountDict.items():
         itemID, isBind = key
         combineItemList.append((itemID, itemCnt, isBind))
-    cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver]
+    cmdList = [title, content, getDays, playerIDList, combineItemList, gold, goldPaper, silver, detail]
     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "SendMail", '%s' % (cmdList), len(str(cmdList)))
     return True
 
@@ -1310,15 +1318,17 @@
 
 def GetPlayerLeaveServerTick(playerID):
     # 获取玩家从本地图中离线时的tick, 最大支持1小时, 如果有需要大于1小时的请调整超时限制
-    # 注: 返回值为None时,只能代表玩家不是在本地图离线1小时内,并不能代表玩家当前是否在线状态,可能在其他地图
+    # 注: 返回值为0时,只能代表玩家不是在本地图离线1小时内,并不能代表玩家当前是否在线状态,可能在其他地图
     if playerID not in PyGameData.g_disconnectPlayer:
-        return
+        return 0
     return PyGameData.g_disconnectPlayer[playerID][0]
 
 def GetPlayerLeaveServerPos(playerID):
     # 获取玩家从本地图中离线时的坐标
+    # 注:使用本函数时,一定要先使用函数 GetPlayerLeaveServerTick 确保是从本地图中离线的才可使用
+    # @return: posX, posY
     if playerID not in PyGameData.g_disconnectPlayer:
-        return
+        return 0, 0
     return PyGameData.g_disconnectPlayer[playerID][1:3]
 
 def RemoveTimeoutLeaveServerPlayerInfo(tick):
@@ -1417,7 +1427,8 @@
     
     FBLogic.DoPlayerChangeMapLogic(curPlayer, tick)
     #summonList = list()
-    
+    #召回宠物
+    PetControl.ReCallFightPet(curPlayer)
     #1. 删除自己不需要的召唤兽(火焰之灵等)
     #必须用while, 因为在循环中要删除
     # 召唤兽切地图不带过去
@@ -1445,6 +1456,24 @@
 #        summonIndex += 1
         
     
+    # 更新最后一次离开的非中立常规地图, 从中立地图退出时需要回到该地方,必须在 DoResetWorldPosAndClear 之前更新
+    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtNull and curPlayer.GetMapID() not in IpyGameDataPY.GetFuncEvalCfg("MapLine", 4):
+        mapID = curPlayer.GetMapID()
+        posX = curPlayer.GetPosX()
+        posY = curPlayer.GetPosY()
+        lineID = curPlayer.GetClientLineID()
+        NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromMapID, mapID)
+        NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromPosX, posX)
+        NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromPosY, posY)
+        NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromLineID, lineID)
+        GameWorld.DebugLog("最后一次离开的非中立常规地图更新!mapID=%s,lineID=%s,Pos(%s,%s)" % (mapID, lineID, posX, posY))
+    else:
+        mapID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromMapID)
+        posX = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromPosX)
+        posY = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromPosY)
+        lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromLineID)
+        GameWorld.DebugLog("最后一次离开的非中立常规地图不变!mapID=%s,lineID=%s,Pos(%s,%s)" % (mapID, lineID, posX, posY))
+        
     #2. 调用切换地图接口
     curPlayer.DoResetWorldPosAndClear()
     
@@ -1472,11 +1501,37 @@
         GameServerRefresh.Set_PlayerRouteServerInitOK_OnLeaveFB(curPlayer, 1)
         return
     
+    GameWorld.Log("PlayerLeaveFB...", curPlayer.GetPlayerID())
+    if GameWorld.IsCrossServer():
+        CrossRealmPlayer.PlayerExitCrossServer(curPlayer)
+        return
+
+    #中立地图回到上一次非中立常规地图    
+    if curPlayer.GetMapID() in IpyGameDataPY.GetFuncEvalCfg("MapLine", 4):
+        mapID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromMapID)
+        posX = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromPosX)
+        posY = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromPosY)
+        lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FromLineID)
+        # 老号支持,本来就在中立地图的,返回新手村
+        if not mapID:
+            # {职业:[dataMapID,posX,posY], ...}
+            createRoleMapDict = IpyGameDataPY.GetFuncEvalCfg("CreateRoleMap", 1, {})
+            if not createRoleMapDict:
+                return
+            job = curPlayer.GetJob()
+            lineID = 0
+            if job in createRoleMapDict:
+                mapID, posX, posY = createRoleMapDict[job]
+            else:
+                mapInfoList = createRoleMapDict.values()
+                mapID, posX, posY = mapInfoList[0]
     #离开副本
-    mapID = curPlayer.GetFromMapID()
-    posX = curPlayer.GetFromPosX()
-    posY = curPlayer.GetFromPosY()
-    
+    else:
+        mapID = curPlayer.GetFromMapID()
+        posX = curPlayer.GetFromPosX()
+        posY = curPlayer.GetFromPosY()
+        lineID = curPlayer.GetFromLineID()
+        
     if mapID == curPlayer.GetMapID():
         # 如果在同一张地图, 取DB重生点, 普通地图下线重上时FromMapID会被设置为本地图
         gameMap = GameWorld.GetMap()
@@ -1486,7 +1541,7 @@
     #copyMapID = curPlayer.GetCopyMapID()
     GameWorld.Log("PlayerLeaveFB MapID = %d, PosX = %d, PosY = %d" % (mapID, posX, posY), curPlayer.GetPlayerID())
     
-    if GameWorld.GetMap().GetAutoSize() and GameWorld.GetGameWorld().GetMapCopyPlayerManager().GetPlayerCount() == 1:
+    if GameWorldProcess.IsNoPlayerNeedCloseFB() and GameWorld.GetGameWorld().GetMapCopyPlayerManager().GetPlayerCount() == 1:
         #如果副本中只有这一个人, 那么把这个副本设置为玩家安全下线, 关闭副本
         gameFB = GameWorld.GetGameFB()
         gameFB.SetIsSafeClose(1)
@@ -1499,7 +1554,7 @@
     #    ChangePlayerAction(curPlayer, IPY_GameWorld.paNull)
     #===============================================================================================
     
-    PlayerResetWorldPosFB(curPlayer, mapID, posX, posY, False, curPlayer.GetFromLineID())
+    PlayerResetWorldPosFB(curPlayer, mapID, posX, posY, False, lineID)
     
     #在空闲或者移动状态下,才能锁死玩家
     if curPlayer.GetPlayerAction() in [IPY_GameWorld.paNull] or curPlayer.IsMoving():
@@ -1509,72 +1564,6 @@
     return
 
 #---------------------------------------------------------------------
-
-def ResetMergeFBPlayerCntInfo(resetMapID):
-    # 重置跨服活动副本地图人数分配情况信息
-    mapID = GameWorld.GetMap().GetMapID()
-    if mapID != ChConfig.Def_MergeTransMapID:
-        return
-    GameWorld.Log("重置跨服活动副本地图人数分配情况信息: resetMapID=%s" % resetMapID)
-    gameWorld = GameWorld.GetGameWorld()
-    mergeFBPlayerCntDict = ReadChConfig.GetEvalChConfig("MergeFBPlayerCount")
-    for reqMapID, mapInfo in mergeFBPlayerCntDict.items():
-        if resetMapID and resetMapID != reqMapID:
-            continue
-        for playerMapID in mapInfo[1]:
-            playerCnt = gameWorld.GetGameWorldDictByKey(ChConfig.Map_WorldKey_MergeFBMapPlayerCnt % playerMapID)
-            for num in xrange(1, 1 + playerCnt):
-                playerID = gameWorld.GetGameWorldDictByKey(ChConfig.Map_WorldKey_MergeFBMapPlayerID % (playerMapID, num))
-                gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBMapPlayerID % (playerMapID, num), 0) # 重置对应的玩家ID
-                gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBPlayerMapID % (reqMapID, playerID), 0) # 重置玩家ID对应的地图
-            gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBMapPlayerCnt % playerMapID, 0) # 重置地图人数
-    return
-
-def __GetMergeFBPlayerMapID(curPlayer, reqMapID):
-    # 获取玩家所分配的跨服活动地图ID
-    # @param reqMapID: 可以是本服活动的地图ID标识; 也可以是指定的跨服活动地图ID, 如果是指定的地图ID也是直接返回
-    
-    mergeFBPlayerCntDict = ReadChConfig.GetEvalChConfig("MergeFBPlayerCount")
-    if reqMapID not in mergeFBPlayerCntDict:
-        return reqMapID
-    
-    playerID = curPlayer.GetPlayerID()
-    gameWorld = GameWorld.GetGameWorld()
-    
-    playerMapID = gameWorld.GetGameWorldDictByKey(ChConfig.Map_WorldKey_MergeFBPlayerMapID % (reqMapID, playerID))
-    if playerMapID:
-        GameWorld.DebugLog("已经有分配跨服活动地图,直接返回!playerMapID=%s" % (playerMapID), playerID)
-        return playerMapID
-    
-    # 还没分配该玩家, 则开始选择分配的地图ID
-    maxPlayerCnt, mapIDList = mergeFBPlayerCntDict[reqMapID]
-    minPlayerCount = 0 # 最少的地图玩家人数
-    minPlayerMapID = 0 # 最少人数的地图ID
-    for mID in mapIDList:
-        curMapPlayerCnt = gameWorld.GetGameWorldDictByKey(ChConfig.Map_WorldKey_MergeFBMapPlayerCnt % mID)
-        if curMapPlayerCnt < maxPlayerCnt:
-            playerMapID = mID
-            break
-        
-        # 保存最少人数的地图ID信息
-        if not minPlayerCount or (minPlayerCount and curMapPlayerCnt < minPlayerCount):
-            minPlayerCount = curMapPlayerCnt
-            minPlayerMapID = mID
-    
-    # 如果没有人数未满的活动地图,则分配到人数较少的地图
-    if not playerMapID:
-        playerMapID = minPlayerMapID
-        
-    # 更新分配信息
-    if playerMapID:
-        mapPlayerCnt = gameWorld.GetGameWorldDictByKey(ChConfig.Map_WorldKey_MergeFBMapPlayerCnt % playerMapID) + 1
-        gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBMapPlayerCnt % playerMapID, mapPlayerCnt)
-        gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBMapPlayerID % (playerMapID, mapPlayerCnt), playerID)
-        gameWorld.SetGameWorldDict(ChConfig.Map_WorldKey_MergeFBPlayerMapID % (reqMapID, playerID), playerMapID)
-        GameWorld.Log("分配跨服活动玩家所属地图: plaeyrID=%s,reqMapID=%s,分配MapID=%s,mapPlayerCnt=%s" 
-                      % (playerID, reqMapID, playerMapID, mapPlayerCnt))
-        
-    return playerMapID
 
 ##玩家进入副本
 # @param curPlayer 玩家实例
@@ -1594,13 +1583,13 @@
     #        NotifyCode(curPlayer, 'jiazu_xyj_671654')
     #        return
         
-    #跨服活动人数分流处理
-    if GameWorld.IsMergeServer():
-        reqMapID = mapID
-        mapID = __GetMergeFBPlayerMapID(curPlayer, reqMapID)
-        if not mapID:
-            GameWorld.ErrLog("找不到可分配进入的跨服活动地图ID! reqMapID=%s" % reqMapID)
-            return
+#    #跨服活动人数分流处理
+#    if GameWorld.IsCrossServer():
+#        reqMapID = mapID
+#        mapID = __GetMergeFBPlayerMapID(curPlayer, reqMapID)
+#        if not mapID:
+#            GameWorld.ErrLog("找不到可分配进入的跨服活动地图ID! reqMapID=%s" % reqMapID)
+#            return
       
     #过滤封包地图ID
     if not GameWorld.GetMap().IsMapIDExist(mapID):
@@ -1725,6 +1714,12 @@
         if isNotify:
             NotifyCode(curPlayer, "SingleEnterPK", [mapID])
         return ShareDefine.EntFBAskRet_PKState
+    
+    ## 跨服PK匹配中
+    if PlayerCrossRealmPK.GetIsCrossPKMatching(curPlayer):
+        if isNotify:
+            NotifyCode(curPlayer, "CrossMatching8", [mapID])            
+        return ShareDefine.EntFBAskRet_CrossPKMatching
     
     #===============================================================================================
     # # 这里不做状态限制,由前端处理,因为策划要根据界面来处理,同一传送功能有可能在不同界面
@@ -2008,7 +2003,7 @@
 # @param canLock 是否可以锁定玩家(传送点不可锁定, 因为要跨地图寻路)
 # @return 返回值无意义
 # @remarks 玩家切换地图
-def PlayerResetWorldPos(curPlayer, mapID, posX, posY, takeTruck, lineID= -1, msg='', canLock=True, exData1=0):
+def PlayerResetWorldPos(curPlayer, mapID, posX, posY, takeTruck, lineID=-1, msg='', canLock=True, exData1=0):
     #更改: 死亡允许切换地图, 在副本中被怪打死, 副本时间到, 回收副本
 #    if curPlayer.GetHP() <= 0 :
 #        GameWorld.Log("死亡无法切换地图")
@@ -2021,8 +2016,12 @@
     #---同地图ID, 同分线, 仅切换坐标---
     #lingID = -1, 代表默认当前线, 如主城2传送剑宗, 到达剑宗2
     if gameWorld.GetMapID() == mapID and (shuntLineID == -1 or gameWorld.GetLineID() == shuntLineID):
-        #重置坐标
-        GameWorld.ResetPlayerPos(curPlayer, posX, posY)
+        if exData1:
+            #boss的用move,通知前端,由前端发起move
+            ChPlayer.NotifyPlayerMove(curPlayer, posX, posY, exData1)
+        else:
+            #重置坐标
+            GameWorld.ResetPlayerPos(curPlayer, posX, posY)
         #@bug: 在摆摊区快速传送至非摆摊区, 可以摆摊, 这里刷新一下场景Buff
         SkillShell.ProcessMapBuff(curPlayer, GameWorld.GetGameWorld().GetTick())
         return
@@ -2058,7 +2057,7 @@
     # 非常规地图之间的切换不处理
     if curMapID not in PyGameData.g_commMapLinePlayerCountDict or tagMapID not in PyGameData.g_commMapLinePlayerCountDict:
         return tagLineID
-    tagLinePlayerCountDict = PyGameData.g_commMapLinePlayerCountDict[tagMapID]
+    tagLinePlayerCountDict = PyGameData.g_commMapLinePlayerCountDict[tagMapID] # 此分线包含所有分线,含未开放的及活动分线
     
     playerID = curPlayer.GetPlayerID()
     playChangeLineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_PlayChangeLineID)
@@ -2075,12 +2074,16 @@
             GameWorld.DebugLog("功能指定切换目标线路,记录当前线路后续切线备用! curLineID=%s,tagLineID=%s" % (curLineID, tagLineID), playerID)
             
         if bossID and NPCCommon.IsMapNeedBossShunt(tagMapID):
-            bossShuntLineID = __GetBossShuntLineID(curPlayer, tagMapID, bossID, tagLinePlayerCountDict.keys())
+            bossShuntLineID = __GetBossShuntLineID(curPlayer, curMapID, curLineID, tagMapID, bossID, tagLinePlayerCountDict.keys())
             if bossShuntLineID != -1:
                 tick = GameWorld.GetGameWorld().GetTick()
                 GameWorld.DebugLog("分流boss, bossID=%s,bossShuntLineID=%s" % (bossID, bossShuntLineID), playerID)
                 NPCCommon.AddBossShuntRelatedPlayer(curPlayer, tagMapID, bossShuntLineID, bossID, tick)
                 return bossShuntLineID
+        return tagLineID
+    
+    if curMapID == tagMapID:
+        GameWorld.DebugLog("同地图切换坐标不处理分流!", playerID)
         return tagLineID
     
     # 可以用来常规分流的线路人数字典信息, 并不是所有线路都可以用来做人数分流的,比如中立地图有多条线用来分流boss,但是只有1条线可用来做常规的人数分流
@@ -2160,10 +2163,23 @@
     GameWorld.DebugLog("分流到人数较少的线路,tagMapID=%s,linePlayerList[count,lineID]=%s" % (tagMapID, linePlayerList), playerID)
     return shuntLineID
 
-def __GetBossShuntLineID(curPlayer, mapID, npcID, lineIDList):
+def __GetBossShuntLineID(curPlayer, curMapID, curLineID, tagMapID, npcID, lineIDList):
     '''获取目标地图boss分流线路
-    根据人数分流玩家,boss死亡状态,只能分流到已死亡线路
-    队伍无视任何规则,默认分配到队伍队员多的那条线
+                根据人数分流玩家,优先分配到活着的线路
+                队伍无视任何规则,默认分配到队伍队员多的那条线
+                
+                前端:
+        1.在中立地图的时候,显示当前线路BOSS的状态
+        2.在常规地图的时候,显示玩家击杀BOSS的CD时间
+        3.本地图不换线,60秒规则保持不变
+        4.进入BOSS区域里,刷新BOSS状态
+        
+                玩家在非中立地图:
+                本地图不换线,60秒规则保持不变()
+                
+                玩家在中立地图
+                没有60秒规则
+                直接发传送包,由后端决定(有队员在不同线路打同一只boss,则传送,否则move)
     '''
     playerID = curPlayer.GetPlayerID()
     playerTeamID = curPlayer.GetTeamID()
@@ -2171,65 +2187,75 @@
     hurtTeamLineID = -1
     hurtTeamMemCount = -1
     
-    emptyLineID = -1
-    bossLinePlayerCntList = []
+    bossLinePlayerDict = {1:[-1, []], 0:[-1, []]} # {是否被击杀:[该状态人数空的线路, [[玩家数, 线路], ...]], ...}
     
-    deadLineList = PyGameData.g_bossShuntDeadLine.get(npcID, [])
-    bossState = not deadLineList # boss公共状态, 只要有一条线路是死亡的就是死亡
+    bossLineStateDict = PyGameData.g_bossShuntLineState.get(npcID, {})
     
-    GameWorld.DebugLog("玩家boss分流: playerTeamID=%s,mapID=%s,npcID=%s,lineIDList=%s,bossState=%s,deadLineList=%s,g_bossShuntPlayerInfo=%s" 
-                       % (playerTeamID, mapID, npcID, lineIDList, bossState, deadLineList, PyGameData.g_bossShuntPlayerInfo), playerID)
+    haveAliveLine = False # 是否有活着的线路
+    activityMapLineDict = IpyGameDataPY.GetFuncEvalCfg("MapLine", 2, {})
     
+    GameWorld.DebugLog("玩家boss分流: playerTeamID=%s,tagMapID=%s,npcID=%s,lineIDList=%s,bossLineStateDict=%s,g_bossShuntPlayerInfo=%s" 
+                       % (playerTeamID, tagMapID, npcID, lineIDList, bossLineStateDict, PyGameData.g_bossShuntPlayerInfo), playerID)
+    if tagMapID in activityMapLineDict:
+        activityLineID = max(0, activityMapLineDict[tagMapID] - 1)
+        # 非1线的活动线路不参与分流
+        if activityLineID != 0 and activityLineID in lineIDList:
+            lineIDList.remove(activityLineID)
+            GameWorld.DebugLog("    非1线的活动线路不参与分流: activityLineID=%s,lineIDList=%s" % (activityLineID, lineIDList), playerID)
+            
     for lineID in lineIDList:
-        key = (mapID, lineID)
+        key = (tagMapID, lineID)
+        # boss分流玩家信息{(mapID, lineID):{playerID:[bossID, teamID, relatedTick], ...}, ...}
         shuntPlayerDict = PyGameData.g_bossShuntPlayerInfo.get(key, {})
         playerCount = 0
         teamPlayerCount = 0
-        for shuntInfo in shuntPlayerDict.values():
+        for shuntPlayerID, shuntInfo in shuntPlayerDict.items():
             bossID = shuntInfo[0]
             if npcID != bossID:
                 continue
             playerCount += 1
             shuntTeamID = shuntInfo[1]
-            if playerTeamID and playerTeamID == shuntTeamID:
+            if playerTeamID and playerTeamID == shuntTeamID and shuntPlayerID != playerID:
                 teamPlayerCount += 1
         
         if teamPlayerCount and teamPlayerCount > hurtTeamMemCount:
             hurtTeamMemCount = teamPlayerCount
             hurtTeamLineID = lineID
             
-        lineBossState = lineID not in deadLineList # 当前线路boss状态
-        if bossState != lineBossState:
-            GameWorld.DebugLog("    lineID=%s,lineBossState=%s != bossState=%s,teamPlayerCount=%s,hurtTeamMemCount=%s,hurtTeamLineID=%s" 
-                           % (lineID, lineBossState, bossState, teamPlayerCount, hurtTeamMemCount, hurtTeamLineID), playerID)
-            continue
+        lineIsAlive = bossLineStateDict.get(lineID, 0)
+        lineBossIsDead = 1 if not lineIsAlive else 0 # 当前线路boss是否死亡
+        emptyLineID, linePlayerCountList = bossLinePlayerDict[lineBossIsDead]
+        if not playerCount and emptyLineID == -1:
+            emptyLineID = lineID
+        linePlayerCountList.append([playerCount, lineID])
+        bossLinePlayerDict[lineBossIsDead] = [emptyLineID, linePlayerCountList]
         
-        GameWorld.DebugLog("    lineID=%s,lineBossState=%s,playerCount=%s,teamPlayerCount=%s,hurtTeamMemCount=%s,hurtTeamLineID=%s" 
-                           % (lineID, lineBossState, playerCount, teamPlayerCount, hurtTeamMemCount, hurtTeamLineID), playerID)
-        
-        if not playerCount:
-            if emptyLineID < 0:
-                emptyLineID = lineID
-        else:
-            bossLinePlayerCntList.append([playerCount, lineID])
+        if not lineBossIsDead:
+            haveAliveLine = True
             
+        GameWorld.DebugLog("    lineID=%s,lineBossIsDead=%s,playerCount=%s,teamPlayerCount=%s,hurtTeamMemCount=%s,hurtTeamLineID=%s" 
+                           % (lineID, lineBossIsDead, playerCount, teamPlayerCount, hurtTeamMemCount, hurtTeamLineID), playerID)
+        
     if hurtTeamLineID >= 0:
         GameWorld.DebugLog("    分流到队友人数多的线路 hurtTeamLineID=%s" % hurtTeamLineID, playerID)
         return hurtTeamLineID
     
-    if not bossLinePlayerCntList:
-        GameWorld.DebugLog("    没有人在该boss状态下的线路,默认空新线路!bossState=%s,emptyLineID=%s" % (bossState, emptyLineID), playerID)
-        return emptyLineID
+    if curMapID == tagMapID and curMapID in IpyGameDataPY.GetFuncEvalCfg("MapLine", 4):
+        GameWorld.DebugLog("    中立地图在本地图中默认当前线路 curLineID=%s" % curLineID, playerID)
+        return curLineID
     
-    bossLinePlayerCntList.sort() # 升序
-    playerCount, minPlayerCntLineID = bossLinePlayerCntList[0]
+    shuntBossIsDead = 0 if haveAliveLine else 1 # 优先分流到活着的线路
+    GameWorld.DebugLog("    boss状态对应线路人数: haveAliveLine=%s, 状态key0为活着: %s" % (haveAliveLine, bossLinePlayerDict))
+    emptyLineID, linePlayerCountList = bossLinePlayerDict[shuntBossIsDead]
+    linePlayerCountList.sort() # 升序
+    playerCount, minPlayerCntLineID = linePlayerCountList[0]
     bossShuntPlayerCountMax = IpyGameDataPY.GetFuncCfg("BossShunt", 2)
     if playerCount >= bossShuntPlayerCountMax and emptyLineID >= 0:
-        GameWorld.DebugLog("    分流到空新线路 bossState=%s,emptyLineID=%s" % (bossState, emptyLineID), playerID)
+        GameWorld.DebugLog("    分流到空新线路 shuntBossIsDead=%s,emptyLineID=%s" % (shuntBossIsDead, emptyLineID), playerID)
         return emptyLineID
     
-    GameWorld.DebugLog("    分流到人数最少的线路 bossState=%s,minPlayerCntLineID=%s,bossLinePlayerCntList=%s" 
-                       % (bossState, minPlayerCntLineID, bossLinePlayerCntList), playerID)
+    GameWorld.DebugLog("    分流到人数最少的线路 shuntBossIsDead=%s,minPlayerCntLineID=%s,linePlayerCountList=%s" 
+                       % (shuntBossIsDead, minPlayerCntLineID, linePlayerCountList), playerID)
     return minPlayerCntLineID
 
 #---------------------------------------------------------------------
@@ -2722,8 +2748,8 @@
         
         curBourseMoney = GetMoney(curPlayer, ShareDefine.TYPE_Price_BourseMoney)
         updBourseMoney = curBourseMoney
-        #当是交易所扣费时,则必定扣除交易额度
-        if costType == ChConfig.Def_Cost_BourseBuy:
+        #当是交易所扣费、钻石红包时,则必定扣除交易额度
+        if costType in ChConfig.UnUseInner_CostType:
             updBourseMoney = max(0, curBourseMoney - price)
         #其他如果当前金子比交易额度还少,则强制调整交易额度为当前金子数(这种情况一般是非交易所消费的,需要同步扣除交易所可购买额度)
         elif updPlayerGold < updBourseMoney:
@@ -2766,12 +2792,7 @@
         SetPlayerCurrency(curPlayer, type_Price, curCurrency - price)
     else:
         GameWorld.Log("付费金钱异常 type_Price = %s" % (type_Price), curPlayer.GetPlayerID())
-        return False   
-    
-    #添加跨服操作事件
-    if costType in ChConfig.MergeServerCanCostType:
-        eventInfo = [type_Price, price, costType, infoDict, quantity, costVIPGold]
-        PlayerMergeEvent.AddMSPlayerEvent(curPlayer.GetPlayerID(), PlayerMergeEvent.Def_MSPEvent_PayMoney, eventInfo)
+        return False
     
     #付款以后后续操作
     __PayMoneyAfter(curPlayer, type_Price, price, costType, infoDict, quantity, costVIPGold)
@@ -3281,18 +3302,33 @@
 # @remarks 获得玩家升级, 获得的属性点
 def GetLvUp_AddPoint(curPlayer):
     curPlayerID = curPlayer.GetID()
-    curReinCnt = curPlayer.GetReincarnationLv() # 当前转生次数
+    curLV = curPlayer.GetLV() # 当前等级
     
-    addPointList = IpyGameDataPY.GetFuncEvalCfg("LVUPAddPoint", 1)
-    
-    addPoint = addPointList[-1] if curReinCnt >= len(addPointList) else addPointList[curReinCnt]
+    addPointDict = IpyGameDataPY.GetFuncEvalCfg("LVUPAddPoint", 1, {})
+    addPoint = GameWorld.GetDictValueByRangeKey(addPointDict, curLV, 0)
     
     if addPoint == None:
-        raise Exception('玩家获得升级属性点异常, reincarnationLv = %s PlayerID = %s' % (curReinCnt, curPlayerID))
+        raise Exception('玩家获得升级属性点异常, curLV = %s PlayerID = %s' % (curLV, curPlayerID))
         return
     
     return int(addPoint)
 
+def DoAddPointOpen(curPlayer):
+    '''加点功能开启 处理给自由属性点及老号处理  
+                    清除老服玩家未加点的点数(清零),以前加的加点属性不清除,属性不变,战力不减, 根据最新的加点开启等级和老服玩家的当前等级,相差的差值给予玩家对应的加点点数'''
+    beforeFreePoint = curPlayer.GetFreePoint()
+    addPointDict = IpyGameDataPY.GetFuncEvalCfg("LVUPAddPoint", 1, {})
+    initFreePoint = IpyGameDataPY.GetFuncCfg("LVUPAddPoint", 2)
+    openLV = GameFuncComm.GetFuncLimitLV(ShareDefine.GameFuncID_AddPoint)
+    setFreePoint = initFreePoint
+    curLV = curPlayer.GetLV()
+    for lv in xrange(openLV, curLV+1):
+        setFreePoint += GameWorld.GetDictValueByRangeKey(addPointDict, lv, 0)
+    addDataDict = {'beforeFreePoint':beforeFreePoint}
+    DataRecordPack.DR_Freepoint(curPlayer, "AddPointOpen", setFreePoint, addDataDict)
+    curPlayer.SetFreePoint(setFreePoint)
+    GameWorld.DebugLog('    加点功能开启处理  beforeFreePoint=%s,curLV=%s, setFreePoint=%s'%(beforeFreePoint, curLV, setFreePoint), curPlayer.GetID())
+    return
 #---------------------------------------------------------------------
 
 ## 功能模块战斗力类
@@ -3301,6 +3337,8 @@
 class ModuleFightPower():
     
     __AttrName = "%s" # 参数为ChConfig.Def_Calc_AllAttrType_MAX对应所有属性列表索引
+    __AttrNameNoline = "Noline_%s" # 参数为ChConfig.Def_Calc_AllAttrType_MAX对应所有属性列表索引
+    __NolineAttrList = [ChConfig.TYPE_Calc_AttrSpeed] # 需要记录的非线性战斗属性
     
     ## 初始化
     #  @param self 类实例
@@ -3320,6 +3358,8 @@
 #            if attrIndex == ChConfig.TYPE_Calc_SuperHit:
 #                value = ChConfig.Def_SuperHitPercent # 默认最低暴击倍值
             setattr(self, self.__AttrName % attrIndex, value)
+        for attrIndex in self.__NolineAttrList:
+            setattr(self, self.__AttrNameNoline % attrIndex, 0)            
         return
             
     ## 根据战斗属性列表设置计算战斗力属性
@@ -3330,6 +3370,12 @@
         # 设置本模块增加的线性战斗属性,非线性战斗属性增加的在刷属性时累加上去
         for attrIndex, value in battleAttrDict.items():
             self.AddCalcMFPAttr(attrIndex, value)
+            
+        # 非线性战斗属性仅设置时记录即可
+        battleNolineAttrDict = allAttrList[ChConfig.CalcAttr_BattleNoline]
+        for attrIndex, value in battleNolineAttrDict.items():
+            if attrIndex in self.__NolineAttrList:
+                setattr(self, self.__AttrNameNoline % attrIndex, value)
         return
     
     ## 设置计算战斗力属性值
@@ -3371,6 +3417,7 @@
         HPRestore = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_HPRestorePer) # 自动回复血量,固定值
         DamBackPer = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_DamBackPer) * fpParam.GetCftDamBackPer() # 反伤百分比
         SpeedValue = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_AttrSpeed) # 移动速度值
+        SpeedPer = getattr(self, self.__AttrNameNoline % ChConfig.TYPE_Calc_AttrSpeed) * fpParam.GetCftSpeedPer() # 移动速度百分比系数
         PetMinAtk = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_PetMinAtk) # 宠物最小攻击
         PetMaxAtk = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_PetMaxAtk) # 宠物最大攻击
         PetDamPer = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_PetDamPer) # 宠物伤害百分比提升
@@ -3389,16 +3436,18 @@
         DamagePerPVPReduce = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_DamagePerPVPReduce) * fpParam.GetCftDamagePerPVPReduce() # 伤害输出计算百分比PVP减少
         ComboRate = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_ComboRate) # 连击几率
         ComboDamPer = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_ComboDamPer) # 连击伤害
-        MaxProDef = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_MaxProDef) # 最大防护值
-        ProDefAbsorb = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_ProDefAbsorb) # 防护值吸收伤害比率
+        #MaxProDef = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_MaxProDef) # 最大防护值
+        #ProDefAbsorb = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_ProDefAbsorb) # 防护值吸收伤害比率
+        ProDefPer = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_ProDefHPPer) # 防护转化百分比
         
         OnlyFinalHurt = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_OnlyFinalHurt) # 额外输出伤害
         PVPAtkBackHP = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_PVPAtkBackHP) # PVP攻击回血
+        NPCHurtAddPer = getattr(self, self.__AttrName % ChConfig.TYPE_Calc_NPCHurtAddPer) # 对怪物伤害加成
         
         #其他需作为公式参数的系数
         AtkSpeedParameter = fpParam.GetCftAtkSpeed()
         LuckyHitParameter = fpParam.GetCftLuckyHit()
-        
+            
         #获取策划配置的表格
         FightpowerFormula = IpyGameDataPY.GetFuncCfg("FightpowerFormula")
         totalFightPower = eval(FormulaControl.GetCompileFormula("FightpowerFormula", FightpowerFormula))
@@ -3413,6 +3462,14 @@
         attrStr = ""
         for attrIndex in xrange(1, ChConfig.Def_Calc_AllAttrType_MAX):
             attrName = self.__AttrName % attrIndex
+            attrValue = getattr(self, attrName)
+            if attrValue <= 0:
+                continue
+            
+            attrStr += "%s=%s," % (attrName, attrValue)
+            
+        for attrIndex in self.__NolineAttrList:
+            attrName = self.__AttrNameNoline % attrIndex
             attrValue = getattr(self, attrName)
             if attrValue <= 0:
                 continue
@@ -3536,10 +3593,6 @@
         #副本获得经验, 无论获得多少经验均需通知, 有些副本逻辑需要通过获得经验时机处理
         if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:
             FBLogic.OnGetExp(curPlayer, finalAddExp, expViewType)
-        
-        # 跨服中获得经验
-        if finalAddExp and GameWorld.IsMergeServer():
-            PlayerMergeEvent.AddMSPlayerEvent(curPlayer.GetPlayerID(), PlayerMergeEvent.Def_MSPEvent_AddExp, finalAddExp)
             
         return finalAddExp
     
@@ -3702,7 +3755,7 @@
         #未达到升级经验
         if curTotalExp < lvUpNeedExp:
             return
-        
+        needSyncTalentPoint = False
         playerNeedDoLVUp = False
         curLV = curPlayer.GetLV()
         maxLV = IpyGameDataPY.GetFuncCfg("PlayerMaxLV", 1)
@@ -3736,6 +3789,7 @@
                        
             # 记录玩家升级
             DataRecordPack.DR_PlayerUpgrade(curPlayer, curPlayer.GetLV(), GetPlayerTotalExp(curPlayer), lvUpNeedExp)
+            DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_LVUP, {'lv':curLV})
             
             self.__DoLVUPAddPoint()  # 升级加点
             #self.__DoLvUpAddSkill()  # 升级加技能
@@ -3743,7 +3797,10 @@
             lvIpyData = GetPlayerLVIpyData(curPlayer.GetLV())
             # 大师天赋点
             if lvIpyData:
-                PlayerGreatMaster.AddGreatMasterSkillPointByLV(curPlayer, lvIpyData.GetTalentPoint())
+                addTalentPoint = lvIpyData.GetTalentPoint()
+                if addTalentPoint:
+                    needSyncTalentPoint = True
+                    PlayerGreatMaster.AddGreatMasterSkillPointByLV(curPlayer, addTalentPoint)
             
             EventShell.EventResponse_LVUp(curPlayer)  # 升级触发事件
             
@@ -3792,10 +3849,16 @@
             #    NotifyCode(curPlayer, "GeRen_liubo_127574")
             
             #===================================================================
-            
+            # 天赋点通知
+            if needSyncTalentPoint:
+                PlayerGreatMaster.Sync_GreatMasterFreeSkillPoint(curPlayer)
             # 升级需要执行的游戏功能处理
             GameFuncComm.DoFuncOpenLogic(curPlayer)
             ChEquip.CalcEquips_OutOfPrint(curPlayer)    # 缓存绝版属性
+            if aftLV%10 == 0:
+                # 控制下刷新次数
+                PlayerPet.CalcPetItemAddPlayerAttr(curPlayer)   # 宠物有随等级变化的技能
+            
             self.RefreshPlayerAttrState(billboardFunc=PlayerBillboard.UpdatePlayerLVBillboard)
             #放在功能开启后面
             PlayerWorldAverageLv.UpdatePlayerWorldAverageLv(curPlayer)
@@ -3803,10 +3866,12 @@
             curPlayer.SetHP(curPlayer.GetMaxHP())
             if curPlayer.GetMaxMP() > 0:
                 curPlayer.SetMP(curPlayer.GetMaxMP())
-                
+            
+            FBLogic.OnPlayerLVUp(curPlayer)
             # 记录开服活动冲级数据
             OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_LV, curPlayer.GetLV())
-            
+            #神秘限购
+            FunctionNPCCommon.MysticalShopOpen(curPlayer, befLV, aftLV)
         #不需要做升级任务, 设置玩家经验
         SetPlayerTotalExp(curPlayer, curTotalExp) 
         return
@@ -3960,6 +4025,8 @@
         PlayerRefineStove.CalcStoveAttr(curPlayer)
         PlayerFamilyTech.CalcFamilyTechAttr(curPlayer)
         PlayerEquipDecompose.RefreshEDAttr(curPlayer)
+        PlayerDogz.RefreshDogzAttr(curPlayer)
+        PlayerGatherSoul.RefreshGatherSoulAttr(curPlayer)
         self.RefreshAllState(isForce=True)
         GameWorld.DebugLog("End ReCalcAllState!!!")
         return
@@ -4083,6 +4150,7 @@
         #beforeAtkInterval = curPlayer.GetAtkInterval()
         beforeMaxHP = curPlayer.GetMaxHP()
         beforeMoveSpeedValue = GetSpeedValue(curPlayer)
+        beforeMaxProDef = GetMaxProDef(curPlayer)
         #构建玩家刷新通知客户端字典, 缓存[索引, 数值]
         playerStateDict = {}
         for index in xrange(1, ChConfig.Def_Calc_AllAttrType_MAX):
@@ -4277,6 +4345,9 @@
         CalcLineEffect.ChangePlayerAttrInLineEffectList(curPlayer, skillNoFightPowerAttrList[ChConfig.CalcAttr_Battle])
         #self.PrintAttr(curPlayer, "固定层级")
         
+        #护盾值刷新
+        self.__RefreshMaxProDef(beforeMaxProDef)
+        
         # 【到此所有功能属性都已刷新处理完毕,复制一份 功能属性的刷新结果,用于BUFF属性单独刷新】
         EffGetSet.CopyPlayerFuncAttr(curPlayer)
         
@@ -4304,6 +4375,33 @@
         GameWorld.DebugLog("End RefreshPlayerAttrStateEx!!!")
         return True
     
+    
+    # 生命转化为防护值
+    def __RefreshMaxProDef(self, beforeMaxProDef):
+        curPlayer = self.__Player
+        if GetProDefHPPer(curPlayer) == 0:
+            return
+        maxHP = curPlayer.GetMaxHP()
+        proDefPer = GetProDefHPPer(curPlayer)
+        
+        #获取策划配置的表格
+        GodWeapon4 = IpyGameDataPY.GetFuncCfg("GodWeapon4", 2)
+        maxProDef = eval(FormulaControl.GetCompileFormula("GodWeapon4", GodWeapon4))
+        
+        SetMaxProDef(curPlayer, int(maxProDef))
+        
+        afterMaxProDef = GetMaxProDef(curPlayer)
+        addValue = max(0, afterMaxProDef - beforeMaxProDef)
+        curProDef = GetProDef(curPlayer)
+        
+        if beforeMaxProDef > 0 and addValue > 0 and curPlayer.GetPlayerAction() != IPY_GameWorld.paDie:
+            # 同步增加 (死亡状态下不刷)
+            SetProDef(curPlayer, min(curProDef + addValue, afterMaxProDef))
+        elif curProDef > afterMaxProDef:
+            # 做一次防范纠正
+            SetProDef(curPlayer, min(curProDef, afterMaxProDef))
+            
+        return
     
     def __RefreshBuffAttr(self):
         ## 刷新buff层属性,该层属性只会改变玩家最终属性,不会影响战力等
@@ -4581,14 +4679,16 @@
         mfpInfo.MFPCnt = len(mfpDataList)
         mfpInfo.MFPList = mfpDataList
         NetPackCommon.SendFakePack(curPlayer, mfpInfo)
-        
+        beforeFightPower = curPlayer.GetFightPower()
         curPlayer.SetFightPower(totalFightPower, False)
+        if totalFightPower < beforeFightPower:
+            DataRecordPack.DR_FightPowerChangeInfo(curPlayer, beforeFightPower)
         highestFightPower = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FightPower_Highest, 0,
                                                            ChConfig.Def_PDictType_FightPower)
         if totalFightPower > highestFightPower:
             NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FightPower_Highest, totalFightPower,
                                  ChConfig.Def_PDictType_FightPower)
-        GameWorld.DebugLog("总战力: %s, 历史最高战力: %s" % (totalFightPower, highestFightPower))
+        GameWorld.DebugLog("总战力: %s, 历史最高战力: %s, beforeFightPower=%s" % (totalFightPower, highestFightPower, beforeFightPower))
         PlayerBillboard.UpdatePlayerFPTotalBillboard(curPlayer)
         # 记录开服活动数据
         OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_FightPower, totalFightPower)
@@ -4624,6 +4724,7 @@
                 speed = int(speed * (ShareDefine.Def_MaxRateValue + buffSpeedPer) / float(ShareDefine.Def_MaxRateValue) + buffSpeed)
                 GameWorld.DebugLog("    buff影响后速度值: speed=%s,buffSpeedPer=%s,buffSpeed=%s" % (speed, buffSpeedPer, buffSpeed))
                 
+            speed = max(speed, 0)   #防小于0错误
         if GetSpeedValue(curPlayer) != speed:
             SetSpeedValue(curPlayer, speed)
             moveSpeed = eval(FormulaControl.GetCompileFormula("MoveSpeed", moveSpeedFormat))
@@ -4750,7 +4851,7 @@
                         }
         
         for i in xrange(1, ChConfig.Def_Calc_AllAttrType_MAX):
-            if i in [ChConfig.TYPE_Calc_AttrHP, ChConfig.TYPE_Calc_AttrMP]:
+            if i in [ChConfig.TYPE_Calc_AttrHP, ChConfig.TYPE_Calc_AttrMP, ChConfig.TYPE_Calc_ProDef]:
                 continue
             value = 0 if i not in initAttrDict else initAttrDict[i]
             EffGetSet.SetValueByEffIndex(curPlayer, i, value)
@@ -4977,6 +5078,7 @@
     index = 0
     buffSkillIDList = []
     
+    passiveEff = PassiveBuffEffMng.GetPassiveEffManager().GetPassiveEff(curPlayer)
     while index < buffState.GetBuffCount():
         curBuff = buffState.GetBuff(index)
         #异常
@@ -4991,10 +5093,16 @@
             continue
         
         #BuffSkill.DoBuffDisApper(curPlayer, curBuff, tick)
-        buffSkillIDList.append([curBuff.GetSkill().GetSkillID(), curBuff.GetOwnerID(), curBuff.GetOwnerType()])
+        #buffSkillIDList.append([curBuff.GetSkill().GetSkillID(), curBuff.GetOwnerID(), curBuff.GetOwnerType()])
+        buffSkillIDList.append(curBuff.GetSkill().GetSkillID())
+        #GameWorld.DebugLog("死亡清理-----%s"%curBuff.GetSkill().GetSkillID())
+        if passiveEff:
+            passiveEff.DelBuffInfo(curBuff.GetSkill())
+            
         #删除这个buff
         buffState.DeleteBuffByIndex(index)
-    
+        
+        
     SkillShell.ClearBuffEffectBySkillIDList(curPlayer, buffState, buffSkillIDList)
     return
 
@@ -5392,10 +5500,11 @@
     fightExpRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_FightExpRate) # VIP加成
     
     actExpRateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ExpRate, {})# 多倍经验活动加成
-    if not PlayerTJG.GetIsTJG(curPlayer) and actExpRateInfo.get(ShareDefine.ActKey_State) \
-        and curPlayer.GetLV() >= actExpRateInfo.get(ShareDefine.ActKey_LVLimit, 0):
-        fightExpRate += actExpRateInfo.get(ShareDefine.ActKey_AddExpRate, 0)
-    
+    if not PlayerTJG.GetIsTJG(curPlayer) and actExpRateInfo.get(ShareDefine.ActKey_State):
+        actExpIpyData = IpyGameDataPY.GetIpyGameData("ActExpRate", actExpRateInfo.get(ShareDefine.ActKey_CfgID))
+        if actExpIpyData and curPlayer.GetLV() >= actExpIpyData.GetLVLimit():
+            fightExpRate += actExpIpyData.GetAddExpRate()
+            
     if curPlayer.GetMapID() not in [ChConfig.Def_FBMapID_FamilyInvade]: #守卫人皇不加组队加成
         fightExpRate += curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TeamExpRate) # 组队
     
@@ -5500,6 +5609,9 @@
 # SetExAttr1 ~ SetExAttr14(DWORD uiExAttr10, bool bNotifyAll = false, bool bNotifyGameServer = false)
 # @param bNotifyAll: 是否广播所周围玩家,默认false,只会发给自己
 # @param bNotifyGameServer: 是否同步GameServer,默认false
+# SetExAttr15 ~ SetExAttr20(DWORD uiExAttr15) 
+#     15~20扩展属性同步封包:0309 选角登录简短信息、0434 周围玩家出现、0102 登录地图玩家信息;
+#     同步前端及GameServer需要自己写通知,设置函数自身不带通知参数
 #
 # 发送0418包
 # SendPropertyRefresh(int inputType, int inputValue, bool boardCast, bool includeSelf = true)
@@ -5508,10 +5620,13 @@
 # 通知GsmeServer; 
 # SendGameServerRefreshState(int inputType, int inputValue)
 
+# SetExAttr15 ~ 18 对应神兵类型等级,场景特效用
+
 # 禁言 通知gameServer
 def SetGMForbidenTalk(curPlayer, value):
     curPlayer.SetGMForbidenTalk(value)
     curPlayer.SendGameServerRefreshState(ShareDefine.CDBPlayerRefresh_ForbidenTalk, value)
+    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ForbidenTalk, value, False)
     return
 
 
@@ -5530,6 +5645,10 @@
 def SetFBFuncLineID(curPlayer, funcLineID): return curPlayer.SetExAttr3(funcLineID, False, False)
 def GetFBFuncLineID(curPlayer): return curPlayer.GetExAttr3()
 
+## 跨服状态: 0-非跨服状态,1-跨服状态
+def GetCrossRealmState(curPlayer): return curPlayer.GetExAttr5()
+def SetCrossRealmState(curPlayer, value): curPlayer.SetExAttr5(value, False, True)
+
 ## 铜钱点, 支持铜钱超20亿
 def GetSilver(curPlayer): return curPlayer.GetExAttr6() * ChConfig.Def_PerPointValue + curPlayer.GetSilver()
 def SetSilver(curPlayer, totalSilver):
@@ -5541,9 +5660,33 @@
         curPlayer.SetExAttr6(silverPoint)
     return
 
+## 玩家今日已获得仙缘币
+def GetTodayXianyuanCoin(curPlayer): return curPlayer.GetExAttr11()
+def SetTodayXianyuanCoin(curPlayer, value): return curPlayer.SetExAttr11(value, False, True)
+def AddTodayXianyuanCoin(curPlayer, addValue): return curPlayer.SetExAttr11(curPlayer.GetExAttr11() + addValue, False, True)
+
 ##VIP到期时间, 需要同步GameServer
 def GetVIPExpireTime(curPlayer): return curPlayer.GetExAttr9()
 def SetVIPExpireTime(curPlayer, expireTime): return curPlayer.SetExAttr9(expireTime, False, True)
+
+##聊天气泡框
+def GetChatBubbleBox(curPlayer): return curPlayer.GetExAttr10()
+def SetChatBubbleBox(curPlayer, value): return curPlayer.SetExAttr10(value, False, True)
+
+## 玩家所属服务器组ID
+def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()
+def UpdPlayerServerGroupID(curPlayer):
+    # 更新自己的服务器组ID, 跨服服务器不处理
+    if GameWorld.IsCrossServer():
+        return
+    serverGroupID = GameWorld.GetServerGroupID()
+    if not serverGroupID:
+        return
+    playerServerGroupID = curPlayer.GetExAttr13()
+    if playerServerGroupID != serverGroupID:
+        curPlayer.SetExAttr13(serverGroupID, False, True)
+        GameWorld.DebugLog("更新玩家所属服务器组ID: serverGroupID=%s" % serverGroupID)
+    return
 
 ##获得玩家威望值
 def GetPrestige(curPlayer): return 0
@@ -5640,10 +5783,6 @@
     
     SetZhenQi(curPlayer, value)
     #EventReport.WriteEvent_add_zhenqi(curPlayer, eventName, eventData, addValue, value)
-
-    if GameWorld.IsMergeServer():
-        eventInfo = [addValue, eventName, eventData]
-        PlayerMergeEvent.AddMSPlayerEvent(curPlayer.GetPlayerID(), PlayerMergeEvent.Def_MSPEvent_AddZhenQi, eventInfo)
     return True
 
 
@@ -5735,37 +5874,6 @@
 def SetLongMaiLV(curPlayer, value):
     return
 #---------------------------------------------------------------------------
-## 设置玩家跨服预赛排位
-#  @param curPlayer: 玩家实例
-#  @param value: 威望值
-#  @return: 
-def SetMergeWarRank(curPlayer, value):
-    curPlayer.SetExAttr10(value, True, True)
-    return
-
-    
-## 获取玩家跨服预赛排位
-#  @param curPlayer: 玩家实例
-#  @return: 威望值
-def GetMergeWarRank(curPlayer):
-    return curPlayer.GetExAttr10()
-
-
-## 设置玩家官爵星级
-#  @param curPlayer: 玩家实例
-#  @param value: 星级
-#  @return: 
-def SetOfficeStar(curPlayer, value):
-    curPlayer.SetExAttr11(value)
-    return
-
-    
-## 获取玩家玩家官爵星级
-#  @param curPlayer: 玩家实例
-#  @return: 星级
-def GetOfficeStar(curPlayer):
-    return curPlayer.GetExAttr11()
-
 
 ##获取可免费开启的格子数
 # @param curPlayer 玩家对象
@@ -6053,7 +6161,10 @@
 
 ## 对怪物伤害加成
 def GetNPCHurtAddPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_NPCHurtAddPer)
-def SetNPCHurtAddPer(curPlayer, value): curPlayer.SetDict(ChConfig.Def_PlayerKey_NPCHurtAddPer, value)
+def SetNPCHurtAddPer(curPlayer, value):
+    curPlayer.SetDict(ChConfig.Def_PlayerKey_NPCHurtAddPer, value)
+    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_NPCHurtAddPer, value, False)
+    
 #---职业伤害加成---
 ## 目标战士伤害加成
 def GetJobAHurtAddPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_JobAHurtAddPer)
@@ -6114,9 +6225,6 @@
     curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_IgnoreDefRateReduce, value, False)
     
 #---特殊伤害概率---
-## 富甲一击概率
-def GetFujiaHitRate(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FujiaHitRate)
-def SetFujiaHitRate(curPlayer, value): curPlayer.SetDict(ChConfig.Def_PlayerKey_FujiaHitRate, value)
 ## 富豪一击概率
 def GetFuhaoHitRate(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FuhaoHitRate)
 def SetFuhaoHitRate(curPlayer, value): curPlayer.SetDict(ChConfig.Def_PlayerKey_FuhaoHitRate, value)
@@ -6127,6 +6235,11 @@
     curPlayer.SetDict(ChConfig.Def_PlayerKey_BleedDamage, value)
     curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_BleedDamage, value, False)
     
+## 最终伤害百分比
+def GetFinalHurtPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FinalHurtPer)
+def SetFinalHurtPer(curPlayer, value):
+    curPlayer.SetDict(ChConfig.Def_PlayerKey_FinalHurtPer, value)
+    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_FinalHurtPer, value, False)
 ## 最终固定伤害增加
 def GetFinalHurt(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FinalHurt)
 def SetFinalHurt(curPlayer, value):
@@ -6351,17 +6464,17 @@
 def GetMaxProDef(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrMaxProDef)
 def SetMaxProDef(curPlayer, value):
     curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrMaxProDef, value)
-    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_MaxProDef, value, True) # 周围玩家需要通知
+    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_MaxProDef, value, False) # 周围玩家需要通知
 #---生命上限换算为防护值的百分比----
 def GetProDefHPPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrProDefHPPer)
 def SetProDefHPPer(curPlayer, value):
     curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrProDefHPPer, value)
-    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ProDefHPPer, value, False)
+    #curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ProDefHPPer, value, False)
 #---防护值吸收伤害比率----
 def GetProDefAbsorb(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrProDefAbsorb)
 def SetProDefAbsorb(curPlayer, value):
     curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrProDefAbsorb, value)
-    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ProDefAbsorb, value, False)
+    #curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ProDefAbsorb, value, False)
     
 #---宠物攻击提升值----
 def GetPetMinAtk(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrPetMinAtk)
@@ -6369,11 +6482,13 @@
 def GetPetMaxAtk(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrPetMaxAtk)
 def SetPetMaxAtk(curPlayer, value): curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrPetMaxAtk, value)
 
-#---宠物伤害百分比提升----
-def GetPetDamPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrPetDamPer)
-def SetPetDamPer(curPlayer, value): 
-    curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrPetDamPer, value)
-    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_PetDamPer, value, False)
+#---宠物伤害百分比提升----移到GameObj下
+#===============================================================================
+# def GetPetDamPer(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_AttrPetDamPer)
+# def SetPetDamPer(curPlayer, value): 
+#    curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrPetDamPer, value)
+#    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_PetDamPer, value, False)
+#===============================================================================
 #---宠物技能伤害百分比提升----
 def GetPetSkillAtkRate(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_PetSkillAtkRate)
 def SetPetSkillAtkRate(curPlayer, value): curPlayer.SetDict(ChConfig.Def_PlayerKey_PetSkillAtkRate, value)
@@ -6512,12 +6627,24 @@
 def GetCalcAttrListValue(curPlayer, funcIndex):
     ## 获取功能点预先计算的所加属性值
     attrList = [{} for _ in range(4)]
-    for attrIndex, attrDict in enumerate(attrList):
-        for i in xrange(Def_MaxAddAttrTypeCnt):
-            attrType = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CalcAddAttrType % (funcIndex, attrIndex, i))
-            if attrType == 0:
-                break
-            attrDict[attrType] = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CalcAddAttrValue % (funcIndex, attrIndex, i))
+    if isinstance(funcIndex, int):
+        funcIndexList = [funcIndex]
+    elif isinstance(funcIndex, list):
+        funcIndexList = funcIndex
+    else:
+        return attrList
+    
+    for funcIndex in funcIndexList:
+        for attrIndex, attrDict in enumerate(attrList):
+            for i in xrange(Def_MaxAddAttrTypeCnt):
+                attrType = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CalcAddAttrType % (funcIndex, attrIndex, i))
+                if attrType == 0:
+                    break
+                attrValue = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CalcAddAttrValue % (funcIndex, attrIndex, i))
+                if attrType in attrDict:
+                    attrDict[attrType] = attrValue + attrDict[attrType]
+                else:
+                    attrDict[attrType] = attrValue                   
     return attrList
 
 ## 刷属性时累加功能事先计算好的属性值

--
Gitblit v1.8.0