From fe9b738b1cb89e3b4d320924fceef70a8e1f6fac Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 04 三月 2021 14:24:50 +0800
Subject: [PATCH] 8650 【主干】【BT2】活动规则优化(多活动支持的改为单表模式,增加活动分组编号字段区分不同的活动编号;常规活动改为不受合服影响,合服活动独立出来;累计充值活动、集字活动适配为新模式 master冲突补同步);

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py |  154 +++++++++++++++++++++++++++++----------------------
 1 files changed, 87 insertions(+), 67 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
index b286ff9..5dcada6 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActTotalRecharge.py
@@ -29,30 +29,70 @@
 import ChConfig
 import CommFunc
 
-def GetTemplateID(cfgID, dayIndex, actNum):
+def GetTemplateID(cfgID, dayIndex):
     if cfgID == None or dayIndex == None:
         return 0
-    if actNum == 1:
-        ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge", cfgID)
-    else:
-        ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge%s" % actNum, cfgID)        
+    ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge", cfgID)     
     if not ipyData:
         return 0
     templateIDList = ipyData.GetTemplateIDList()
     templateID = templateIDList[-1] if dayIndex >= len(templateIDList) else templateIDList[dayIndex]
     return templateID
 
+def GetActInfo(actNum):
+    if ShareDefine.OperationActionName_TotalRecharge not in PyGameData.g_operationActionDict:
+        return {}
+    actNumDict = PyGameData.g_operationActionDict[ShareDefine.OperationActionName_TotalRecharge]
+    if actNum not in actNumDict:
+        return {}
+    return actNumDict[actNum]
+
 def OnPlayerLogin(curPlayer):
     
-    for actNum, actName in ShareDefine.OperationActionName_TotalRechargeDict.items():
+    TransferPlayerActDBKeyValue(curPlayer)
+    
+    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_TotalRecharge, {}).values():
+        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
         isReset = __CheckPlayerTotalRechargeAction(curPlayer, actNum)
         if not isReset:
-            actTotalRechargeInfo = PyGameData.g_operationActionDict.get(actName, {})
             # 活动中同步活动信息
-            if actTotalRechargeInfo.get(ShareDefine.ActKey_State):
+            if actInfo.get(ShareDefine.ActKey_State):
                 Sync_TotalRechargeActionInfo(curPlayer, actNum)
                 Sync_TotalRechargeInfo(curPlayer, actNum)
                 
+    return
+
+def TransferPlayerActDBKeyValue(curPlayer):
+    ## 玩家登录时调用,旧版本玩家活动数据转移到新版本字典,线上版本维护之后的版本可删除此代码,线上版本分支 gt_1.100.4
+    
+    # 原: 1-常规单日;2-常规多日;3-节日多日
+    # 新:10            11        31
+    transferActNumDict = {1:10, 2:11, 3:31}
+    for actNumOld, actNumNew in transferActNumDict.items():
+        actID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeID % actNumOld)
+        if not actID:
+            continue
+        
+        templateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeTemplateID % actNumOld)
+        rechargeGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeGold % actNumOld)
+        awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeAwardRecord % actNumOld)
+        worldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeWorldLV % actNumOld)
+        
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeID % actNumNew, actID)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeTemplateID % actNumNew, templateID)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeGold % actNumNew, rechargeGold)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeAwardRecord % actNumNew, awardRecord)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeWorldLV % actNumNew, worldLV)
+        
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeID % actNumOld, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeTemplateID % actNumOld, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeGold % actNumOld, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeAwardRecord % actNumOld, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeWorldLV % actNumOld, 0)
+        
+        GameWorld.Log("累计充值转移玩家活动字典记录: actNumOld=%s,actNumNew=%s,actID=%s,templateID=%s,rechargeGold=%s,awardRecord=%s,worldLV=%s" 
+                      % (actNumOld, actNumNew, actID, templateID, rechargeGold, awardRecord, worldLV), curPlayer.GetPlayerID())
+        
     return
 
 def RefreshTotalRechargeActionInfo(actNum):
@@ -69,12 +109,9 @@
     ## 检查玩家累计充值活动数据信息
     
     playerID = curPlayer.GetPlayerID()
-    if actNum not in ShareDefine.OperationActionName_TotalRechargeDict:
-        return
-    actName = ShareDefine.OperationActionName_TotalRechargeDict[actNum]
-    actTotalRechargeInfo = PyGameData.g_operationActionDict.get(actName, {})
-    TotalRechargeID = actTotalRechargeInfo.get(ShareDefine.ActKey_ID, 0)
-    state = actTotalRechargeInfo.get(ShareDefine.ActKey_State, 0)
+    actInfo = GetActInfo(actNum)
+    TotalRechargeID = actInfo.get(ShareDefine.ActKey_ID, 0)
+    state = actInfo.get(ShareDefine.ActKey_State, 0)
     
     playerTotalRechargeID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeID % actNum) # 玩家身上的活动ID
     
@@ -82,9 +119,9 @@
     if TotalRechargeID == playerTotalRechargeID:
         GameWorld.DebugLog("累计充值活动ID不变,不处理!actNum=%s" % actNum, curPlayer.GetPlayerID())
         return
-    actWorldLV = actTotalRechargeInfo.get(ShareDefine.ActKey_WorldLV, 0)
+    actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
     playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeWorldLV % actNum)
-    templateID = GetTemplateID(actTotalRechargeInfo.get(ShareDefine.ActKey_CfgID, 0), actTotalRechargeInfo.get(ShareDefine.ActKey_DayIndex, 0), actNum)
+    templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), actNum)
     playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeTemplateID % actNum)
     
     GameWorld.DebugLog("累计充值重置! actNum=%s,TotalRechargeID=%s,playerTotalRechargeID=%s,state=%s,templateID=%s,playerTemplateID=%s" 
@@ -138,8 +175,8 @@
         
     if batchPlayerIDList:
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeAwardRecord % actNum, awardRecord)
-        mailTypeKey = "TotalRechargeMail40" if actNum == 3 else "TotalRechargeMail"
-        PlayerControl.SendMailBatch(mailTypeKey, batchPlayerIDList, batchAddItemList, batchParamList)
+        actType = actNum / 10
+        PlayerControl.SendMailBatch("TotalRechargeMail%s" % actType, batchPlayerIDList, batchAddItemList, batchParamList)
         
     return
 
@@ -153,54 +190,47 @@
         return itemInfoDict[str(job)]
     
 
-def AddTotalRechargeGold(curPlayer, addGold, actNum):
+def AddTotalRechargeGold(curPlayer, addGold):
     if addGold <= 0:
         return
-   
-    if actNum not in ShareDefine.OperationActionName_TotalRechargeDict:
-        return
-    actName = ShareDefine.OperationActionName_TotalRechargeDict[actNum]
-    actTotalRechargeInfo = PyGameData.g_operationActionDict.get(actName, {})
     
-    if not actTotalRechargeInfo.get(ShareDefine.ActKey_State):
-        GameWorld.DebugLog("累计充值活动当前未开启! actNum=%s" % actNum)
-        return
-    
-    actID = actTotalRechargeInfo.get(ShareDefine.ActKey_ID)
-    templateID = GetTemplateID(actTotalRechargeInfo.get(ShareDefine.ActKey_CfgID, 0), actTotalRechargeInfo.get(ShareDefine.ActKey_DayIndex, 0), actNum)
-    if not actID or not templateID:
-        GameWorld.ErrLog("累计充值活动数据异常!actID=%s,templateID=%s" % (actID, templateID), curPlayer.GetPlayerID())
-        return
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeID % actNum, actID)
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeTemplateID % actNum, templateID)
-    
-    curRechargeGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeGold % actNum)
-    updRechargeGold = curRechargeGold + addGold
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeGold % actNum, updRechargeGold)
-    Sync_TotalRechargeInfo(curPlayer, actNum)
-    GameWorld.DebugLog("玩家累计充值活动: actNum=%s,actID=%s,templateID=%s,curRechargeGold=%s,addGold=%s,updRechargeGold=%s" 
-                       % (actNum, actID, templateID, curRechargeGold, addGold, updRechargeGold), curPlayer.GetPlayerID())
+    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_TotalRecharge, {}).values():
+        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
+        if not actInfo.get(ShareDefine.ActKey_State):
+            GameWorld.DebugLog("累计充值活动当前未开启! actNum=%s" % actNum)
+            continue
+        
+        actID = actInfo.get(ShareDefine.ActKey_ID)
+        templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), actNum)
+        if not actID or not templateID:
+            GameWorld.ErrLog("累计充值活动数据异常!actID=%s,templateID=%s" % (actID, templateID), curPlayer.GetPlayerID())
+            continue
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeID % actNum, actID)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeTemplateID % actNum, templateID)
+        
+        curRechargeGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeGold % actNum)
+        updRechargeGold = curRechargeGold + addGold
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalRechargeGold % actNum, updRechargeGold)
+        Sync_TotalRechargeInfo(curPlayer, actNum)
+        GameWorld.DebugLog("玩家累计充值活动: actNum=%s,actID=%s,templateID=%s,curRechargeGold=%s,addGold=%s,updRechargeGold=%s" 
+                           % (actNum, actID, templateID, curRechargeGold, addGold, updRechargeGold), curPlayer.GetPlayerID())
     return
 
 def OnGetTotalRechargeAward(curPlayer, awardIndex, actNum):
     '''OnGetTotalRechargeAward
     @param awardIndex: 奖励索引
-    @param actNum: 活动编号,如1 或 2 代表不同的活动
+    @param actNum: 活动编号,如11 或  12 代表不同的活动
     '''
     actNum = GameWorld.ToIntDef(actNum, 0)
     if actNum <= 0:
         GameWorld.DebugLog("没有指定领取的累充活动编号! actNum=%s" % actNum)
         return
     playerID = curPlayer.GetPlayerID()
-    
-    if actNum not in ShareDefine.OperationActionName_TotalRechargeDict:
-        return
-    actName = ShareDefine.OperationActionName_TotalRechargeDict[actNum]
-    actTotalRechargeInfo = PyGameData.g_operationActionDict.get(actName, {})
+    actInfo = GetActInfo(actNum)
                 
-    TotalRechargeID = actTotalRechargeInfo.get(ShareDefine.ActKey_ID, 0)
-    state = actTotalRechargeInfo.get(ShareDefine.ActKey_State, 0)
-    templateID = GetTemplateID(actTotalRechargeInfo.get(ShareDefine.ActKey_CfgID, 0), actTotalRechargeInfo.get(ShareDefine.ActKey_DayIndex, 0), actNum)
+    TotalRechargeID = actInfo.get(ShareDefine.ActKey_ID, 0)
+    state = actInfo.get(ShareDefine.ActKey_State, 0)
+    templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0))
     if not state or not templateID:
         GameWorld.DebugLog("没有累计充值活动,无法领奖!actNum=%s,state=%s,templateID=%s" % (actNum, state, templateID), playerID)
         return
@@ -229,7 +259,7 @@
         return
     
     needGold = CommFunc.RMBToCoin(awardIpyData.GetNeedGold())
-    actWorldLV = actTotalRechargeInfo.get(ShareDefine.ActKey_WorldLV, 0)
+    actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
     awardItemList = __GetItemList(ipyData.GetAwardItem(), curPlayer.GetJob(), actWorldLV)
     
     curRechargeGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalRechargeGold % actNum)
@@ -271,22 +301,12 @@
 def Sync_TotalRechargeActionInfo(curPlayer, actNum):
     ## 通知累计充值活动信息
     
-    if actNum not in ShareDefine.OperationActionName_TotalRechargeDict:
-        return
-    actName = ShareDefine.OperationActionName_TotalRechargeDict[actNum]
-    actTotalRechargeInfo = PyGameData.g_operationActionDict.get(actName, {})
-    
-    if not actTotalRechargeInfo:
+    actInfo = GetActInfo(actNum)
+    if not actInfo.get(ShareDefine.ActKey_State):
         return
     
-    if not actTotalRechargeInfo.get(ShareDefine.ActKey_State):
-        return
-    
-    cfgID = actTotalRechargeInfo.get(ShareDefine.ActKey_CfgID)
-    if actNum == 1:
-        ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge", cfgID)
-    else:
-        ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge%s" % actNum, cfgID)  
+    cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
+    ipyData = IpyGameDataPY.GetIpyGameData("ActTotalRecharge", cfgID)
     if not ipyData:
         return
     
@@ -294,7 +314,7 @@
     if not templateIDList:
         return
     job = curPlayer.GetJob()
-    actWorldLV = actTotalRechargeInfo.get(ShareDefine.ActKey_WorldLV, 0)
+    actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
     openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
     actInfo = ChPyNetSendPack.tagMCActTotalRechargeInfo()
     actInfo.ActNum = actNum

--
Gitblit v1.8.0