From 495f9eed41e29b54672a767817c9cb11419dfa4c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 31 七月 2023 16:36:46 +0800
Subject: [PATCH] 9788 【BT9】【后端】成就系统(增加成就积分) hygame2

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py      |   52 +++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py      |    3 +
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py |   37 ++++++++++++
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py                           |   52 +++++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Success.py  |    5 +
 5 files changed, 148 insertions(+), 1 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index f2a8af1..c2f6256 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -24262,6 +24262,58 @@
 
 
 #------------------------------------------------------
+# A3 43  成就积分信息 #tagMCSuccessScoreInfo
+
+class  tagMCSuccessScoreInfo(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("ScoreAwardState", c_int),    #成就积分领奖记录,按奖励索引位记录是否领取
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA3
+        self.SubCmd = 0x43
+        return
+
+    def ReadData(self, stringData, _pos=0, _len=0):
+        self.Clear()
+        memmove(addressof(self), stringData[_pos:], self.GetLength())
+        return _pos + self.GetLength()
+
+    def Clear(self):
+        self.Cmd = 0xA3
+        self.SubCmd = 0x43
+        self.ScoreAwardState = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCSuccessScoreInfo)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A3 43  成就积分信息 //tagMCSuccessScoreInfo:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                ScoreAwardState:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.ScoreAwardState
+                                )
+        return DumpString
+
+
+m_NAtagMCSuccessScoreInfo=tagMCSuccessScoreInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuccessScoreInfo.Cmd,m_NAtagMCSuccessScoreInfo.SubCmd))] = m_NAtagMCSuccessScoreInfo
+
+
+#------------------------------------------------------
 #A3 14 通知各功能的祝福值  #tagMCSyncBlessValue
 
 class  tagMCSyncSingleBlessValue(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index f2a8af1..c2f6256 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -24262,6 +24262,58 @@
 
 
 #------------------------------------------------------
+# A3 43  成就积分信息 #tagMCSuccessScoreInfo
+
+class  tagMCSuccessScoreInfo(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ("ScoreAwardState", c_int),    #成就积分领奖记录,按奖励索引位记录是否领取
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA3
+        self.SubCmd = 0x43
+        return
+
+    def ReadData(self, stringData, _pos=0, _len=0):
+        self.Clear()
+        memmove(addressof(self), stringData[_pos:], self.GetLength())
+        return _pos + self.GetLength()
+
+    def Clear(self):
+        self.Cmd = 0xA3
+        self.SubCmd = 0x43
+        self.ScoreAwardState = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCSuccessScoreInfo)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A3 43  成就积分信息 //tagMCSuccessScoreInfo:
+                                Cmd:%s,
+                                SubCmd:%s,
+                                ScoreAwardState:%d
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd,
+                                self.ScoreAwardState
+                                )
+        return DumpString
+
+
+m_NAtagMCSuccessScoreInfo=tagMCSuccessScoreInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCSuccessScoreInfo.Cmd,m_NAtagMCSuccessScoreInfo.SubCmd))] = m_NAtagMCSuccessScoreInfo
+
+
+#------------------------------------------------------
 #A3 14 通知各功能的祝福值  #tagMCSyncBlessValue
 
 class  tagMCSyncSingleBlessValue(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Success.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Success.py
index d683796..b2491a0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Success.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/Success.py
@@ -19,6 +19,7 @@
 import ShareDefine
 import PlayerSuccess
 import GameWorld
+import PlayerControl
 
 #逻辑实现
 ## GM命令执行入口
@@ -83,6 +84,8 @@
     PlayerSuccess.Sync_SuccessInfo(curPlayer, [], True)
     # 同步成就领奖记录
     PlayerSuccess.Sync_SuccTypeIndexAwardRecord(curPlayer, [], True)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Success_ScoreAward, 0)
+    PlayerSuccess.Sync_SuccessScoreAward(curPlayer)
     GameWorld.DebugAnswer(curPlayer, "重置成就类型:%s" % resetTypeList)
     return
 
@@ -111,6 +114,8 @@
     # 同步成就领奖记录
     PlayerSuccess.Sync_SuccTypeIndexAwardRecord(curPlayer, resetIDList, True)
     GameWorld.DebugAnswer(curPlayer, "重置成就ID领奖:%s" % resetIDList)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Success_ScoreAward, 0)
+    PlayerSuccess.Sync_SuccessScoreAward(curPlayer)
     return
 
 def __DoPrintSuccess(curPlayer, msgList):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
index 4e315ad..459f36d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -5616,6 +5616,9 @@
     # 古宝特殊效果物品奖励
     elif rewardType == ChConfig.Def_RewardType_GubaoItemEff:
         PlayerGubao.GetGubaoItemEffAward(curPlayer, dataEx, dataExStr)
+    # 成就积分奖励
+    elif rewardType == ChConfig.Def_RewardType_SuccessScore:
+        PlayerSuccess.GetSuccessScoreAward(curPlayer, dataEx)
     #缥缈奇遇领取
     elif rewardType == ChConfig.Def_RewardType_FairyAdventuresAward:
         PlayerFairyDomain.GetFairyAdventuresAward(curPlayer, dataEx, dataExStr)
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 1f181c5..11b362c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
@@ -245,6 +245,9 @@
         if not succInfoList:
             continue
         __DoCheckSuccessFinish(curPlayer, succType, succInfoList)
+        
+    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_ScoreAward):
+        Sync_SuccessScoreAward(curPlayer)
     return
 
 ## 检查老玩家成就激活情况
@@ -1044,4 +1047,36 @@
     elif mapID == ChConfig.Def_FBMapID_IceLode:
         #冰晶矿脉
         DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_IceLode, addCount)
-    return
\ No newline at end of file
+    return
+
+def GetSuccessScoreAward(curPlayer, awardIndex):
+    playerID = curPlayer.GetPlayerID()
+    awardDict = IpyGameDataPY.GetFuncEvalCfg("SucceeScore", 1, {})
+    if str(awardIndex) not in awardDict:
+        return
+    awardInfo = awardDict[str(awardIndex)]
+    if len(awardInfo) != 2:
+        return
+    needScore, awardItemList = awardInfo
+    if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_SuccessSocre, needScore):
+        GameWorld.Log("成就积分不足,无法领奖! awardIndex=%s,needScore=%s" % (awardIndex, needScore), playerID)
+        return
+    awardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_ScoreAward)
+    if awardState & pow(2, awardIndex):
+        GameWorld.DebugLog("已领取过该成就积分奖励! awardIndex=%s" % awardIndex, playerID)
+        return
+    updAwardState = awardState | pow(2, awardIndex)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Success_ScoreAward, updAwardState)
+    GameWorld.DebugLog("领取成就积分奖励! awardIndex=%s,awardState=%s,updAwardState=%s" % (awardIndex, awardState, updAwardState), playerID)
+    Sync_SuccessScoreAward(curPlayer)
+    ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["SuccessScore", False, {}])
+    return
+
+def Sync_SuccessScoreAward(curPlayer):
+    clientPack = ChPyNetSendPack.tagMCSuccessScoreInfo()
+    clientPack.Clear()
+    clientPack.ScoreAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Success_ScoreAward)
+    NetPackCommon.SendFakePack(curPlayer, clientPack)
+    return
+    
+    
\ No newline at end of file

--
Gitblit v1.8.0