1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package FunctionNPCCommon
# @todo: ¹¦ÄÜNPC¹ÜÀíÆ÷
#
# @author: panwei
# @date 2010-4-26
# @version 4.4
#
# @note: 
#---------------------------------------------------------------------
# @change: "2013-04-18 17:00" wdb ÎïÆ·ÑÕɫʹÓÃÐÞ¸Ä
# @change: "2013-04-26 16:00" wdb npcÉ̵êÐÞ¸Ä
# @change: "2013-05-03 17:00" wdb npcÉ̵êÅä±í·½Ê½ÐÞ¸Ä
# @change: "2013-05-20 15:00" wdb ×°±¸¸½¼ÓÊôÐÔ½Ó¿ÚÐÞ¸Ä
# @change: "2013-05-30 10:30" wdb ×°±¸±¦Ê¯ÏâǶµ÷Õû
# @change: "2013-07-19 20:00" Alee Ìí¼Ó»Ø¹º
# @change: "2013-07-22 17:00" Alee ÎïÆ·¿É°´ÊýÁ¿¹ºÂò
# @change: "2013-10-12 21:10" Alee ÏµÍ³Ìáʾ
# @change: "2013-10-22 11:10" Alee ÎïÆ·¼¼ÄÜÔöǿЧ¹û,ͳһº¯ÊýEquipAddAdditionEx
# @change: "2013-11-08 22:30" Alee É̳ÇÌí¼Ó´ò¿×
# @change: "2013-11-19 11:00" hxp Ð޸ijöÊÛÎïÆ·ÅжϽðÇ®ÉÏÏÞÂß¼­
# @change: "2014-01-16 13:54" xmnathan Õ½ÃËÉ̳ǹºÂò
# @change: "2014-01-28 00:55" Alee ¶ñħÉ̵êĬÈÏ׿ԽºÍÌ××°
# @change: "2014-02-12 14:00" Alee È¡ÏûºìÃû¹ºÂò³Í·£
# @change: "2014-04-07 11:30" Alee ·â°üDWORDµ¼Ö½ӿÚint±¨´í£¬·À·¶·¶Î§¹ý´ó
# @change: "2014-05-05 15:00" xmnathan Ì滻ϵͳÌáʾ
# @change: "2014-05-21 17:25" xcc Ôö¼Óħ·½Ñ°±¦»ý·Ö¶Ò»»ÎïÆ·¹¦ÄÜ
# @change: "2014-06-05 15:30" hxp É̵êNPCÎïÆ·¹ºÂòÔö¼ÓÿÈտɹºÂò´ÎÊýÉÏÏÞÖ§³Ö
# @change: "2014-08-04 16:00" Alee Ì××°ÎïÆ·É̵êÐÞ¸Ä
# @change: "2014-08-07 20:40" Alee ±¦²Ø»ý·Ö¶Ò»»×¿Ô½ÊôÐÔ×°±¸¹Ì¶¨2ÌõÊôÐÔ
# @change: "2014-10-20 16:20" Alee ¶Ò»»Ì××°3׿Խ
# @change: "2014-11-05 15:00" Alee É̵깺Âò°ó¶¨ÐÞ¸Ä
# @change: "2014-12-11 16:30" hxp É̵ê¶Ò»»×°±¸Ôö¼ÓÖ§³ÖÅäÖÃ×°±¸¶ÔӦ׿ԽÌõÊý
# @change: "2015-01-14 00:30" hxp Ôö¼ÓÎïÆ·±ä¸üʼþ»ã±¨
# @change: "2015-01-14 16:40" ljd Ôö¼ÓÎïÆ·¶Ò»»É̵ê
# @change: "2015-01-27 10:50" ljd Ôö¼Ó×°±¸ÎïÆ·À´Ô´±ê¼Ç
# @change: "2015-04-03 18:00" hxp ·À·¶»ØÊÕÕ¾Òì³£Çé¿öÎïÆ·Ïûʧ¶øÃ»ÓÐÖØÖñê¼Çλµ¼ÖÂÊýÖµÔ½½ç
# @change: "2015-04-16 19:10" ljd É̵긶Ǯʱ´«ÈëÖ§¸¶ÀàÐÍ
# @change: "2015-04-27 22:00" hxp Ôö¼ÓBuyItemÁ÷Ïò
# @change: "2016-07-20 14:30" hxp »õ±ÒÖ§¸¶Á÷ÏòÕûºÏ
# @change: "2016-08-04 18:00" hxp ³öÊۻعº¼Û¸ñÐÞ¸Ä
#---------------------------------------------------------------------
#"""Version = 2016-08-04 18:00"""
#---------------------------------------------------------------------
 
import ChConfig
import GameWorld
import NetPackCommon
import ItemControler
import ChPyNetSendPack
import PlayerControl
import IpyGameDataPY
import ItemCommon
import ObjPool
 
# ÖØÖÃÀàÐÍ
ResetType_Day = 1
ResetType_Week = 2
 
# ½âËøÀàÐÍ
UnlockType_FamilyLV = 1 # ¹«»áµÈ¼¶
UnlockType_RandRefresh = 2 # Ëæ»úˢнâËø
 
# ²¿·ÖÉ̵êÀàÐÍ
ShopType_HeroSoul = 3 # ½«»ê
 
RefreshShopTypeList = [ShopType_HeroSoul]
 
def DoShopOpen(curPlayer):
    for shopType in RefreshShopTypeList:
        DoRandRefreshShopItem(curPlayer, shopType, sysRefresh=True)
    return
 
def ShopItemOnLogin(curPlayer):
    SyncShopItemBuyCntInfo(curPlayer)
    for shopType in RefreshShopTypeList:
        SyncShopRefreshItemInfo(curPlayer, shopType)
    return
 
def ShopItemOnDay(curPlayer):
    for shopType in RefreshShopTypeList:
        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopRefreshCnt % shopType):
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopRefreshCnt % shopType, 0)
        SyncShopRefreshItemInfo(curPlayer, shopType)
        
    ResetShopItemBuyCount(curPlayer, [ResetType_Day])
    return
 
def ShopItemOnWeek(curPlayer):
    ResetShopItemBuyCount(curPlayer, [ResetType_Week])
    return
 
def ResetShopItemBuyCount(curPlayer, resetTypeList):
    #@param resetTypeList: ÐèÒªÖØÖõÄÀàÐÍÁбí
    if not resetTypeList:
        # Ôݶ¨±ØÐëÖ¸¶¨ÀàÐÍÁÐ±í£¬·ÀÖ¹ÖÕÉíÏÞ¹ºµÄÎó±»ÖØÖÃ
        return
    syncIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetStoreCount()):
        shopItem = ipyDataMgr.GetStoreByIndex(i)
        if not shopItem.GetLimitCnt():
            continue
        if shopItem.GetResetType() not in resetTypeList:
            continue
        shopID = shopItem.GetID()
        curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
        if curBuyCnt <= 0:
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopBuyCnt % shopID, 0)
        syncIDList.append(shopID)
    if syncIDList:
        SyncShopItemBuyCntInfo(curPlayer, syncIDList)
    return
 
def ResetShopItemBuyCountByShopType(curPlayer, shopTypeList):
    ##¸ù¾ÝÉ̵êÀàÐÍÖØÖÃÉ̵êÏÞ¹ºÎïÆ·´ÎÊý
    if not shopTypeList:
        return
    syncIDList = []
    for shopType in shopTypeList:
        ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True)
        if not ipyDataList:
            continue
        for ipyData in ipyDataList:
            if not ipyData.GetLimitCnt():
                continue
            shopID = ipyData.GetID()
            curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
            if curBuyCnt <= 0:
                continue
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopBuyCnt % shopID, 0)
            syncIDList.append(shopID)
    if syncIDList:
        SyncShopItemBuyCntInfo(curPlayer, syncIDList)
    return
 
def PayAutoBuyItem(curPlayer, lackItemDict, priceType, costType=ChConfig.Def_Cost_Unknown, infoDict={}, isCheck=False, shopItemIndexDict=None):
    ''' Ö§¸¶×Ô¶¯¹ºÂòÎïÆ·ÏûºÄ£¬´ÓÉ̳ÇÖйºÂò£¬Ö±½Ó¿ÛÇ®£¬²»²úÉúÎïÆ·
            Ò»°ãÓÃÓÚ»ù´¡É̵ê×Ô¶¯¹ºÂòÎïÆ·£¬²»¿¼ÂǸ´ÔÓµÄÏÞ¹ºÂß¼­
    @param isCheck: ÊÇ·ñÖ»ÊǼì²é£¬²»Ö´ÐÐʵ¼ÊÏûºÄÂß¼­
    @param shopItemIndexDict: Ö¸¶¨¹ºÂòµÄÉÌÆ·¶ÔÓ¦É̳DZíÉÌÆ·IDË÷Òý×ֵ䣬Èç¹ûûÓÐÖ¸¶¨ÉÌÆ·Ë÷Òý£¬Ôò°´ÏûºÄµÄ¼Û¸ñÀàÐÍ×Ô¶¯ËÑË÷É̳DZí
    '''
    
    addLimitCountInfo = {}
    totalMoney = 0
    # ¼ÆËã×Ô¶¯¹ºÂòÏûºÄ
    for itemID, lackCnt in lackItemDict.items():
        if lackCnt <= 0:
            continue
        
        curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)
        if not curItem:
            return
        
        if shopItemIndexDict and itemID in shopItemIndexDict:
            shopID = shopItemIndexDict[itemID]
            ipyData = IpyGameDataPY.GetIpyGameData("Store", shopID)
        else:
            ipyData = ItemCommon.GetShopItemPriceIpyData(itemID, priceType)
        if not ipyData:
            return
        
        shopID = ipyData.GetID()
        shopType = ipyData.GetShopType()
        priceType = ipyData.GetMoneyType()
        itemMoney = ipyData.GetMoneyNum()
        limitBuyCnt = ipyData.GetLimitCnt()
        if limitBuyCnt:
            curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
            canBuyCnt = max(0, limitBuyCnt - curBuyCnt)
            if canBuyCnt < lackCnt:
                GameWorld.Log("×Ô¶¯¹ºÂò´ÎÊý²»×㣡shopType=%s,shopID=%s,itemID=%s,limitBuyCnt=%s,curBuyCnt=%s,canBuyCnt=%s < %s" 
                              % (shopType, shopID, itemID, limitBuyCnt, curBuyCnt, canBuyCnt, lackCnt), curPlayer.GetPlayerID())
                return
            addLimitCountInfo[shopID] = lackCnt
            
        totalMoney += (lackCnt * itemMoney)
        
    if totalMoney <= 0:
        return
    
    if isCheck:
        return PlayerControl.HaveMoney(curPlayer, priceType, totalMoney)
    
    GameWorld.DebugLog("¿Û³ý×Ô¶¯¹ºÂòÏûºÄ: lackItemDict=%s,priceType=%s,totalMoney=%s,costType=%s,addLimitCountInfo=%s" 
                       % (lackItemDict, priceType, totalMoney, costType, addLimitCountInfo), curPlayer.GetPlayerID())
    
    if not PlayerControl.PayMoney(curPlayer, priceType, totalMoney, costType, infoDict):
        return
    
    if addLimitCountInfo:
        syncIDList = []
        for shopID, lackCnt in addLimitCountInfo.items():
            curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopBuyCnt % shopID, curBuyCnt + lackCnt)
            syncIDList.append(shopID)
        SyncShopItemBuyCntInfo(curPlayer, syncIDList)
        
    return True
 
#// A3 10 ¹ºÂòÉ̳ÇÎïÆ· #tagCSBuyItem
#
#struct    tagCSBuyItem
#{
#    tagHead        Head;
#    DWORD        ShopID;        //ÉÌÆ·ID
#    DWORD        BuyCount;    //¹ºÂòÊýÁ¿
#};
def PyBuyItem(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    shopID = clientData.ShopID
    buyCount = clientData.BuyCount
    OnBuyItem(curPlayer, shopID, buyCount)
    return
 
def OnBuyItem(curPlayer, shopID, clientBuyCount):
    GameWorld.DebugLog("¹ºÂòÉ̳ÇÎïÆ·: shopID=%s,clientBuyCount=%s" % (shopID, clientBuyCount))
    if GameWorld.IsCrossServer():
        return
    if shopID <= 0 or clientBuyCount <= 0:
        return
    ipyData = IpyGameDataPY.GetIpyGameData("Store", shopID)
    if not ipyData:
        return
    shopType = ipyData.GetShopType()
    limitBuyCnt = ipyData.GetLimitCnt()
    if limitBuyCnt > 0:
        curBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
        canBuyCnt = max(0, limitBuyCnt - curBuyCnt)
        if canBuyCnt <= 0:
            GameWorld.DebugLog("ÉÌÆ·ÏÞ¹º´ÎÊýÒÑÂú ! shopType=%s,shopID=%s,curBuyCnt=%s < %s" % (shopType, shopID, curBuyCnt, limitBuyCnt))
            return
        if clientBuyCount > canBuyCnt:
            clientBuyCount = canBuyCnt
            
    itemID, itemCount, isBind = ipyData.GetItemID(), ipyData.GetItemCnt(), 0
    itemListEx = ipyData.GetItemListEx()
    totalItemList = []
    if itemID:
        totalItemList.append([itemID, itemCount * clientBuyCount, isBind])
    for itemIDEx, itemCountEx, isBindEx in itemListEx:
        totalItemList.append([itemIDEx, itemCountEx * clientBuyCount, isBindEx])
    if not totalItemList:
        GameWorld.ErrLog("Store shop item error! shopType=%s,shopID=%s" % (shopType, shopID), curPlayer.GetPlayerID())
        return
    mainItemID = totalItemList[0][0]
    GameWorld.DebugLog("shopType=%s,shopID=%s,totalItemList=%s" % (shopType, shopID, totalItemList))
    
    # ¼ì²éÊÇ·ñ½âËøÉÌÆ·¹ºÂò
    if not CheckBuyItemUnlock(curPlayer, shopType, shopID, mainItemID, ipyData):
        GameWorld.Log("Store shop item lock! shopID=%s,shopID=%s" % (shopType, shopID), curPlayer.GetPlayerID())
        return
    
    priceType, itemPrice = ipyData.GetMoneyType(), ipyData.GetMoneyNum()
    itemPrice *= clientBuyCount
    #if not PlayerControl.HaveMoney(curPlayer, priceType, itemPrice):
    #    return
    
    infoDict = {"TotalItemList":totalItemList, "ClientBuyCount":clientBuyCount, "ShopType":shopType,
                "ShopID":shopID, ChConfig.Def_Cost_Reason_SonKey:mainItemID}
    if priceType and itemPrice and not PlayerControl.PayMoney(curPlayer, priceType, itemPrice, ChConfig.Def_Cost_BuyStoreItem, infoDict, clientBuyCount):
        return
    
    # ½ñÈÕ¹ºÂò´ÎÊý+1
    if limitBuyCnt > 0:
        updBuyCnt = min(curBuyCnt + clientBuyCount, ChConfig.Def_UpperLimit_DWord)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopBuyCnt % shopID, updBuyCnt)
        GameWorld.DebugLog("¸üÐÂÉ̳ÇÎïÆ·ÏÞ¹º´ÎÊý: shopID=%s,curBuyCnt=%s,clientBuyCount=%s,updBuyCnt=%s/%s" 
                           % (shopID, curBuyCnt, clientBuyCount, updBuyCnt, limitBuyCnt))
        SyncShopItemBuyCntInfo(curPlayer, [shopID])
        
    ItemControler.GivePlayerItemOrMail(curPlayer, totalItemList, event=["BuyItem", False, {}], notifyDataEx=shopID)
    return
 
def CheckBuyItemUnlock(curPlayer, shopType, shopID, mainItemID, ipyData):
    ## ¼ì²éÊÇ·ñ½âËøÉÌÆ·¹ºÂò
    # @return: ÊÇ·ñÒѽâËø¹ºÂò
    
    unlockType = ipyData.GetUnlockType()
    unlockValue = ipyData.GetUnlockValue()
    
    # ¹«»áµÈ¼¶½âËø
    if unlockType == UnlockType_FamilyLV:
        if not curPlayer.GetFamilyID():
            GameWorld.DebugLog("ÎÞ¹«»áÎÞ·¨¹ºÂò! shopID=%s" % shopID)
            return
        curFamilyLV = curPlayer.GetFamilyLV()
        if curFamilyLV <= 0:
            curFamilyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyLV)
        if curFamilyLV < unlockValue:
            GameWorld.DebugLog("¹«»áµÈ¼¶²»×ãÎÞ·¨¹ºÂò! shopID=%s,curFamilyLV=%s < %s" % (shopID, curFamilyLV, unlockValue))
            return
        
    # Ëæ»úˢнâËø
    elif unlockType == UnlockType_RandRefresh:
        if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ShopRandUnlock, shopID):
            GameWorld.DebugLog("¸ÃÉÌÆ·Ã»ÓÐËæ»ú½âËøÎÞ·¨¹ºÂò! shopID=%s" % shopID)
            return
        
    return True
 
#// A2 32 Ë¢ÐÂÉ̵ê #tagCSRefreshShop
#
#struct    tagCSRefreshShop
#{
#    tagHead        Head;
#    WORD        ShopType;
#};
def OnRefreshShop(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    shopType = clientData.ShopType
    DoRandRefreshShopItem(curPlayer, shopType)
    return
 
def DoRandRefreshShopItem(curPlayer, shopType, randCnt=0, sysRefresh=False):
    ## Ëæ»úË¢ÐÂÉ̵êÎïÆ·£¬ID²»Öظ´
    # @param randCnt: Ö¸¶¨ÒªËæ»ú½âËøµÄ¸öÊý
    
    ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True)
    if not ipyDataList:
        return
    
    shopIDWeightDict = {}
    randWeightList = []
    for ipyData in ipyDataList:
        if ipyData.GetUnlockType() != UnlockType_RandRefresh:
            continue
        shopID = ipyData.GetID()
        randWeight = ipyData.GetUnlockValue()
        randWeightList.append([randWeight, shopID])
        shopIDWeightDict[shopID] = randWeight
        
    if not randWeightList:
        GameWorld.ErrLog("¸ÃÉ̵êûÓпÉËæ»úˢнâËøµÄÉÌÆ·! shopType=%s" % shopType)
        return
    
    refreshCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopRefreshCnt % shopType)
    moneyType, moneyValue = 0, 0
    if shopType == ShopType_HeroSoul:
        randCnt = IpyGameDataPY.GetFuncCfg("StoreHeroSoul", 1)
        freeCnt = IpyGameDataPY.GetFuncCfg("StoreHeroSoul", 3)
        if not sysRefresh and refreshCnt >= freeCnt:
            moneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("StoreHeroSoul", 2)
            
    GameWorld.DebugLog("Ëæ»úË¢ÐÂÉ̵êÉÌÆ·: shopType=%s,randCnt=%s/%s,refreshCnt=%s,moneyType=%s,moneyValue=%s,sysRefresh=%s" 
                       % (shopType, randCnt, len(randWeightList), refreshCnt, moneyType, moneyValue, sysRefresh))
    
    if randCnt <= 0:
        return
    
    if moneyType and moneyValue and not PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, "RefreshShopItem"):
        return
    
    doCnt = randCnt * 10
    randShopIDList = []
    syncBuyCntIDList = []
    while randWeightList and len(randShopIDList) < randCnt and doCnt > 0:
        doCnt -= 1
        shopID = GameWorld.GetResultByWeightList(randWeightList)
        if not shopID:
            continue
        randShopIDList.append(shopID)
        randWeight = shopIDWeightDict.get(shopID, 0)
        if [randWeight, shopID] in randWeightList:
            randWeightList.remove([randWeight, shopID])
            
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_ShopRandUnlock, shopID, 1)
        if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID):
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopBuyCnt % shopID, 0)
            syncBuyCntIDList.append(shopID)
            
    GameWorld.DebugLog("Ëæ»úË¢ÐÂÉÌÆ·Êý: %s,%s" % (len(randShopIDList), randShopIDList))
    GameWorld.DebugLog("Ê£ÓàËø¶¨ÉÌÆ·Êý: %s,%s" % (len(randWeightList), randWeightList))
    
    # ÆäËûµÄÉèÖÃδ½âËø
    for _, shopID in randWeightList:
        GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_ShopRandUnlock, shopID, 0)
    if not sysRefresh:
        refreshCnt += 1
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShopRefreshCnt % shopType, refreshCnt)
        GameWorld.DebugLog("¸üÐÂË¢ÐÂÉ̵ê´ÎÊý=%s" % refreshCnt)
        
    if syncBuyCntIDList:
        SyncShopItemBuyCntInfo(curPlayer, syncBuyCntIDList)
    SyncShopRefreshItemInfo(curPlayer, shopType, randShopIDList)
    return
 
def SyncShopRefreshItemInfo(curPlayer, shopType, syncIDList=[]):
    ##ͬ²½Ë¢Ð½âËøµÄÉÌÆ·ÐÅÏ¢
    if not syncIDList:
        syncIDList = []
        ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True)
        if not ipyDataList:
            return
        for ipyData in ipyDataList:
            shopID = ipyData.GetID()
            if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ShopRandUnlock, shopID):
                continue
            syncIDList.append(shopID)
    if not syncIDList:
        return
    clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCShopRefreshItemInfo)
    clientPack.ShopType = shopType
    clientPack.RefreshCnt = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopRefreshCnt % shopType), 250)
    clientPack.ShopIDList = syncIDList
    clientPack.Count = len(clientPack.ShopIDList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
def SyncShopItemBuyCntInfo(curPlayer, syncIDList=[]):
    ##ͬ²½ÉÌÆ·¹ºÂò´ÎÊý
    
    objPool = ObjPool.GetPoolMgr()
    buyCntList = []
    if syncIDList:
        for shopID in syncIDList:
            buyInfo = objPool.acquire(ChPyNetSendPack.tagSCShopItemBuyCnt)
            buyInfo.ShopID = shopID
            buyInfo.BuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
            buyCntList.append(buyInfo)
    else:
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for i in xrange(ipyDataMgr.GetStoreCount()):
            shopItem = ipyDataMgr.GetStoreByIndex(i)
            if not shopItem.GetLimitCnt():
                continue
            shopID = shopItem.GetID()
            buyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShopBuyCnt % shopID)
            if buyCnt <= 0:
                continue
            buyInfo = objPool.acquire(ChPyNetSendPack.tagSCShopItemBuyCnt)
            buyInfo.ShopID = shopID
            buyInfo.BuyCnt = buyCnt
            buyCntList.append(buyInfo)
            
    if not buyCntList:
        return
    
    clientPack = objPool.acquire(ChPyNetSendPack.tagSCShopItemBuyCntInfo)
    clientPack.BuyCntList = buyCntList
    clientPack.Count = len(clientPack.BuyCntList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return