From 8155ce1b16a37578c76b3d520a12f4b5419666a1 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 01 四月 2020 15:53:16 +0800
Subject: [PATCH] 8405 【后端】成就系统开发(成就通行证领奖)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py |   88 +++++++++++++++++++++++++++++++-------------
 1 files changed, 62 insertions(+), 26 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
index 1d4901f..9382a50 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
@@ -89,6 +89,14 @@
         
     return 
 
+def GetSuccPassportAwardHasGot(curPlayer, succID):
+    #获取成就通行证奖励是否已领取
+    return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_Success_PassportAward, succID)
+def SetSuccPassportAwardHasGot(curPlayer, succID, hasGot=True):
+    #设置成就通行证奖励领取状态
+    GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_Success_PassportAward, succID, hasGot)
+    return
+    
 def SetSuccFinishValue(curPlayer, succType, condition, value):
     #设置成就完成度
     key = ChConfig.Def_PDict_Success_CntValue % (succType, condition)
@@ -112,6 +120,7 @@
         self.preSuccIDList = [] # 前置成就ID
         self.condition = [] # 辅助条件(根据类型自定义配置)
         self.awardItemDict = {} # 完成成就可领取的奖励物品{itemid:itemcnt}
+        self.awardItemDict2 = {} # 完成成就可领取的奖励物品,通行证奖励{itemid:itemcnt}
         self.moneyDict = {} # 完成成就获得的金钱 {moneyType:money}
         self.exp = 0 # 完成成就获得的经验
         self.attrDict = {} # 完成成就获得的属性 {attrid:attrvalue}
@@ -153,6 +162,7 @@
             succData.preSuccIDList = list(successIpyData.GetPreSuccess())
             succData.condition = list(successIpyData.GetCondition())
             succData.awardItemDict = successIpyData.GetAwardItem()
+            succData.awardItemDict2 = successIpyData.GetAwardItem2()
             succData.moneyDict = successIpyData.GetMoney()
             succData.exp = successIpyData.GetExp()
             succData.attrDict = successIpyData.GetAwardAttr()
@@ -161,7 +171,8 @@
             magicWeaponExp = successIpyData.GetMagicWeaponExp()
             if magicWeaponID and magicWeaponExp:
                 succData.magicWeaponExp[magicWeaponID] = magicWeaponExp
-            succData.hasAward = bool(succData.awardItemDict or succData.moneyDict or succData.exp or succData.attrDict or succData.redPacketID or succData.magicWeaponExp)
+            succData.hasAward = bool(succData.awardItemDict or succData.moneyDict or succData.exp or succData.attrDict or succData.redPacketID or succData.magicWeaponExp \
+                                     or succData.awardItemDict2)
             successDataObjDict[succData.succID]=succData
             if tuple(succData.condition) not in conditionDict:
                 conditionDict[tuple(succData.condition)] = [succData.succID]
@@ -865,47 +876,64 @@
             awardDict[itemID] = awardDict.get(itemID, 0)+itemCnt
     return awardDict
 
+def GetSuccessPassportState(curPlayer):
+    ## 成就通行证状态
+    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % ChConfig.Def_CTGID_SuccessPassport) > 0
+
 #// A5 42 领取成就奖励 #tagMCGetSuccessAward
 #
 #struct    tagMCGetSuccessAward
 #{
 #    tagHead        Head;
 #    DWORD        SuccID;    //成就ID
+#    BYTE        IsPassport;    //是否通行证奖励
 #};
-## 领取成就奖励
-#  @param None
-#  @return
 def OnGetSuccessAward(index, clientData, tick):
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
     succID = clientData.SuccID
-    __DoGetSuccTypeIndexAward(curPlayer, succID)
+    isPassport = clientData.IsPassport
+    __DoGetSuccTypeIndexAward(curPlayer, succID, isPassport=isPassport)
     return
 
 ## 领取某个成就奖励
 #  @param None
 #  @return
-def __DoGetSuccTypeIndexAward(curPlayer, succID, isGiveItem=True):
-    GameWorld.DebugLog("领取成就奖励succID=%s" % (succID))
+def __DoGetSuccTypeIndexAward(curPlayer, succID, isGiveItem=True, isPassport=False):
+    GameWorld.DebugLog("领取成就奖励succID=%s,isPassport=%s" % (succID, isPassport))
    
     succData = GetSuccDataMng().GetSuccessData(succID)
     if not succData:
         GameWorld.DebugLog("    成就数据不存在!succID=%s" % (succID))
         return
-    
-    finishTime = GetSuccIsFinish(curPlayer, succID)
-    if finishTime <= 0:
-        GameWorld.DebugLog("    该成就未完成!")
-        return
-    
-    if GetSuccHasGot(curPlayer, succID):
-        GameWorld.DebugLog("    该成就奖励已经领取过!")
-        return
-    
+        
     if not succData.hasAward:
         GameWorld.DebugLog("    该成就没有配置奖励!")
         return
     
-    itemDict = succData.awardItemDict
+    finishTime = GetSuccIsFinish(curPlayer, succID)
+    hasGot = GetSuccHasGot(curPlayer, succID) # 因为普通奖励领取后会重置是否已完成,所以如果已经领取普通奖励也代表已完成
+    if finishTime <= 0 and not hasGot:
+        GameWorld.DebugLog("    该成就未完成!")
+        return
+    
+    if isPassport:
+        if GetSuccPassportAwardHasGot(curPlayer, succID):
+            GameWorld.DebugLog("    该成就通行证奖励已经领取过!")
+            return
+        
+        if not GetSuccessPassportState(curPlayer):
+            GameWorld.DebugLog("    未开通成就通行证,无法领取通行证奖励!")
+            return
+        itemDict = succData.awardItemDict2
+        if not itemDict:
+            GameWorld.DebugLog("    该成就没用通行证奖励!")
+            return
+    else:
+        if hasGot:
+            GameWorld.DebugLog("    该成就奖励已经领取过!")
+            return
+        itemDict = succData.awardItemDict
+        
 #    if awardItemDict and '[' in str(awardItemDict):
 #        #修行成就奖励根据境界等级变
 #        curRealmLV = curPlayer.GetOfficialRank()
@@ -919,9 +947,6 @@
 #    else:
 #        itemDict = awardItemDict
         
-            
-        
-        
     # 检查背包
     if isGiveItem:
         packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)
@@ -931,13 +956,20 @@
             return
 
     # 更新领奖记录
-    SetSuccHasGot(curPlayer, succID)
+    if isPassport:
+        SetSuccPassportAwardHasGot(curPlayer, succID)
+    else:
+        SetSuccHasGot(curPlayer, succID)
     
     # 给物品
     if isGiveItem:
         for itemID, itemCnt in itemDict.items():
             isPutIn = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere])
        
+    if isPassport:
+        # 通行证奖励只给物品
+        return itemDict
+    
     #给钱
     for moneyType, value in succData.moneyDict.items():
         PlayerControl.GiveMoney(curPlayer, moneyType, value)
@@ -968,27 +1000,31 @@
     if succIDList:
         recordIndexList = []
         for succID in succIDList:
-            recordIndexList.append(succID / 31)
+            recordIndex = succID / 31
+            if recordIndex not in recordIndexList:
+                recordIndexList.append(recordIndex)
     else:
         ipyDataMgr = IpyGameDataPY.IPY_Data()
         succCnt = ipyDataMgr.GetSuccessCount()
         if not succCnt:
             return
         maxSuccid = ipyDataMgr.GetSuccessByIndex(succCnt-1).GetID()
-        recordIndexList = range(maxSuccid / 31+1)
+        recordIndexList = xrange(maxSuccid / 31+1)
             
     succFARPack = ChPyNetSendPack.tagMCSuccessFinishAwardRecordList()
     succFARPack.Clear()
     succFARPack.RecordList = []
     for i in recordIndexList:
         awardRecord=curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_AwardRecord%i)
-        if not isSyncZero and not awardRecord:
+        passportAwardRecord=curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_PassportAward%i)
+        if not isSyncZero and not awardRecord and not passportAwardRecord:
             continue
         recordInfo = ChPyNetSendPack.tagMCSuccessFinishAwardRecord()
         recordInfo.RecordIndex = i
         recordInfo.Record = awardRecord
+        recordInfo.PassportRecord = passportAwardRecord
         succFARPack.RecordList.append(recordInfo)
-   
+        
     succFARPack.RecordCnt = len(succFARPack.RecordList)
     NetPackCommon.SendFakePack(curPlayer, succFARPack)
     return

--
Gitblit v1.8.0