From 787c076b2fdc73a11b9b76e2ea928f3da1f5873e Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 19 十二月 2019 16:35:02 +0800
Subject: [PATCH] 8359 【主干】活跃兑换

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py |  286 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 256 insertions(+), 30 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py
index 6c610a3..416fb05 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py
@@ -31,6 +31,7 @@
 import EventShell
 import PlayerPet
 import datetime
+import time
 
 #关联类型
 (
@@ -84,12 +85,6 @@
         __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint, 0)
         #重新计算奖励阶段
         __CalcAwardStage(curPlayer)
-        #重置可领取修行点,未领取的发邮件
-#        realmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint)
-#        if realmPoint and GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Official):
-#            if GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_DailyQuest):
-#                PlayerControl.SendMailByKey('XXDForgetToPick', [curPlayer.GetID()], [(ChConfig.Def_ItemID_RealmPoint, realmPoint, 1)], [realmPoint])
-#            __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint, 0)
         
         SyncDailyActivityInfo(curPlayer)
     else:
@@ -149,6 +144,8 @@
     SyncDailyActivityInfo(curPlayer)
     #同步日常活动次数
     SyncDailyActionInfo(curPlayer)
+    #活跃放置
+    Sync_ActivityPlaceInfo(curPlayer)
     return
 
 
@@ -279,17 +276,12 @@
         addValue = addValue + addExtraPoint
     curTotalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)
     __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, curTotalPoint + addValue)
-    AddCanCostActivityPoint(curPlayer, addValue, isLVUp)
-    historyPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint)
-    __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint,
-                    min(ChConfig.Def_UpperLimit_DWord, historyPoint + addValue))
-
+    __AddCanCostActivityPoint(curPlayer, addValue, isLVUp)
+    
     SyncDailyActivityInfo(curPlayer)
     EventShell.EventRespons_AddActivityValue(curPlayer)
-    GameWorld.DebugLog(
-        "增加活跃度,addValue=%s, multiple=%s, addExtraPoint=%s"
-        % (addValue, multiple, addExtraPoint), curPlayer.GetPlayerID())
-
+    GameWorld.DebugLog("增加活跃度,addValue=%s,multiple=%s,addExtraPoint=%s,isLVUp=%s" 
+                       % (addValue, multiple, addExtraPoint, isLVUp), curPlayer.GetPlayerID())
     return
 
 def __GetActionAddPer(curPlayer):
@@ -306,13 +298,13 @@
         return multiple, extraPointLimit
     return actRealmPointIpyData.GetMultiple(), actRealmPointIpyData.GetPointLimit()
 
-def AddCanCostActivityPoint(curPlayer, addValue, isLVUp):
+def __AddCanCostActivityPoint(curPlayer, addValue, isLVUp):
     # 增加可消耗的活跃点
     curPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint)
     if isLVUp:
         updPoint = min(ChConfig.Def_UpperLimit_DWord, curPoint + addValue)
     else:
-        maxPoint = IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint', 1)
+        maxPoint = IpyGameDataPY.GetFuncCfg('ActivityPlace', 1)
         if maxPoint and curPoint >= maxPoint:
             GameWorld.DebugLog("可消耗的活跃点超出上限,不增加! curPoint=%s,maxPoint=%s" % (curPoint, maxPoint))
             return
@@ -402,19 +394,6 @@
     GameWorld.DebugLog("领取活跃度奖励OK!awardStage=%s, index=%s,needActivity=%s,totalActivity=%s,awardRecord=%s" 
                        % (awardStage, awardIndex, needActivity, totalActivity, updAwardRecord))
     EventShell.EventRespons_ActivityAward(curPlayer, awardIndex)
-    return
-
-
-def GetRealmPointAward(curPlayer):
-    #领取活跃修行点
-    realmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint)
-    if not realmPoint:
-        return
-    PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_RealmPoint, realmPoint)
-    __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint, 0)
-    #totalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)
-    #__SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, totalPoint+realmPoint)
-    SyncDailyActivityInfo(curPlayer)
     return
 
 
@@ -641,3 +620,250 @@
     if activityNum: 
         AddActivityFinishCnt(curPlayer, activityNum, curDayTimes, addCount)
     return
+
+
+################################## 活跃放置 ##############################################
+
+#// B0 27 活跃放置启动 #tagCMActivityPlaceStart
+#
+#struct    tagCMActivityPlaceStart
+#{
+#    tagHead        Head;
+#    BYTE        RewardEndType;    //是否结算探索,后端处理奖励后自动启动下一次放置探索;0-无结算启动,1-倒计时结束结算,2-快速结算;
+#};
+def OnActivityPlaceStart(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    rewardEndType = clientData.RewardEndType
+    
+    rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)
+    maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数
+    if rewardCount >= maxRewardCount:
+        GameWorld.ErrLog("活跃放置奖励累计次数已达上限,无法启动")
+        return
+    
+    placeState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceState)
+    
+    endCount, nextStartReduceSeconds = 1, 0
+    
+    # 无结算启动
+    if rewardEndType == 0:
+        if placeState:
+            GameWorld.DebugLog("已在放置探索中!")
+            return
+        __DoActivityPlaceStart(curPlayer)
+        
+    # 倒计时结束结算
+    elif rewardEndType == 1:
+        if not placeState:
+            GameWorld.DebugLog("非放置探索中,无法结算!")
+            return
+        startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime)
+        if not startTime:
+            return
+        needSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlace", 3) # 单次放置奖励持续时间,秒
+        curTime = int(time.time())
+        passTime = curTime - startTime
+        if passTime < needSeconds:
+            GameWorld.DebugLog("探索时间未到,无法结算! curTime=%s,startTime=%s,passTime=%s < %s" % (curTime, startTime, passTime, needSeconds))
+            return
+        endCount = passTime / needSeconds
+        nextStartReduceSeconds = passTime % needSeconds
+        __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds)
+        
+    # 快速结算
+    elif rewardEndType == 2:
+        if not placeState:
+            GameWorld.DebugLog("非放置探索中,无法快速结算!")
+            return
+        
+        costItemID, costGoldParper = IpyGameDataPY.GetFuncEvalCfg("ActivityPlace", 5)
+        costItemCount = 1
+        
+        costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)
+        lackCnt = costItemCount - bindCnt - unBindCnt
+        if lackCnt > 0:
+            if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, costGoldParper, ChConfig.Def_Cost_ActivityPlace):
+                return
+        else:
+            ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, ChConfig.ItemDel_ActivityPlace)
+            
+        __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds)
+        
+    Sync_ActivityPlaceInfo(curPlayer)
+    return
+
+def __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds):
+    ## 放置活跃奖励结算
+    
+    if not endCount:
+        return
+    countDataDict = {}
+    lvDataDict = {}
+    ipyDataMgr = IpyGameDataPY.IPY_Data()
+    for index in xrange(ipyDataMgr.GetActivityPlaceRewardCount()):
+        ipyData = ipyDataMgr.GetActivityPlaceRewardByIndex(index)
+        placeCount = ipyData.GetPlaceCount()
+        placeMaxLV = ipyData.GetPlaceMaxLV()
+        if placeCount:
+            countDataDict[placeCount] = ipyData
+        else:
+            lvDataDict[placeMaxLV] = ipyData
+            
+    lvRewardIpyData = None
+    playerLV = curPlayer.GetLV()
+    lvList = sorted(lvDataDict.keys())
+    for lv in lvList:
+        if playerLV <= lv:
+            lvRewardIpyData = lvDataDict[lv]
+            break
+    if not lvRewardIpyData:
+        lvRewardIpyData = lvDataDict[lvList[-1]]
+        
+    costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数
+    maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数
+    maxAppointCount = max(countDataDict) # 最大定制奖励次数
+    rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)
+    
+    isStop = False
+    rewardItemDict = {}
+    GameWorld.DebugLog("结算放置活跃奖励: rewardCount=%s,endCount=%s,maxRewardCount=%s,maxAppointCount=%s" % (rewardCount, endCount, maxRewardCount, maxAppointCount))
+    for endIndex in xrange(endCount):
+        #GameWorld.DebugLog("endIndex=%s" % endIndex)
+        
+        # 超过1次的需要补扣活跃消耗
+        if endCount > 1 and endIndex != 0:
+            if not CostActivityPoint(curPlayer, costPoint):
+                isStop = True
+                GameWorld.DebugLog("    可消耗的活跃不足,无法继续结算奖励!")
+                break
+            
+        rewardIpyData = None
+        rewardTotalCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardTotalCount)
+        
+        # 加奖励次数
+        rewardCount += 1
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, rewardCount)
+        if rewardTotalCount < maxAppointCount:
+            rewardTotalCount += 1
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, rewardTotalCount)
+            if rewardTotalCount in countDataDict:
+                rewardIpyData = countDataDict[rewardTotalCount]
+                #GameWorld.DebugLog("    取定制次数奖励")
+                
+        if not rewardIpyData:
+            rewardIpyData = lvRewardIpyData
+            #GameWorld.DebugLog("    取等级奖励: maxLV=%s" % rewardIpyData.GetPlaceMaxLV())
+            
+        # 固定奖励
+        for itemID, itemCount in rewardIpyData.GetFixedItemRewardList():
+            rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + itemCount
+        # 饼图库A
+        for _ in xrange(rewardIpyData.GetRandItemCountA()):
+            itemID = GameWorld.GetResultByRandomList(rewardIpyData.GetRandItemRewardListA())
+            if itemID:
+                rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + 1
+        # 饼图库B
+        for _ in xrange(rewardIpyData.GetRandItemCountB()):
+            itemID = GameWorld.GetResultByRandomList(rewardIpyData.GetRandItemRewardListB())
+            if itemID:
+                rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + 1
+                
+        GameWorld.DebugLog("    rewardCount=%s,rewardTotalCount=%s, %s" % (rewardCount, rewardTotalCount, rewardItemDict))
+
+        if rewardCount >= maxRewardCount:
+            isStop = True
+            GameWorld.DebugLog("    放置活跃奖励次数已达上限!rewardCount=%s" % rewardCount)
+            break
+            
+    # 存储奖励
+    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)
+    for i in xrange(rewardItemCount):
+        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)
+        if itemID not in rewardItemDict:
+            continue
+        addCount = rewardItemDict.pop(itemID)
+        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)
+        updCount = itemCount + addCount
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i, updCount)
+        #GameWorld.DebugLog("    更新探索奖励: itemID=%s,itemCount=%s,addCount=%s,updCount=%s" % (itemID, itemCount, addCount, updCount))
+        
+    for itemID, itemCount in rewardItemDict.items():
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemID % rewardItemCount, itemID)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % rewardItemCount, itemCount)
+        rewardItemCount += 1
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, rewardItemCount)
+        #GameWorld.DebugLog("    新增探索奖励: itemID=%s,itemCount=%s,rewardItemCount=%s" % (itemID, itemCount, rewardItemCount))
+        
+    if isStop:
+        GameWorld.DebugLog("    停止探索!")
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 0)
+    else:
+        __DoActivityPlaceStart(curPlayer, nextStartReduceSeconds)
+        
+    return
+
+def __DoActivityPlaceStart(curPlayer, reduceSeconds=0):
+    
+    costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数
+    canUseActivityPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityCanCostTotalPoint)
+    if canUseActivityPoint < costPoint:
+        GameWorld.DebugLog("活跃度不足,无法启动放置探索!canUseActivityPoint=%s" % canUseActivityPoint)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 0)
+        return
+    startTime = int(time.time()) - reduceSeconds
+    GameWorld.DebugLog("    启动新一轮放置探索!reduceSeconds=%s" % reduceSeconds)
+    CostActivityPoint(curPlayer, costPoint)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceState, 1)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, startTime)
+    return True
+
+def GetActivityPlaceReward(curPlayer):
+    ## 领取活跃放置奖励
+    
+    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)
+    if not rewardItemCount:
+        GameWorld.DebugLog("没有活跃放置奖励,无法领取!")
+        return
+    
+    isAppointItem = 0
+    rewardItemList = []
+    for i in xrange(rewardItemCount):
+        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)
+        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)
+        if not itemID or not itemCount:
+            break
+        rewardItemList.append([itemID, itemCount, isAppointItem])
+        
+        # 领取后需要重置为0
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemID % i, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i, 0)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, 0)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, 0)
+    
+    GameWorld.DebugLog("领取活跃放置奖励: rewardItemCount=%s,rewardItemList=%s" % (rewardItemCount, rewardItemList))
+    ItemControler.GivePlayerItemOrMail(curPlayer, rewardItemList)
+    
+    Sync_ActivityPlaceInfo(curPlayer)
+    return
+
+def Sync_ActivityPlaceInfo(curPlayer):
+    ## 同步活跃放置信息
+    rewardItemInfo = []
+    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)
+    for i in xrange(rewardItemCount):
+        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)
+        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)
+        rewardItemInfo.append([itemID, itemCount])
+    placeInfo = ChPyNetSendPack.tagMCActivityPlaceInfo()
+    placeInfo.PlaceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceState)
+    placeInfo.StartTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime)
+    placeInfo.RewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)
+    placeInfo.RewardInfo = str(rewardItemInfo)
+    placeInfo.RewardLen = len(placeInfo.RewardInfo)
+    NetPackCommon.SendFakePack(curPlayer, placeInfo)
+    return
+
+#########################################################################################
+
+
+

--
Gitblit v1.8.0