From 65a4c2029af3f70ce484a2eec167c50f227d7a5c Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期一, 27 五月 2019 14:08:22 +0800
Subject: [PATCH] 6805 【后端】【2.0】副本前端化(封魔坛前期本)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py |  182 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 148 insertions(+), 34 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py
index ee256ce..a181345 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerFairyDomain.py
@@ -19,6 +19,7 @@
 import ChConfig
 import ChPyNetSendPack
 import NetPackCommon
+import PlayerBossReborn
 import ShareDefine
 import GameWorld
 import GameLogic_CrossGrassland
@@ -26,11 +27,14 @@
 import IpyGameDataPY
 import PlayerActivity
 import ItemControler
+import ItemCommon
+import PyGameData
 import EventShell
+import FBCommon
+import NPCCommon
 
 import copy
 import random
-import FBCommon
 
 #0-奇遇 1-宝藏 2-仙草 3-妖王 4-灵草
 (
@@ -56,10 +60,46 @@
 AdventuresType4,
 ) = range(1, 5)
 
+#事件副本类型
+(
+FDEventFBType_Client, #前端本0
+FDEventFBType_Server, #本服本1
+FDEventFBType_CrossServer, #跨服本2
+) = range(3)
 
 def OnLogin(curPlayer):
     NotifyVisitFairyDomainInfo(curPlayer)
     NotifyFairyAdventuresInfo(curPlayer)
+    return
+
+
+def OnHour(curPlayer):
+    __ResetFairyDomainCntLimit(curPlayer, 1)
+    return
+
+
+def OnDay(curPlayer):
+    __ResetFairyDomainCntLimit(curPlayer, 2)
+    return
+
+
+def __ResetFairyDomainCntLimit(curPlayer, resetType):
+    ## 重置个人缥缈事件出现次数记录
+    ipyMgr = IpyGameDataPY.IPY_Data()
+    for i in xrange(ipyMgr.GetFairyDomainCount()):
+        ipyData = ipyMgr.GetFairyDomainByIndex(i)
+        eventID = ipyData.GetID()
+        appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID)
+        if not appearCntInfo:
+            continue
+        hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
+        if resetType == 1:
+            updAppearCntInfo = dayAppearCntPri * 1000
+        elif resetType == 2:
+            updAppearCntInfo = hourAppearCntPri
+        else:
+            return
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID, updAppearCntInfo)
     return
 
 
@@ -80,15 +120,8 @@
         if fairyDomainState != 1:
             GameWorld.DebugLog("    未开始寻访仙域, 无法结束")
             return
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainState, 0)
-        
-        for i in xrange(maxEventCnt):
-            fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
-            if fdEventID:
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventID % i, 0)
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdEventID, 0)
-                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, 0)
-                
+        EndFairyDomain(curPlayer)
+                        
         NotifyVisitFairyDomainInfo(curPlayer)
         return
     
@@ -106,7 +139,7 @@
     if fairyDomainState != 2 and not PlayerActivity.AddDailyActionFinishCnt(curPlayer, dailyID):
         GameWorld.DebugLog("    寻访仙域次数不足!")
         return
-    
+
     #随机事件 重置事件状态
     visitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
     appointIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog('FairyDomainAppoint', visitCnt + 1)
@@ -116,10 +149,11 @@
             fdEventIDList.append(appointIpyData.GetEventID()) 
     else:
         fdEventTypeDict = {}
-        #先随机奇遇事件
-        fortuitousEventRate = IpyGameDataPY.GetFuncCfg('ImmortalDomain')
-        if GameWorld.CanHappen(fortuitousEventRate):
-            fdEventTypeDict[FDEventType0] = 1
+        #先随机独立事件
+        singleEventRateDict = IpyGameDataPY.GetFuncCfg('ImmortalDomain')
+        for eventType, rate in singleEventRateDict.items():
+            if GameWorld.CanHappen(rate):
+                fdEventTypeDict[eventType] = 1
         
         otherCnt = GameWorld.GetResultByRandomList(otherCntRateList, 0)
         if otherCnt:
@@ -142,7 +176,15 @@
             if not randomList:
                 continue                
             fdEventIDList += randomList
-    
+        #更新个人出现次数
+        for fdEventID in fdEventIDList:
+            appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % fdEventID)
+            hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
+            updAppearCntInfo = (dayAppearCntPri + 1) * 1000 + (hourAppearCntPri + 1)
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventAppearCnt % fdEventID, updAppearCntInfo)
+        #更新全服出现次数
+        msgStr = str(fdEventIDList)
+        GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'AddFairyDomainEvent', msgStr, len(msgStr))
     #奇遇事件 随机档位数据
     openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
     for fdEventID in fdEventIDList:
@@ -180,6 +222,23 @@
     #通知
     NotifyVisitFairyDomainInfo(curPlayer, fdEventIDList)
     NotifyFairyAdventuresInfo(curPlayer)
+
+    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_FairyDomain, 1)
+    return
+
+
+def EndFairyDomain(curPlayer):
+    GameWorld.DebugLog("EndFairyDomain", curPlayer.GetID())
+    ##结束寻访
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainState, 0)
+    otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
+    maxEventCnt = max([info[1] for info in otherCntRateList]) + 1  #最大可出现事件个数
+    for i in xrange(maxEventCnt):
+        fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
+        if fdEventID:
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventID % i, 0)
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdEventID, 0)
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyAdventuresData % fdEventID, 0)
     return
 
 
@@ -201,15 +260,47 @@
         if lvLimit and not (lvLimit[0] <= curLV <= lvLimit[1]):
             #等级范围不满足
             continue
-        
+        eventID = ipyData.GetID()
+        appearCntInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventAppearCnt % eventID)
+        hourAppearCntPri, dayAppearCntPri = appearCntInfo % 1000, appearCntInfo / 1000
+        hourCntPriLimit, dayCntPriLimit = ipyData.GetHourCntPriLimit(), ipyData.GetDayCntPriLimit()
+        if hourCntPriLimit and hourAppearCntPri >= hourCntPriLimit:
+            #超过本小时个人可出现次数上限
+            continue
+        if dayCntPriLimit and dayAppearCntPri >= dayCntPriLimit:
+            #超过今日个人可出现次数上限
+            continue
+        if eventID in PyGameData.g_fairyDomainLimit:
+            #超过全服可出现次数
+            continue
         rate += ipyData.GetWeight()
         randomRateList.append([rate, ipyData.GetID()])
     if not randomRateList:
-        GameWorld.DebugLog('    缥缈仙域刷新池 随机库获取错误 !eventType=%s' % eventType, curPlayer.GetID())
+        GameWorld.DebugLog('    缥缈仙域刷新池 该类型没有符合条件的事件!eventType=%s' % eventType, curPlayer.GetID())
         return []
-    randomResultList = GameWorld.GetResultByRandomListEx(randomRateList, cnt, [])
-        
+    realCnt = min(len(randomRateList), cnt)
+    randomResultList = GameWorld.GetResultByRandomListEx(randomRateList, realCnt, [])
+    GameWorld.DebugLog('eventType=%s, cnt=%s,randomRateList=%s,randomResultList=%s' % (eventType, cnt, randomRateList, randomResultList))
     return randomResultList
+
+
+def GetFairyDomainFBEventState(curPlayer, mapID, lineID):
+    ## 获取缥缈相关副本寻访状态
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
+    if not ipyData:
+        return FDEventState_No
+    fdeventID = ipyData.GetID()
+    curState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventState % fdeventID)
+    return curState
+
+
+def SetFairyDomainFBEventState(curPlayer, mapID, lineID, state):
+    ## 设置缥缈相关副本寻访状态
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition("FairyDomain", {"MapID":mapID, "LineID":lineID})
+    if not ipyData:
+        return False
+    fdeventID = ipyData.GetID()
+    return SetFairyDomainEventState(curPlayer, fdeventID, state)
 
 
 def SetFairyDomainEventState(curPlayer, fdeventID, state):
@@ -223,14 +314,14 @@
         return
     if curState == state:
         return True
-    
+    ipyData = IpyGameDataPY.GetIpyGameData('FairyDomain', fdeventID)
+    if not ipyData:
+        return
     if state == FDEventState_Visiting:
         if curState != FDEventState_CanVisit:
             GameWorld.DebugLog('缥缈仙域事件状态设置错误,fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
             return
-        ipyData = IpyGameDataPY.GetIpyGameData('FairyDomain', fdeventID)
-        if not ipyData:
-            return
+        
         costEnergy = ipyData.GetCostEnergy()
         curEnergy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEnergy)
         if curEnergy < costEnergy:
@@ -240,34 +331,38 @@
         
         # 草园重置
         if ipyData.GetEventType() in [FDEventType_GrasslandXian, FDEventType_GrasslandLing]:
-            GameLogic_CrossGrassland.DoResetCrossGrassland(curPlayer, ipyData.GetEventType())
+            GameLogic_CrossGrassland.DoResetCrossGrassland(curPlayer, ipyData.GetEventType(), fdeventID)
             
     elif state == FDEventState_Visited:
-        if curState != FDEventState_Visiting:
-            GameWorld.Log('缥缈仙域事件状态设置错误,fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
-            return
-        EventShell.EventRespons_FairyDomain(curPlayer)
+        #设置结束,暂不做限制,防止异常导致无法结束
+#        if curState != FDEventState_Visiting:
+#            GameWorld.Log('缥缈仙域事件状态设置错误,fdeventID=%s, state=%s, curState=%s' % (fdeventID, state, curState))
+#            return
+        EventShell.EventRespons_FairyDomain(curPlayer, ipyData.GetEventType())
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FairyDomainEventState % fdeventID, state)
     NotifyVisitFairyDomainInfo(curPlayer, [fdeventID], 0)
     return True
 
 
-def NotifyVisitFairyDomainInfo(curPlayer, fdEventList=[], isAll=1):
+def NotifyVisitFairyDomainInfo(curPlayer, fdEventList=None, isAll=1):
     if not fdEventList:
+        syncFDEventList = []
         otherCntRateList = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomain', 2)
         maxEventCnt = max([info[1] for info in otherCntRateList]) + 1  #最大可出现事件个数
         for i in xrange(maxEventCnt):
             fdEventID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventID % i)
             if fdEventID:
-                fdEventList.append(fdEventID)
-            
+                syncFDEventList.append(fdEventID)
+    else:
+        syncFDEventList = fdEventList
+
     packData = ChPyNetSendPack.tagMCFairyDomainInfo()
     packData.IsAll = isAll
     packData.State = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainState)
     packData.Energy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEnergy)
     packData.VisitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
     packData.InfoList = []
-    for fdeventID in fdEventList:
+    for fdeventID in syncFDEventList:
         fdeventData = ChPyNetSendPack.tagMCFairyDomainEvent()
         fdeventData.EventID = fdeventID
         fdeventData.EventState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainEventState % fdeventID)
@@ -350,11 +445,14 @@
                 if not gearAwardList:
                     return
                 itemRateList = gearAwardList[index] if index < len(gearAwardList) else gearAwardList[-1]
+                itemRateList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, itemRateList, 1)
                 giveItemList = [GameWorld.GetResultByWeightList(itemRateList)]
             else:
                 giveItemList = [ipyData.GetBasicAward()]
                 
         ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList)
+        for itemInfo in giveItemList:
+            NPCCommon.SendVirtualItemDrop(curPlayer, itemInfo[0], 0, 0, '')
         msgDict = {FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(giveItemList)}
         FBCommon.Notify_FB_Over(curPlayer, msgDict)
         GameWorld.DebugLog('缥缈奇遇领奖 msgDict=%s, fdeventID=%s' % (msgDict, fdeventID))
@@ -367,4 +465,20 @@
     ipyData = IpyGameDataPY.GetIpyGameDataByCondition('FairyDomainAppoint', {'Cnt':visitCnt, 'EventID':fdEventID}, False, False)
     if not ipyData:
         return
-    return ipyData.GetAward()
+    job = curPlayer.GetJob()
+    itemList = []
+    for itemInfo in ipyData.GetAward():
+        if type(itemInfo[0]) == dict:
+            if job not in itemInfo[0]:
+                continue
+            itemList.append([itemInfo[0][job], itemInfo[1], itemInfo[2]])
+        else:
+            itemList.append(itemInfo)
+    
+    for itemRateList in ipyData.GetRandomAward():
+        itemRateList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, itemRateList, 1)
+        giveItem = GameWorld.GetResultByWeightList(itemRateList)
+        if not giveItem:
+            continue
+        itemList.append(giveItem)
+    return itemList

--
Gitblit v1.8.0