From 37a0a0bba170701ee91b15c668b97b5b47a53289 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 26 十一月 2018 21:21:02 +0800
Subject: [PATCH] 4762 【后端】组队助战类型副本助战修改(混乱妖域);宗门、渡劫、娲皇、混乱妖域结算增加同步获得仙缘币信息;增加每日助战登记修行点; 召唤成功增加同步职业信息;

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py |  135 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 109 insertions(+), 26 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 61b4e32..6a2a3ec 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
@@ -31,6 +31,8 @@
 import NPCCommon
 import FBLogic
 import PlayerVip
+import IPY_GameWorld
+import PlayerActivity
 
 def DoPlayerOnDay(curPlayer):
     checkInInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HelpBattleCheckInCount)
@@ -40,6 +42,9 @@
         checkInInfo = (checkInCount + 1) * 10 + 0
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
         SyncCheckInState(curPlayer, 0, False)
+    
+    # 重置每日已获得仙缘币
+    PlayerControl.SetTodayXianyuanCoin(curPlayer, 0)
     return
 
 def DoPlayerLogin(curPlayer):
@@ -103,6 +108,7 @@
     if isOK:
         checkInInfo = (checkInCount + 1) * 10 + 1
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HelpBattleCheckInCount, checkInInfo)
+        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_HelpBattleCheckIn)
         
         # 没有数据缓存的话,马上同步一次
         if not haveViewCache:
@@ -227,6 +233,7 @@
         callResultPack = ChPyNetSendPack.tagMCHelpBattleCallResult()
         callResultPack.ObjID = objID
         callResultPack.PlayerID = calledPlayerID
+        callResultPack.Job = job
         NetPackCommon.SendFakePack(curPlayer, callResultPack)
         
     # 召唤满后
@@ -419,16 +426,34 @@
         PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_FBHelpBattle, totalHelpCount)
     return
 
-def DoSingleFBAddXianyuanCoin(curPlayer, mapID, lineID):
-    ## 挑战单人副本增加仙缘币,仅适用于召唤镜像助战挑战的副本
+def DoFBAddXianyuanCoin(curPlayer, mapID, lineID, isHelp=False):
+    '''真人挑战副本增加仙缘币,包含过关或助战(不含镜像助战)
+    @param isHelp: 是否助战的
+    @return: 获得的仙缘币, 无法获得仙缘币原因(1-达到助战次数上限,2-达到每日获得仙缘币上限)
+    '''
     playerID = curPlayer.GetPlayerID()
     fbFuncIpyData = IpyGameDataPY.GetIpyGameData("FBFunc", mapID)
-    fbHelpIpyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, lineID)
-    if not fbFuncIpyData or not fbHelpIpyData:
-        return
+    if not fbFuncIpyData:
+        return 0, 0
     
+    reason = 0
     addCoinRate = 10000 # 基础倍率
-    baseFBPoint = fbFuncIpyData.GetFBPoint() # 过关 - 基础仙缘币
+    if not isHelp:
+        baseFBPoint = fbFuncIpyData.GetFBPoint() # 过关 - 基础仙缘币
+    else:
+        baseFBPoint = fbFuncIpyData.GetHelpPoint() # 助战
+        dayHelpCountMax = fbFuncIpyData.GetDayHelpCountMax() # 真实助战每日可获得仙缘币次数
+        if dayHelpCountMax:
+            todayHelpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FBRealHelpCount % mapID)
+            if todayHelpCount >= dayHelpCountMax:
+                baseFBPoint = 0
+                reason = 1
+                GameWorld.DebugLog("达到每日助战可获得仙缘币次数上限!无法再获得!mapID=%s" % (mapID), playerID)
+            else:
+                todayHelpCount += 1
+                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FBRealHelpCount % mapID, todayHelpCount)
+                GameWorld.DebugLog("增加每日助战可获得仙缘币次数!mapID=%s,todayHelpCount=%s" % (mapID, todayHelpCount), playerID)
+                
     xianyuanCoinUpper = IpyGameDataPY.GetFuncCfg("HelpBattlePoint", 1) # 每日仙缘币上限
     relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...} 
     todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer) # 今日已获得仙缘币
@@ -437,37 +462,95 @@
         playerXianyuanCoinUpper += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinUpperAdd)
         addCoinRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_XianyuanCoinAddPer)
         
-    if todayXianyuanCoin >= playerXianyuanCoinUpper:
-        GameWorld.DebugLog("玩家今日仙缘币已达上限!todayXianyuanCoin=%s,playerXianyuanCoinUpper=%s" 
-                           % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
-        return
+    #达到上限也需要记录,所以这里暂不限制
+    #if todayXianyuanCoin >= playerXianyuanCoinUpper:
+    #    GameWorld.DebugLog("玩家今日仙缘币已达上限!todayXianyuanCoin=%s,playerXianyuanCoinUpper=%s" 
+    #                       % (todayXianyuanCoin, playerXianyuanCoinUpper), playerID)
+    #    return
     
-    relationAdd = 0
-    helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
-    for helpPlayerInfoDict in helpBattlePlayerDict.values():
-        relation = helpPlayerInfoDict.get("Relation", 0)
-        if not relation:
-            continue
-        relationAddList = relationCoinAddDict.get(str(relation), [])
-        relationAdd += relationAddList[1] if len(relationAddList) == 2 else 0
+    relationAdd, relationPlayerID, relationPlayerName = 0, 0, ""
+    
+    fbType = GameWorld.GetMap().GetMapFBType()
+    if fbType == IPY_GameWorld.fbtSingle:
+        helpBattlePlayerDict = PyGameData.g_fbHelpBattlePlayerDict.get(playerID, {})
+        for helpPlayerInfoDict in helpBattlePlayerDict.values():
+            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)
         
-    coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.0)
+    coinAdd = 0
+    if baseFBPoint:
+        coinAdd = int((baseFBPoint + relationAdd) * addCoinRate / 10000.0)
     canAddMax = max(playerXianyuanCoinUpper - todayXianyuanCoin, 0)
     coinAddReal = min(coinAdd, canAddMax) # 实际加仙缘币
-    
-    GameWorld.DebugLog("挑战单人副本增加仙缘币: coinAdd=%s,canAddMax=%s,coinAddReal=%s" % (coinAdd, canAddMax, coinAddReal), playerID)
+    if canAddMax == 0 and not reason:
+        reason = 2
+        
+    GameWorld.DebugLog("挑战副本增加仙缘币: baseFBPoint=%s,relationAdd=%s,addCoinRate=%s,coinAdd=%s,canAddMax=%s,coinAddReal=%s,relationPlayerID=%s" 
+                       % (baseFBPoint, relationAdd, addCoinRate, coinAdd, canAddMax, coinAddReal, relationPlayerID), playerID)
     if coinAddReal:
         addDataDict = {"MapID":mapID, "FuncLineID":lineID}
         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_XianyuanCoin, coinAddReal, addDataDict=addDataDict)
         PlayerControl.AddTodayXianyuanCoin(curPlayer, coinAddReal)
         
     # 通知自己获得仙缘币
-    Sync_AddXianyuanCoinMsg(curPlayer, mapID, lineID, coinAddReal)
-    return
+    Sync_AddXianyuanCoinMsg(curPlayer, mapID, lineID, coinAddReal, relationPlayerID, relationPlayerName)
+    return coinAddReal, reason
 
-def DoTeamFBAddXianyuanCoin(curPlayer, mapID, lineID, callPlayerID, callPlayerName, relation):
-    ## 挑战组队副本增加仙缘币
-    return
+def __GetTeamFBMemRelationInfo(curPlayer, relationCoinAddDict, isHelp):
+    relationAdd = 0 # 社交关系加成
+    relationPlayerID = 0
+    relationPlayerName = ""
+    teamID = curPlayer.GetTeamID()
+    if teamID not in PyGameData.g_teamFBMemRelationDict:
+        return relationAdd, relationPlayerID, relationPlayerName
+    
+    friendList, memFamilyIDDict, memNameDict = PyGameData.g_teamFBMemRelationDict[teamID]
+    relationList = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 3, []) # 社交关系优先级
+    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 == 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
+    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 == memFamilyID:
+                    memRelation = checkRelation
+                    break
+            if not memRelation:
+                continue
+            relationAddList = relationCoinAddDict.get(str(memRelation), [])
+            relationAdd += relationAddList[0] if len(relationAddList) == 2 else 0
+            
+    return relationAdd, relationPlayerID, relationPlayerName
 
 def Sync_AddXianyuanCoinMsg(curPlayer, mapID, funcLineID, addXianyuanCoin, callPlayerID=0, callPlayerName=""):
     '''同步自己主动战斗获得仙缘币信息

--
Gitblit v1.8.0