From 68e048256ca3e40cbc6e73cfd0937663cd41d63c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 27 十二月 2019 20:50:44 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.173on.com:10010/r/SnxxServerCode

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py |  208 +++++++++++++++++++++++++++------------------------
 1 files changed, 111 insertions(+), 97 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 416fb05..e24b989 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActivity.py
@@ -29,6 +29,7 @@
 import PyGameData
 import GameFuncComm
 import EventShell
+import PlayerTJG
 import PlayerPet
 import datetime
 import time
@@ -629,74 +630,115 @@
 #struct    tagCMActivityPlaceStart
 #{
 #    tagHead        Head;
-#    BYTE        RewardEndType;    //是否结算探索,后端处理奖励后自动启动下一次放置探索;0-无结算启动,1-倒计时结束结算,2-快速结算;
 #};
 def OnActivityPlaceStart(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
-    rewardEndType = clientData.RewardEndType
     
+    maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数        
+    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)
     rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)
-    maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # 最大累计放置奖励次数
-    if rewardCount >= maxRewardCount:
-        GameWorld.ErrLog("活跃放置奖励累计次数已达上限,无法启动")
+    
+    maxCanStartCount = maxRewardCount - remainCount - rewardCount
+    if maxCanStartCount <= 0:
+        GameWorld.DebugLog("活跃放置奖励累计次数已达上限,无法启动!remainCount=%s + rewardCount=%s >= maxRewardCount=%s" 
+                           % (remainCount, rewardCount, maxRewardCount))
+        return
+            
+    costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # 单次放置消耗的活跃点数
+    canUseActivityPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityCanCostTotalPoint)
+    pointCanUseCount = canUseActivityPoint / costPoint
+    startCount = min(maxCanStartCount, pointCanUseCount)
+    if startCount <= 0:
+        GameWorld.DebugLog("可用活跃不足,无法添加次数启动!canUseActivityPoint=%s,costPoint=%s" % (canUseActivityPoint, costPoint))
         return
     
-    placeState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceState)
+    updRemainCount = remainCount + startCount
+    GameWorld.DebugLog("添加活跃放置次数: startCount=%s,rewardCount=%s,remainCount=%s,updRemainCount=%s" 
+                       % (startCount, rewardCount, remainCount, updRemainCount))
     
-    endCount, nextStartReduceSeconds = 1, 0
+    costPointTotal = costPoint * startCount
+    CostActivityPoint(curPlayer, costPointTotal)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, updRemainCount)
     
-    # 无结算启动
-    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) # 单次放置奖励持续时间,秒
+    if not remainCount:
         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)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime)
+        GameWorld.DebugLog("    没有剩余次数,更新启动时间: %s" % curTime)
         
     Sync_ActivityPlaceInfo(curPlayer)
     return
 
-def __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds):
+#// B0 28 活跃放置快速完成 #tagCMActivityPlaceQuickFinish
+#
+#struct    tagCMActivityPlaceQuickFinish
+#{
+#    tagHead        Head;
+#    BYTE        FinishCount;    //完成次数
+#};
+def OnActivityPlaceQuickFinish(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    finishCount = clientData.FinishCount
+    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)
+    if not remainCount:
+        GameWorld.DebugLog("没有剩余活跃放置次数,无法快速完成!")
+        return
+    finishCount = min(finishCount, remainCount)
+    if not finishCount:
+        return
+    
+    costItemID, costGoldParper = IpyGameDataPY.GetFuncEvalCfg("ActivityPlace", 5)
+    costItemCount = finishCount # 每次扣一个
+    
+    costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)
+    lackCnt = costItemCount - bindCnt - unBindCnt
+    delItemCount = costItemCount
+    if lackCnt > 0:
+        costGoldParperTotal = costGoldParper * lackCnt
+        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, costGoldParperTotal, ChConfig.Def_Cost_ActivityPlace):
+            return
+        delItemCount -= lackCnt
+        
+    if delItemCount > 0:
+        ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delItemCount, ChConfig.ItemDel_ActivityPlace)
+        
+    __DoActivityPlaceRewardEnd(curPlayer, finishCount)
+    return
+
+def ProcessActivityPlace(curPlayer):
+    ## 活跃放置定时处理
+    
+    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)
+    if remainCount <= 0:
+        #GameWorld.DebugLog("没有剩余放置次数不处理!")
+        return
+    
+    curTime = int(time.time())
+    startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime)
+    if not startTime:
+        startTime = curTime
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime)
+        
+    needSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlace", 3) # 单次放置奖励持续时间,秒
+    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)
+    return
+
+def __DoActivityPlaceRewardEnd(curPlayer, endCount, nextStartReduceSeconds=0):
     ## 放置活跃奖励结算
     
-    if not endCount:
+    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)
+    endCount = min(endCount, remainCount)
+    if endCount <= 0:
         return
+    
+    if PlayerTJG.GetIsTJG(curPlayer):
+        return
+    
     countDataDict = {}
     lvDataDict = {}
     ipyDataMgr = IpyGameDataPY.IPY_Data()
@@ -719,36 +761,24 @@
     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)
+    rewardTotalCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardTotalCount)
     
-    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)
+    GameWorld.DebugLog("结算放置活跃奖励: remainCount=%s,rewardCount=%s,endCount=%s,maxAppointCount=%s" % (remainCount, rewardCount, endCount, maxAppointCount))
+    for _ in xrange(endCount):
         
-        # 超过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)
         
         # 加奖励次数
+        remainCount -= 1
         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("    取定制次数奖励")
+                #GameWorld.DebugLog("    取定制次数奖励: rewardTotalCount=%s" % rewardTotalCount)
                 
         if not rewardIpyData:
             rewardIpyData = lvRewardIpyData
@@ -768,13 +798,17 @@
             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
-            
+        GameWorld.DebugLog("    remainCount=%s,rewardCount=%s,rewardTotalCount=%s, %s" % (remainCount, rewardCount, rewardTotalCount, rewardItemDict))
+        
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, remainCount)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, rewardCount)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, rewardTotalCount)
+    
+    if remainCount > 0:
+        nextStartTime = int(time.time()) - nextStartReduceSeconds
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, nextStartTime)
+        GameWorld.DebugLog("    还有剩余次数,更新启动时间: %s, nextStartReduceSeconds=%s" % (nextStartTime, nextStartReduceSeconds))
+        
     # 存储奖励
     rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)
     for i in xrange(rewardItemCount):
@@ -794,28 +828,8 @@
         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)
-        
+    Sync_ActivityPlaceInfo(curPlayer)
     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):
     ## 领取活跃放置奖励
@@ -855,8 +869,8 @@
         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.PlaceCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)
     placeInfo.RewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)
     placeInfo.RewardInfo = str(rewardItemInfo)
     placeInfo.RewardLen = len(placeInfo.RewardInfo)

--
Gitblit v1.8.0