From c04a87b2679e8561dcbe3fad845e169a27f1ec46 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期五, 22 二月 2019 17:11:37 +0800
Subject: [PATCH] 6256 子 【开发】【2.0】神秘商店开发 / 【后端】【2.0】神秘商店

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py |  134 ++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini                              |    6 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py                      |   48 +++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py                  |  111 ++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py                    |   20 ++
 PySysDB/PySysDBPY.h                                                                                     |    8 
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py                                           |   48 +++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py             |    2 
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py                                       |  111 ++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py               |    4 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py                         |    8 
 11 files changed, 492 insertions(+), 8 deletions(-)

diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index a9cb801..96dbfbe 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -1750,4 +1750,12 @@
 	WORD		ItemCnt;	//物品数量
 	BYTE		IsBind;	//是否绑定
 	DWORD		Weight;	//权重
+};
+
+//神秘商店表
+
+struct tagMysteryShop
+{
+	list		LVRange;	//等级范围
+	DWORD		GoodsID;	//商城表ID
 };
\ No newline at end of file
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index 0728bf6..084a3af 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -5015,6 +5015,54 @@
 
 
 #------------------------------------------------------
+# A2 32 神秘商店刷新 #tagCMRefreshMysticalShop
+
+class  tagCMRefreshMysticalShop(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA2
+        self.SubCmd = 0x32
+        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 = 0xA2
+        self.SubCmd = 0x32
+        return
+
+    def GetLength(self):
+        return sizeof(tagCMRefreshMysticalShop)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A2 32 神秘商店刷新 //tagCMRefreshMysticalShop:
+                                Cmd:%s,
+                                SubCmd:%s
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd
+                                )
+        return DumpString
+
+
+m_NAtagCMRefreshMysticalShop=tagCMRefreshMysticalShop()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMRefreshMysticalShop.Cmd,m_NAtagCMRefreshMysticalShop.SubCmd))] = m_NAtagCMRefreshMysticalShop
+
+
+#------------------------------------------------------
 # A2 14 刷新定时神秘商店物品#tagCMRefreshShopItem
 
 class  tagCMRefreshShopItem(Structure):
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index 5f86b1a..2553bbd 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -20127,6 +20127,117 @@
 
 
 #------------------------------------------------------
+# A8 16 神秘商店商品信息 #tagMCMysticalShopInfo
+
+class  tagMCMysticalShopGoods(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("GoodsID", c_int),    # 商品ID
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        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.GoodsID = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCMysticalShopGoods)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A8 16 神秘商店商品信息 //tagMCMysticalShopInfo:
+                                GoodsID:%d
+                                '''\
+                                %(
+                                self.GoodsID
+                                )
+        return DumpString
+
+
+class  tagMCMysticalShopInfo(Structure):
+    Head = tagHead()
+    RefreshCnt = 0    #(WORD RefreshCnt)// 刷新次数
+    Count = 0    #(BYTE Count)// 商品数
+    GoodsList = list()    #(vector<tagMCMysticalShopGoods> GoodsList)// 商品信息
+    data = None
+
+    def __init__(self):
+        self.Clear()
+        self.Head.Cmd = 0xA8
+        self.Head.SubCmd = 0x16
+        return
+
+    def ReadData(self, _lpData, _pos=0, _Len=0):
+        self.Clear()
+        _pos = self.Head.ReadData(_lpData, _pos)
+        self.RefreshCnt,_pos = CommFunc.ReadWORD(_lpData, _pos)
+        self.Count,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        for i in range(self.Count):
+            temGoodsList = tagMCMysticalShopGoods()
+            _pos = temGoodsList.ReadData(_lpData, _pos)
+            self.GoodsList.append(temGoodsList)
+        return _pos
+
+    def Clear(self):
+        self.Head = tagHead()
+        self.Head.Clear()
+        self.Head.Cmd = 0xA8
+        self.Head.SubCmd = 0x16
+        self.RefreshCnt = 0
+        self.Count = 0
+        self.GoodsList = list()
+        return
+
+    def GetLength(self):
+        length = 0
+        length += self.Head.GetLength()
+        length += 2
+        length += 1
+        for i in range(self.Count):
+            length += self.GoodsList[i].GetLength()
+
+        return length
+
+    def GetBuffer(self):
+        data = ''
+        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+        data = CommFunc.WriteWORD(data, self.RefreshCnt)
+        data = CommFunc.WriteBYTE(data, self.Count)
+        for i in range(self.Count):
+            data = CommFunc.WriteString(data, self.GoodsList[i].GetLength(), self.GoodsList[i].GetBuffer())
+        return data
+
+    def OutputString(self):
+        DumpString = '''
+                                Head:%s,
+                                RefreshCnt:%d,
+                                Count:%d,
+                                GoodsList:%s
+                                '''\
+                                %(
+                                self.Head.OutputString(),
+                                self.RefreshCnt,
+                                self.Count,
+                                "..."
+                                )
+        return DumpString
+
+
+m_NAtagMCMysticalShopInfo=tagMCMysticalShopInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCMysticalShopInfo.Head.Cmd,m_NAtagMCMysticalShopInfo.Head.SubCmd))] = m_NAtagMCMysticalShopInfo
+
+
+#------------------------------------------------------
 # A8 06 通知神秘限购商品时间 #tagMCMysticalShopTimeInfo
 
 class  tagMCMysticalShopTime(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
index 10deea2..b8f9f74 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
@@ -68,7 +68,7 @@
 Writer = wdb
 Releaser = wdb
 RegType = 0
-RegisterPackCount = 2
+RegisterPackCount = 3
 
 PacketCMD_1=0xA2
 PacketSubCMD_1=0x01
@@ -78,6 +78,10 @@
 PacketSubCMD_2=0x11
 PacketCallFunc_2=OnSellManyItem
 
+PacketCMD_3=0xA2
+PacketSubCMD_3=0x32
+PacketCallFunc_3=OnMysticalShopRefresh
+
 ;物品管理
 [ItemControler]
 ScriptName = Item\ItemControler.py
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 5d7dcb6..3fcf716 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3129,6 +3129,7 @@
 Def_PlayerKey_ComboBuffProcessState = "ComboBuffProcessState"    #持续性buff连击处理状态
 Def_PlayerKey_LvAwardQueryState = 'LvAwardQueryState'  # 等级奖励领奖查询状态
 Def_PlayerKey_StoreQueryState = 'StoreQueryState'  # 商店全服购买次数查询状态
+Def_PlayerKey_MysticalShopLastTime = 'MysticalShopLastTime'  # 神秘商店刷新时间
 #===============================================================================
 # # 持续性buff伤害处理连击技能ID列表
 # # 因为释放一次技能后一段时间内是持续性的, 故连接判断效果仅处理一次, 持续时间内均受此效果影响, 不重复处理连击
@@ -3516,6 +3517,9 @@
 Def_PDict_CollNpcIDCollTime = "CollNpcIDCollTime_%s"   # 采集NPCID对应每日对应采集次数,%sNPCID
 Def_PDict_ShopItemDayBuyCnt = "ShopItemDayBuyCnt_%s"   # 商店NPC商品已购买次数,itemIndex
 Def_PDict_ShopItemStartTime = "ShopItemStartTime_%s"   # 神秘限购商品开卖时间,itemIndex
+Def_PDict_MysticalShopGoods = "MysticalShopGoods_%s"   # 神秘商店商品ID,索引
+Def_PDict_MysticalShopRefreshCnt = "MysticalShopRefreshCnt"   # 神秘商店已手动刷新次数
+Def_PDict_MysticalShopLVRefreshCnt = "MysticalShopLVRefreshCnt"   # 神秘商店等级段刷新次数
 Def_PDict_ShopItemBuyCnt = "ShopItemBuyCnt_%s_%s"   # 自定义商品已购买次数,(shopID, itemIndex)
 Def_PDict_ShopItemOpenState = "ShopItemOpenState_%s_%s"   # 自定义神秘商店物品开启状态,(shopID, keyNum)
 Def_PDict_TimeShopRefreshCnt = "TimeShopRefreshCnt_%s"   # 自定义神秘商店已手动刷新次数,(shopID)
@@ -4652,6 +4656,7 @@
 Def_Cost_FBGatherSoulBoss, # 聚魂副本BOSS召唤 40
 Def_Cost_CrossRealmPK, # 跨服PK
 Def_Cost_LuckyTreasure, #幸运鉴宝
+Def_Cost_MysteryShopRefresh, # 神秘商店刷新
 #-----------以下为暂时没用的,先不删除,如有新增消费点则放在这些之前------------
 Def_Cost_RefreshArrestTask, # 刷新悬赏任务
 Def_Cost_OffLineExp, # 兑换离线经验
@@ -4668,7 +4673,7 @@
 Def_Cost_Trade, # 交易
 Def_Cost_Rename, # 改名
 Def_Cost_SkillLvUp, # 技能升级
-) = range(2000, 2000 + 58)
+) = range(2000, 2000 + 59)
 
 Def_Cost_Reason_SonKey = "reason_name_son" # 消费点原因子类说明key
 
@@ -4754,6 +4759,7 @@
 Def_Cost_FBGatherSoulBoss:"FBGatherSoulBoss",
 Def_Cost_CrossRealmPK:"CrossRealmPK",
 Def_Cost_LuckyTreasure:"LuckyTreasure",
+Def_Cost_MysteryShopRefresh:"MysteryShopRefresh",
 }
 ## -----------------------------------------------------
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index 0728bf6..084a3af 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -5015,6 +5015,54 @@
 
 
 #------------------------------------------------------
+# A2 32 神秘商店刷新 #tagCMRefreshMysticalShop
+
+class  tagCMRefreshMysticalShop(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("Cmd", c_ubyte),
+                  ("SubCmd", c_ubyte),
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        self.Cmd = 0xA2
+        self.SubCmd = 0x32
+        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 = 0xA2
+        self.SubCmd = 0x32
+        return
+
+    def GetLength(self):
+        return sizeof(tagCMRefreshMysticalShop)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A2 32 神秘商店刷新 //tagCMRefreshMysticalShop:
+                                Cmd:%s,
+                                SubCmd:%s
+                                '''\
+                                %(
+                                self.Cmd,
+                                self.SubCmd
+                                )
+        return DumpString
+
+
+m_NAtagCMRefreshMysticalShop=tagCMRefreshMysticalShop()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMRefreshMysticalShop.Cmd,m_NAtagCMRefreshMysticalShop.SubCmd))] = m_NAtagCMRefreshMysticalShop
+
+
+#------------------------------------------------------
 # A2 14 刷新定时神秘商店物品#tagCMRefreshShopItem
 
 class  tagCMRefreshShopItem(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 5f86b1a..2553bbd 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -20127,6 +20127,117 @@
 
 
 #------------------------------------------------------
+# A8 16 神秘商店商品信息 #tagMCMysticalShopInfo
+
+class  tagMCMysticalShopGoods(Structure):
+    _pack_ = 1
+    _fields_ = [
+                  ("GoodsID", c_int),    # 商品ID
+                  ]
+
+    def __init__(self):
+        self.Clear()
+        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.GoodsID = 0
+        return
+
+    def GetLength(self):
+        return sizeof(tagMCMysticalShopGoods)
+
+    def GetBuffer(self):
+        return string_at(addressof(self), self.GetLength())
+
+    def OutputString(self):
+        DumpString = '''// A8 16 神秘商店商品信息 //tagMCMysticalShopInfo:
+                                GoodsID:%d
+                                '''\
+                                %(
+                                self.GoodsID
+                                )
+        return DumpString
+
+
+class  tagMCMysticalShopInfo(Structure):
+    Head = tagHead()
+    RefreshCnt = 0    #(WORD RefreshCnt)// 刷新次数
+    Count = 0    #(BYTE Count)// 商品数
+    GoodsList = list()    #(vector<tagMCMysticalShopGoods> GoodsList)// 商品信息
+    data = None
+
+    def __init__(self):
+        self.Clear()
+        self.Head.Cmd = 0xA8
+        self.Head.SubCmd = 0x16
+        return
+
+    def ReadData(self, _lpData, _pos=0, _Len=0):
+        self.Clear()
+        _pos = self.Head.ReadData(_lpData, _pos)
+        self.RefreshCnt,_pos = CommFunc.ReadWORD(_lpData, _pos)
+        self.Count,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        for i in range(self.Count):
+            temGoodsList = tagMCMysticalShopGoods()
+            _pos = temGoodsList.ReadData(_lpData, _pos)
+            self.GoodsList.append(temGoodsList)
+        return _pos
+
+    def Clear(self):
+        self.Head = tagHead()
+        self.Head.Clear()
+        self.Head.Cmd = 0xA8
+        self.Head.SubCmd = 0x16
+        self.RefreshCnt = 0
+        self.Count = 0
+        self.GoodsList = list()
+        return
+
+    def GetLength(self):
+        length = 0
+        length += self.Head.GetLength()
+        length += 2
+        length += 1
+        for i in range(self.Count):
+            length += self.GoodsList[i].GetLength()
+
+        return length
+
+    def GetBuffer(self):
+        data = ''
+        data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+        data = CommFunc.WriteWORD(data, self.RefreshCnt)
+        data = CommFunc.WriteBYTE(data, self.Count)
+        for i in range(self.Count):
+            data = CommFunc.WriteString(data, self.GoodsList[i].GetLength(), self.GoodsList[i].GetBuffer())
+        return data
+
+    def OutputString(self):
+        DumpString = '''
+                                Head:%s,
+                                RefreshCnt:%d,
+                                Count:%d,
+                                GoodsList:%s
+                                '''\
+                                %(
+                                self.Head.OutputString(),
+                                self.RefreshCnt,
+                                self.Count,
+                                "..."
+                                )
+        return DumpString
+
+
+m_NAtagMCMysticalShopInfo=tagMCMysticalShopInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCMysticalShopInfo.Head.Cmd,m_NAtagMCMysticalShopInfo.Head.SubCmd))] = m_NAtagMCMysticalShopInfo
+
+
+#------------------------------------------------------
 # A8 06 通知神秘限购商品时间 #tagMCMysticalShopTimeInfo
 
 class  tagMCMysticalShopTime(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
index 2573564..8fb8a5e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
@@ -71,6 +71,8 @@
 import random
 import math
 import time
+
+g_mysticalShopDict = {} #神秘商店{等级范围:[等级段,{金钱类型:库}]}
 #---------------------------------------------------------------------
 ##开始交易
 # @param curPlayer 玩家实例
@@ -200,9 +202,10 @@
             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuperGiftHasOpen, 1)
             
     
-    SyncMysticalShopInfo(curPlayer)
+    SyncMysticalLimitShopInfo(curPlayer)
     SyncShopItemTodayBuyCount(curPlayer)
     SyncSuperGiftInfo(curPlayer)
+    SyncMysticalShopInfo(curPlayer)
     return
 
 ##商店物品OnDay
@@ -213,6 +216,10 @@
         UpdataSuperGiftTime(curPlayer, True)
         OSSaleOpenMail(curPlayer)
         refreshType = [3]
+        #神秘商店刷新次数重置
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, 0)
+        SyncMysticalShopInfo(curPlayer)
+        
     elif onEventType == ShareDefine.Def_OnEventTypeEx:
         refreshType = [4]
         openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
@@ -305,7 +312,7 @@
         SyncShopItemTodayBuyCount(curPlayer, syncIndexList, True)
     return
 
-def MysticalShopOpen(curPlayer, befLV, aftLV):
+def MysticalLimitShopOpen(curPlayer, befLV, aftLV):
     ##神秘限购开启
     ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('Store', {'ShopType':16}, True)
     if not ipyDataList:
@@ -320,10 +327,10 @@
             syncGoodsList.append(goodsID)
             GameWorld.DebugLog('神秘限购商品%s 开卖'%goodsID, curPlayer.GetID())
     if syncGoodsList:
-        SyncMysticalShopInfo(curPlayer)
+        SyncMysticalLimitShopInfo(curPlayer)
     return
 
-def SyncMysticalShopInfo(curPlayer):
+def SyncMysticalLimitShopInfo(curPlayer):
     ##神秘限购通知
     packData = ChPyNetSendPack.tagMCMysticalShopTimeInfo()
     packData.ShopTimeList = []
@@ -348,6 +355,125 @@
     NetPackCommon.SendFakePack(curPlayer, packData)
     return
 
+def CheckMysticalShopRefresh(curPlayer, tick):
+    ##神秘商店刷新
+    createRoleTime = curPlayer.GetCreateRoleTime()
+    diffTime = GameWorld.GetCurrentTime() - GameWorld.GetDateTimeByStr(createRoleTime, ChConfig.TYPE_Time_Format)
+    pastSeconds = diffTime.days*24*60*60 + diffTime.seconds
+    refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
+    if pastSeconds % refreshTime == 0:
+        __DoMysticalShopRefresh(curPlayer, True, tick)
+    return
+
+#// A2 32 神秘商店刷新 #tagCMRefreshMysticalShop
+#struct    tagCMRefreshMysticalShop
+#{
+#    tagHead        Head;
+#};
+def OnMysticalShopRefresh(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    __DoMysticalShopRefresh(curPlayer, False, tick)
+    return
+
+def __DoMysticalShopRefresh(curPlayer, isFree, tick):
+    global g_mysticalShopDict #{等级范围:[等级段,{金钱类型:库}]}
+    
+    lastTime = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MysticalShopLastTime)
+    if lastTime and tick - lastTime < 1000:
+        #GameWorld.DebugLog('神秘商店刷新,过于频繁!')
+        return
+    curPlayer.SetDict(ChConfig.Def_PlayerKey_MysticalShopLastTime, tick)
+    if not g_mysticalShopDict:
+        ipyMgr= IpyGameDataPY.IPY_Data()
+        for i in xrange(ipyMgr.GetMysteryShopCount()):
+            ipyData = ipyMgr.GetMysteryShopByIndex(i)
+            lvRange = ipyData.GetLVRange()
+            goodsID = ipyData.GetGoodsID()
+            goodsIpyData = IpyGameDataPY.GetIpyGameData('Store', goodsID)
+            moneyType = goodsIpyData.GetMoneyType()
+            weight = goodsIpyData.GetLimitValue()
+            lvkey = tuple(lvRange)
+            if lvkey not in g_mysticalShopDict:
+                g_mysticalShopDict[lvkey] = [lvkey[0], {}]
+                weightDict = {}
+            if moneyType not in g_mysticalShopDict[lvkey][1]:
+                g_mysticalShopDict[lvkey][1][moneyType] = []
+            weightDict[moneyType] = weightDict.get(moneyType, 0) + weight
+            g_mysticalShopDict[lvkey][1][moneyType].append([weightDict[moneyType], goodsID])
+            
+    playerLV = curPlayer.GetLV()
+    curLVDan, shopDict = GameWorld.GetDictValueByRangeKey(g_mysticalShopDict, playerLV)
+    if not shopDict:
+        return
+    maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
+    goldGoodsCnt =GameWorld.GetResultByRandomList(IpyGameDataPY.GetFuncEvalCfg('MysteryShopGoods', 2))
+    if not goldGoodsCnt:
+        return
+    specialGoodsID = 0 #必出的商品ID
+    if not isFree:
+        #优先道具,再仙玉
+        itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
+        costItemID = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 1)
+        costItemCntDict = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 2)
+        curRefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
+        cntList = [int(cnt) for cnt in costItemCntDict.keys()]
+        cntList.sort()
+        costItemCnt = costItemCntDict[str(cntList[-1])]
+        for cnt in cntList:
+            if curRefreshCnt <= cnt:
+                costItemCnt = costItemCntDict[str(cnt)]
+                break
+        enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(costItemID, itemPack, costItemCnt)
+        costGold = 0
+        if not enough:
+            costGold = lackCnt * IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 3)
+            if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_MysteryShopRefresh):
+                return
+        ItemCommon.ReduceItem(curPlayer, itemPack, indexList, costItemCnt, False, "MysteryShopRefresh")
+        curLVRefreshData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopLVRefreshCnt)
+        curLVRefreshCnt, lvDan = curLVRefreshData / 10000, curLVRefreshData % 10000 
+        updLVRefreshCnt = 1 if curLVDan != lvDan else curLVRefreshCnt + 1 #等级段变更,重置该等级段的刷新次数
+        updLVRefreshData = min(updLVRefreshCnt * 10000+curLVDan, ChConfig.Def_UpperLimit_DWord)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopLVRefreshCnt, updLVRefreshData)
+        specialRefreshCfg = IpyGameDataPY.GetFuncEvalCfg('MysteryShopRefresh', 5)
+        if curLVDan in specialRefreshCfg and updLVRefreshCnt == specialRefreshCfg[curLVDan][0]:
+            specialGoodsID = specialRefreshCfg[curLVDan][1]
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopRefreshCnt, curRefreshCnt+1)
+        
+    goldGoodsCnt = min(goldGoodsCnt, maxCnt)
+    sliverGoodsCnt = maxCnt - goldGoodsCnt
+    goodsResultList = []
+    if goldGoodsCnt:
+        goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Gold_Money, []), goldGoodsCnt, [])
+    if sliverGoodsCnt:
+        goodsResultList += GameWorld.GetResultByRandomListEx(shopDict.get(IPY_GameWorld.TYPE_Price_Silver_Money, []), sliverGoodsCnt, [])
+    if specialGoodsID and specialGoodsID not in goodsResultList:
+        goodsResultList[0] = specialGoodsID
+        GameWorld.DebugLog('神秘商店刷新特殊规则,等级段:%s,updLVRefreshCnt=%s,specialGoodsID=%s'%(curLVDan, updLVRefreshCnt, specialGoodsID))
+    
+    GameWorld.DebugLog('神秘商店刷新isFree=%s,goldGoodsCnt=%s,sliverGoodsCnt=%s,goodsResultList=%s'%(isFree, goldGoodsCnt, sliverGoodsCnt, goodsResultList))
+    for i in xrange(maxCnt):
+        goodsID = goodsResultList[i] if i < len(goodsResultList) else 0
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MysticalShopGoods % i, goodsID)
+    #通知
+    SyncMysticalShopInfo(curPlayer)
+    return
+
+def SyncMysticalShopInfo(curPlayer):
+    ##神秘商店通知
+    packData = ChPyNetSendPack.tagMCMysticalShopInfo()
+    packData.RefreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopRefreshCnt)
+    packData.GoodsList = []
+    maxCnt = IpyGameDataPY.GetFuncCfg('MysteryShopGoods', 1)
+    for i in xrange(maxCnt):
+        goodsID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MysticalShopGoods % i)
+        goodsInfo = ChPyNetSendPack.tagMCMysticalShopGoods()
+        goodsInfo.GoodsID = goodsID
+        packData.GoodsList.append(goodsInfo)
+    packData.Count = len(packData.GoodsList)
+    NetPackCommon.SendFakePack(curPlayer, packData)
+    return
+
 ## 回购物品
 #  @param None
 #  @return None
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 34c03c0..fb00bb8 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1367,6 +1367,11 @@
                         ("BYTE", "IsBind", 0),
                         ("DWORD", "Weight", 0),
                         ),
+
+                "MysteryShop":(
+                        ("list", "LVRange", 0),
+                        ("DWORD", "GoodsID", 0),
+                        ),
                 }
 
 
@@ -4174,6 +4179,17 @@
     def GetItemCnt(self): return self.ItemCnt # 物品数量
     def GetIsBind(self): return self.IsBind # 是否绑定
     def GetWeight(self): return self.Weight # 权重
+
+# 神秘商店表
+class IPY_MysteryShop():
+    
+    def __init__(self):
+        self.LVRange = []
+        self.GoodsID = 0
+        return
+        
+    def GetLVRange(self): return self.LVRange # 等级范围
+    def GetGoodsID(self): return self.GoodsID # 商城表ID
 
 
 def Log(msg, playerID=0, par=0):
@@ -4465,6 +4481,8 @@
         self.ipyActLuckyTreasureLen = len(self.ipyActLuckyTreasureCache)
         self.ipyLuckyTreasureTemplateCache = self.__LoadFileData("LuckyTreasureTemplate", IPY_LuckyTreasureTemplate)
         self.ipyLuckyTreasureTemplateLen = len(self.ipyLuckyTreasureTemplateCache)
+        self.ipyMysteryShopCache = self.__LoadFileData("MysteryShop", IPY_MysteryShop)
+        self.ipyMysteryShopLen = len(self.ipyMysteryShopCache)
         Log("IPY_FuncConfig count=%s" % len(self.ipyFuncConfigDict))
         Log("IPY_DataMgr InitOK!")
         return
@@ -4897,6 +4915,8 @@
     def GetActLuckyTreasureByIndex(self, index): return self.ipyActLuckyTreasureCache[index]
     def GetLuckyTreasureTemplateCount(self): return self.ipyLuckyTreasureTemplateLen
     def GetLuckyTreasureTemplateByIndex(self, index): return self.ipyLuckyTreasureTemplateCache[index]
+    def GetMysteryShopCount(self): return self.ipyMysteryShopLen
+    def GetMysteryShopByIndex(self, index): return self.ipyMysteryShopCache[index]
 
 IPYData = IPY_DataMgr()
 def IPY_Data(): return IPYData
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index d174759..91184a0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -4003,7 +4003,7 @@
             # 记录开服活动冲级数据
             OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_LV, curPlayer.GetLV())
             #神秘限购
-            FunctionNPCCommon.MysticalShopOpen(curPlayer, befLV, aftLV)
+            FunctionNPCCommon.MysticalLimitShopOpen(curPlayer, befLV, aftLV)
         #不需要做升级任务, 设置玩家经验
         SetPlayerTotalExp(curPlayer, curTotalExp) 
         return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py
index c0cb9f9..a531409 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py
@@ -54,7 +54,7 @@
 import PlayerSuccess
 import CrossPlayerData
 import PassiveBuffEffMng
-import PlayerFamilyRedPacket
+import FunctionNPCCommon
 import FormulaControl
 import PlayerGoldGift
 import PlayerFlashSale
@@ -1276,6 +1276,8 @@
     PlayerFlashSale.ProcessFlashSaleMail(curPlayer, tick)
     #地图经验
     ProcessAreaExp(curPlayer, tick)
+    #神秘商店刷新
+    FunctionNPCCommon.CheckMysticalShopRefresh(curPlayer, tick)
     #跨服数据同步,放最后
     CrossPlayerData.ProcessCrossPlayer(curPlayer, tick)
     return

--
Gitblit v1.8.0