xdh
2019-01-22 b61fe6ed796dfeb1a7ed718d8099d6edb05f36f6
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Event.EventSrc.Operate_EquipStone
#
# @todo:×°±¸±¦Ê¯
# @author hxp
# @date 2017-07-29
# @version 1.0
#
# ÏêϸÃèÊö: ×°±¸±¦Ê¯
#
#-------------------------------------------------------------------------------
#"""Version = 2017-07-29 12:00"""
#-------------------------------------------------------------------------------
 
import GameWorld
import ItemCommon
import PlayerControl
import IPY_GameWorld
import ItemControler
import IpyGameDataPY
import ChConfig
import ChEquip
import OpenServerCampaign
import ChPyNetSendPack
import NetPackCommon
import DataRecordPack
import PlayerSuccess
import PlayerWeekParty
import ShareDefine
 
 
 
def OnLogin(curPlayer):
    ###µÇ¼·¢°üͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢
    Sycn_StoneHoleInfo(curPlayer)
    return
 
def GetAllStoneEquipIndexList():
    ###µÃµ½ËùÓпÉÏâǶ±¦Ê¯×°±¸Î»Áбí
    
    #»ñµÃ±¦Ê¯ÀàÐÍÊýÁ¿
    GemTypeCount = IpyGameDataPY.GetFuncCfg("GemTypeCount")
    #»ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î»
    stoneCanPlaceList = []      
    for stoneTypeIndex in xrange(1, GemTypeCount + 1):
        #Ñ­»·±¦Ê¯ÀàÐͶÔÓ¦µÄ×°±¸Î»
        stoneCanPlaceList += IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneTypeIndex, 1)
    
    return stoneCanPlaceList
 
def GetAllEquipPlaceHoleIndex():
    ### µÃµ½×°±¸Î»ËùÓп×λ
    gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
    maxEquipHoleCnt = len(gemOpenClassLVList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý
     
    gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
    maxHoleVipCnt = len(gemOpenVipList)# ×î´óVip¿ª·Å¿×Êý
    
    return range(maxEquipHoleCnt) + range(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxHoleVipCnt)
 
def GetEquipIndexStoneIDList(curPlayer, equipIndex):
    ### ×°±¸Î»¿×λ±¦Ê¯IDÁбí
    
    holeIndexList = GetAllEquipPlaceHoleIndex()
    holeStoneIDList = []
    for holeIndex in holeIndexList:
        stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex) [0]
        holeStoneIDList.append(stoneID)
    return holeStoneIDList
 
def GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex):
    '''»ñµÃ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢
    @return: stoneID, stoneIsBind
    '''
    #»ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢
    stoneInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex)) 
    #»ñȡװ±¸Î»¿×λÉϱ¦Ê¯ID
    stoneID = stoneInfo / ChConfig.Def_Stone_SaveStoneInfoXNumber
    #»ñȡװ±¸Î»¿×λÉϱ¦Ê¯ÊÇ·ñ°ó¶¨×´Ì¬
    stoneIsBind = stoneInfo % ChConfig.Def_Stone_SaveStoneInfoXNumber   
    return stoneID, stoneIsBind
 
def SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind):
    ### ±£´æ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex),
                                       changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind) 
    return
 
 
#//A3 04 ±¦Ê¯ÏâǶ»òÌæ»» #tagCMEquipEnchase
#struct    tagCMEquipEnchase
#{
#    tagHead        Head;
#    BYTE        EquipIndex;        //×°±¸Î»Ë÷Òý
#    BYTE        StoneIndex;        //±¦Ê¯ËùÔÚÍæ¼ÒÎïÆ·±³°üË÷Òý
#    BYTE        HoleIndex;        //Ñ¡ÔñµÄ¿×Ë÷Òý
#};
def OnEquipEnchase(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    
    # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
    equipIndex = clientData.EquipIndex
    stoneIndex = clientData.StoneIndex
    holeIndex = clientData.HoleIndex
    
    GameWorld.DebugLog("±¦Ê¯ÏâǶ: equipIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipIndex, stoneIndex, holeIndex), playerID)
    
    #»ñµÃ×°±¸Î»×°±¸ÊµÀý
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    curEquip = equipPack.GetAt(equipIndex)
    
    if not ItemCommon.CheckItemCanUse(curEquip):
        GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
        return
 
    #»ñµÃ±¦Ê¯ÊµÀý
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    curStone = itemPack.GetAt(stoneIndex)
    
    if not ItemCommon.CheckItemCanUse(curStone):
        GameWorld.Log("Ä¿±ê±¦Ê¯Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
        return
    
    stoneItemID = curStone.GetItemTypeID()
    isBind = curStone.GetIsBind()
    curStoneEff = curStone.GetEffectByIndex(0)
    curEffID = curStoneEff.GetEffectID()
    if curEffID != ChConfig.Def_Effect_EquipStone:
        GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨ÏâǶ£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s != %s" 
                      % (stoneIndex, stoneItemID, curEffID, ChConfig.Def_Effect_EquipStone), playerID)
        return
    
    stoneEffType = curStoneEff.GetEffectValue(0)
    stoneCanPlaceList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneEffType, 1)
    
    if equipIndex not in stoneCanPlaceList:
        GameWorld.Log("¸Ã±¦Ê¯²»¿ÉÏâǶÔÚ¸Ã×°±¸Î»£¡stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPlace=%s" 
                      % (stoneItemID, stoneEffType, stoneCanPlaceList, equipIndex), playerID)
        return
    
    equipClassLV = ItemCommon.GetItemClassLV(curEquip)
    if not __CheckStoneHoleCanUse(curPlayer, equipClassLV, holeIndex):
        return
    
    # ¿Û³ý±¦Ê¯
    ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"EquipPlace":equipIndex, "HoleIndex":holeIndex})
    
    isBind = 1 if isBind else 0
    
    # ±ä¸ü±¦Ê¯¿×±¦Ê¯ÐÅÏ¢
    __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, stoneItemID, isBind, "EquipStone", True)
    
#    #ÏâǶ³É¹¦
#    if not curEquip.GetIsBind():
#        ItemControler.SetItemIsBind(curEquip, True)
    
    # Ë¢ÐÂÊôÐÔ
    RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, True)
    
    #ͬ²½¿Í»§¶Ë
    Sycn_StoneHoleInfo(curPlayer, [equipIndex])
    #³É¾Í
    DoStoneSuccess(curPlayer)
    return
 
def DoStoneSuccess(curPlayer):
    PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone1)
    PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone2)
    totalStoneLV = 0
    holeIndexList = GetAllEquipPlaceHoleIndex()
    gameData = GameWorld.GetGameData()
    packType = IPY_GameWorld.rptEquip
    playerEquip = curPlayer.GetItemManager().GetPack(packType)
    for equipIndex in xrange(playerEquip.GetCount()):
        if equipIndex not in ShareDefine.RoleEquipType :
            continue
        for holeIndex in holeIndexList:
            
            curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
            if curGemID == 0:
                continue
            curGem = gameData.GetItemByTypeID(curGemID)
            if not curGem:
                continue    
    
            gemEffect = curGem.GetEffectByIndex(0)
            gemType, gemLV = gemEffect.GetEffectValue(0), gemEffect.GetEffectValue(1)
            if gemType == 1:#ÉúÃü±¦Ê¯
                PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone1, 1, [gemLV])
            elif gemType == 2:#»ÙÃð±¦Ê¯
                PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone2, 1, [gemLV])
                
            totalStoneLV += gemLV
            
    # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶
    OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)
    PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_StoneTotalLV, totalStoneLV)
    return
 
#//A3 05 ±¦Ê¯ÕªÈ¡ #tagCMEquipStonePick
#struct    tagCMEquipStonePick
#{
#    tagHead        Head;
#    BYTE        EquipIndex;        //×°±¸Î»ÔÚ±³°üÖÐË÷Òý
#    BYTE        HoleIndex;        //×°±¸Î»µÄ¿×Ë÷Òý
#};
def OnEquipStonePick(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
    equipIndex = clientData.EquipIndex
    holeIndex = clientData.HoleIndex
    GameWorld.DebugLog("±¦Ê¯Õª³ý: equipIndex=%s,holeIndex=%s" % (equipIndex, holeIndex), playerID)
    
    #»ñµÃ×°±¸Î»×°±¸ÊµÀý
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    curEquip = equipPack.GetAt(equipIndex)
    
    if not ItemCommon.CheckItemCanUse(curEquip):
        GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
        return
    
    #ÑéÖ¤±³°ü¿Õ¼ä
    if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem, True):
        return
    
    # ÑéÖ¤±¦Ê¯
    stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
    
    if not stoneID:
        GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")
        return
    
    __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, 0, 0, "StonePick", True)
    
    # Ë¢ÐÂÊôÐÔ
    RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)
    
    #ͬ²½¿Í»§¶Ë
    Sycn_StoneHoleInfo(curPlayer, [equipIndex])
    
    totalStoneLV = GetTotalStoneLV(curPlayer)
    # ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶
    OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True)
    return
 
def GetTotalStoneLV(curPlayer):
    ##±¦Ê¯×ܵȼ¶
    totalStoneLV = 0
    holeIndexList = GetAllEquipPlaceHoleIndex()
    gameData = GameWorld.GetGameData()
    playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    for equipIndex in xrange(playerEquip.GetCount()):
        if equipIndex not in ShareDefine.RoleEquipType :
            continue
        for holeIndex in holeIndexList:
            curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
            if curGemID == 0:
                continue
            curGem = gameData.GetItemByTypeID(curGemID)
            if not curGem:
                continue
            gemLV = curGem.GetEffectByIndex(0).GetEffectValue(1)
            totalStoneLV += gemLV
    return totalStoneLV
 
#// A3 06 ±¦Ê¯Éý¼¶ #tagCMEquipStoneUpgrade
#struct    tagCMEquipStoneUpgrade
#{
#    tagHead        Head;
#    BYTE        EquipIndex;        //×°±¸Î»ÔÚ×°±¸±³°üÖеÄË÷Òý
#    BYTE        HoleIndex;        //×°±¸Î»Öб¦Ê¯¿×Ë÷Òý
#    BYTE        UpWay;        //Éý¼¶·½Ê½ 0:ÏÉÓñ 1:±¦Ê¯
#};
def OnEquipStoneUpgrade(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    
    # ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
    equipIndex = clientData.EquipIndex
    holeIndex = clientData.HoleIndex
    upWay = clientData.UpWay
    GameWorld.DebugLog("±¦Ê¯Éý¼¶: equipPlace=%s,holeIndex=%s" % (equipIndex, holeIndex), playerID)
    
    #»ñµÃ×°±¸Î»×°±¸ÊµÀý
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    curEquip = equipPack.GetAt(equipIndex)
    
    if not ItemCommon.CheckItemCanUse(curEquip):
        GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
        return
        
    #Éý¼¶±¦Ê¯ID
    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
    if stoneID == 0:
        GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")      
        return      
    stoneItemData = GameWorld.GetGameData().GetItemByTypeID(stoneID) 
    stoneItemID = stoneItemData.GetItemTypeID()
    curStoneEff = stoneItemData.GetEffectByIndex(0)
    curEffID = curStoneEff.GetEffectID()
    if curEffID != ChConfig.Def_Effect_EquipStone:
        GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨Éý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s" 
                      % (holeIndex, stoneItemID, curEffID), playerID)
        return 
    stoneEffType = curStoneEff.GetEffectValue(0)
    level = curStoneEff.GetEffectValue(1)
    upgradeStoneID = curStoneEff.GetEffectValue(2)
    
    stoneTypeItemIDDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 1)
    GameWorld.DebugLog("stoneEffType=%s,stoneTypeItemIDDict=%s,level=%s,upgradeStoneID=%s" 
                       % (stoneEffType, stoneTypeItemIDDict, level, upgradeStoneID))
    if stoneEffType not in stoneTypeItemIDDict:
        return
    stoneTypeItemID = stoneTypeItemIDDict[stoneEffType]
    
    if not upgradeStoneID:
        GameWorld.Log("¸Ã±¦Ê¯ÒÑÊÇ×î´ó¼¶,²»ÄÜÉý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s,upgradeStoneID=%s"
                      % (holeIndex, stoneItemID, curEffID, upgradeStoneID), playerID)
        return
    needCount = IpyGameDataPY.GetFuncCfg("GemUpCostFormula", 2) # ºÏ³ÉÏÂÒ»¼¶ËùÐ豦ʯ¸öÊý
    if not needCount:
        return
    if upWay == 0: #ÏÉÓñ
        unitPrice = ItemCommon.GetShopItemPrice(stoneTypeItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
        if not unitPrice:
            return
        costCount = pow(needCount, level - 1) * (needCount - 1)
        costGold = costCount * unitPrice
        if costGold <= 0:
            return
        infoDict = {"StoneItemID":stoneItemID, "CurStoneIDLV":level, "UpgradeStoneID":upgradeStoneID, "CostCount":costCount, "UnitPrice":unitPrice}
        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_EquipStone, infoDict):
            GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % costGold)
            return
    else:
        #ͬ¼¶±¦Ê¯
        costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, stoneItemID)
        if bindCnt + unBindCnt < needCount-1:
            GameWorld.DebugLog("ͬ¼¶±¦Ê¯²»×ã %s!" % (needCount-1))
            return
        if stoneIsBind:
            costIndexList = (costItemIndexList[0]+costItemIndexList[1])[:2]
        else:
            costIndexList = (costItemIndexList[1]+costItemIndexList[0])[:2]
        itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
        hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, costIndexList, needCount-1, False, ChConfig.ItemDel_StoneUpgrade, 
                                        {"EquipPlace":equipIndex, "HoleIndex":holeIndex})
        if hasBind:
            stoneIsBind = True
        
    
    __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, upgradeStoneID, stoneIsBind, "StoneUpgrade", False)
    
    # Ë¢ÐÂÊôÐÔ
    RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)
    
    #ͬ²½¿Í»§¶Ë
    Sycn_StoneHoleInfo(curPlayer, [equipIndex])
    
    DoStoneSuccess(curPlayer)
    return
 
def __CheckStoneHoleCanUse(curPlayer, equipClassLV, holeIndex):
    ##ÑéÖ¤¿×ºÏ·¨ÐÔ
    
    holeIndexList = GetAllEquipPlaceHoleIndex()
    if holeIndex not in holeIndexList:
        GameWorld.Log("ÏâǶ¿×Ë÷Òý´íÎó!holeIndex=%s, holeIndexList=%s" % (holeIndex, holeIndexList))
        return False
    
    openCommHoleCnt = 0 # ÒѾ­¿ª·Å×°±¸³£¹æ¿×Êý
    gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
    for holeCnt, openClassLV in enumerate(gemOpenClassLVList, 1):
        if equipClassLV >= openClassLV:
            openCommHoleCnt = holeCnt
            
    # VIP¿×
    if holeIndex >= ChConfig.Def_Stone_VipHole:
        
        if openCommHoleCnt <= 0:
            GameWorld.Log("×°±¸Î´¿ªÆôÈÎºÎÆÕͨ±¦Ê¯¿×£¬ÎÞ·¨¿ªÆôVIP¿×λ! equipClassLV=%s,openCommHoleCnt=%s" % (equipClassLV, openCommHoleCnt))
            return False
        gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
        
        openVIPHoleCnt = 0 # ÒѾ­¿ª·Å×°±¸VIP¿×Êý
        curVipLV = curPlayer.GetVIPLv()
        for holeCnt, vipLv in enumerate(gemOpenVipList, 1):      
            if curVipLV >= vipLv:       
                openVIPHoleCnt = holeCnt
                
        if holeIndex >= openVIPHoleCnt + ChConfig.Def_Stone_VipHole:
            GameWorld.Log("×°±¸VIP±¦Ê¯¿×먦·Å!curVipLV=%s,holeIndex=%s,openVIPHoleCnt=%s" 
                          % (curVipLV, holeIndex, openVIPHoleCnt), curPlayer.GetPlayerID())
            return False
        
        #²»ÏÞÖÆÊÇ·ñ¹ýÆÚ
        #if not PlayerVip.GetCurVIPTime(curPlayer):
        #    GameWorld.Log("VIPÒѹýÆÚ£¬ÎÞ·¨Ê¹ÓÃVIP±¦Ê¯¿×£¡", curPlayer.GetPlayerID())
        #    return False
        
    # ³£¹æ¿×
    elif holeIndex >= openCommHoleCnt:
        GameWorld.Log("¸Ã×°±¸±¦Ê¯¿×Ϊ¿ª·Å£¡equipClassLV=%s,holeIndex=%s,openCommHoleCnt=%s" 
                      % (equipClassLV, holeIndex, openCommHoleCnt), curPlayer.GetPlayerID())
        return False
    
    return True
 
def __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff):
    ## ±ä¸üÍæ¼Ò×°±¸¿×±¦Ê¯
    
    #»ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢
    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
    #±£´æ×°±¸Î»¿×λÉϱ¦Ê¯IDºÍ°ó¶¨×´Ì¬
    SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind)
    
    if isPickoff and stoneID:
        itemCount = 1
        # Õª³ýµÄ±¦Ê¯¶¼°ó¶¨
        if ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):
            ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, True if stoneIsBind else False,
                                         [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], 
                                         event=[ChConfig.ItemGive_StonePickoff, False, {"EquipPlace":equipIndex, "HoleIndex":holeIndex}])
        else:
            PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], [[stoneID, 1, stoneIsBind]])
            
    DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'equipIndex':equipIndex,"holeIndex":holeIndex, "stoneID":stoneID, 'changeStoneID':changeStoneID})    
    return
 
 
def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify):
    ## ±¦Ê¯Ë¢ÐÂÊôÐÔ
    # ×°±¸µÈ¼¶¸Ä±ä£¬ÅжÏÊÇ·ñÎªÍæ¼ÒÉíÉϵÄ×°±¸£¬Èç¹ûÊǵĻ°Ë¢ÐÂÍæ¼ÒÊôÐÔ
    if packType in [IPY_GameWorld.rptEquip, IPY_GameWorld.rptHorseEquip]:
        #ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ
        if isNeedNotify:
            curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Stone)
        ChEquip.RefreshPlayerEquipAttribute(curPlayer)
        
        #Ë¢ÐÂËùÓÐÊôÐÔ
        playControl = PlayerControl.PlayerControl(curPlayer)
        playControl.RefreshPlayerAttrState()
        
    return
 
 
def DoMoveEquipStone(curPlayer, equipIndex): 
    ###Ìæ»»×°±¸Ê±±¦Ê¯×ªÒÆ
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    curEquip = equipPack.GetAt(equipIndex)
    if not ItemCommon.CheckItemCanUse(curEquip):
        return
    
    #»ñµÃ×°±¸½×¼¶¿×ÐÅÏ¢
    gemOpenClassLVList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
    maxEquipHoleCnt = len(gemOpenClassLVList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý
    
    openEquipHoleCnt = 0 # ÒѾ­¿ª·Å¿×Êý
    equipClassLV = ItemCommon.GetItemClassLV(curEquip)
    for holeCnt, openClassLV in enumerate(gemOpenClassLVList, 1):
        if equipClassLV >= openClassLV:
            openEquipHoleCnt = holeCnt
            
    #ÐèÒª²ðж±¦Ê¯µÄ¿×Áбí
    pickoffHoleList = []
    
    #ÅжÏ×°±¸½×¼¶±¦Ê¯ÊÇ·ñ²ðж
    for holeIndex in xrange(maxEquipHoleCnt):      
        if holeIndex < openEquipHoleCnt:
            continue
        curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
        if curGemID == 0:
            continue       
        pickoffHoleList.append([equipIndex, holeIndex])
        
    #ûÓпªÆôÆÕͨװ±¸¿×£¬ÐèÕª³ýVIP¿×
    if not openEquipHoleCnt:
        #»ñµÃVIPµÈ¼¶¿×ÐÅÏ¢
        gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
        maxVipHoleCnt = len(gemOpenVipList)# ×î´óVIP¿ª·Å¿×Êý
        #ÅжÏVIPµÈ¼¶¿×ÐÅÏ¢
        for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt): 
            curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
            if curGemID == 0:                             
                continue
            pickoffHoleList.append([equipIndex, holeIndex])
            
    # ÍÑ×°±¸µÄÍâ²ãË¢ÊôÐÔ, ÕâÀﲻˢ
    __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, "EquipChange", False)
    return
 
def OnVIPTimeOut(curPlayer):
    ## VIPµ½ÆÚ´¦Àí
    #¹ýÆÚÒ»ÑùÓÐЧ£¬ÆÁ±Î¸ÃÂß¼­
    #===============================================================================================
    # #»ñµÃvipµÈ¼¶¿×ÐÅÏ¢
    # gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
    # maxVipHoleCnt = len(gemOpenVipList)# ×î´óVip¿ª·Å¿×Êý
    # 
    # #»ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î»
    # stoneCanPlaceList = GetAllStoneEquipIndexList()
    # #ÐèÒª²ðж±¦Ê¯µÄ¿×Áбí
    # pickoffHoleList = []
    # for equipIndex in stoneCanPlaceList:
    #    for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt):
    #        stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
    #        if not stoneInfo[0]:
    #            continue
    #        pickoffHoleList.append([equipIndex, holeIndex])
    #        
    # __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, "VIPChange", True)
    #===============================================================================================
    return  
 
def __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, eventName, isRefreshAttr):
    ## ÏµÍ³Õª³ý±¦Ê¯
    
    if not pickoffHoleList:
        return
    
    GameWorld.DebugLog("ϵͳժ³ý±¦Ê¯: %s,pickoffHoleList=%s" % (eventName, pickoffHoleList), curPlayer.GetPlayerID())
    
    equipIndexList = []
    stoneCount = len(pickoffHoleList)
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, stoneCount)
    if packSpace >= stoneCount:
        for equipIndex, holeIndex in pickoffHoleList:
            __DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, 0, 0, eventName, True)
            if equipIndex not in equipIndexList:
                equipIndexList.append(equipIndex)
    else:
        #ÓʼþÎïÆ·ÐÅÏ¢Áбí
        mailItemInfoList = []
        for equipIndex, holeIndex in pickoffHoleList:
            stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
            mailItemInfoList.append([stoneInfo[0], 1, stoneInfo[1]])
            SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, 0, 0)
            DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'changeStoneID':0,'equipIndex':equipIndex,"holeIndex":holeIndex, "stoneID":stoneInfo[0]})
            if equipIndex not in equipIndexList:
                equipIndexList.append(equipIndex)
        PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList)
        
    if isRefreshAttr:
        RefreshAttrByStoneAction(curPlayer, IPY_GameWorld.rptEquip, False)
    
    if equipIndexList:
        Sycn_StoneHoleInfo(curPlayer, equipIndexList)
    return
 
def Sycn_StoneHoleInfo(curPlayer, equipIndexList=[]):
    ###ͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢
    #×°±¸Î»ËùÓп×λ
    holeIndexList = GetAllEquipPlaceHoleIndex()
    maxHoleCount = len(holeIndexList)
    if not equipIndexList:
        equipIndexList = GetAllStoneEquipIndexList()
    
    sendPack = ChPyNetSendPack.tagMCStoneInfo()
    sendPack.InfoList = []
    for equipIndex in equipIndexList:
        stoneMsg = ChPyNetSendPack.tagMCStoneMsg()
        stoneMsg.EquipPlace = equipIndex
        stoneMsg.MaxStoneCount = maxHoleCount 
        stoneMsg.StoneInfo = GetEquipIndexStoneIDList(curPlayer, equipIndex)
        holeStoneBindList = []
        for holeIndex in holeIndexList:
            isBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[1]
            holeStoneBindList.append(isBind)
        stoneMsg.StoneBind = holeStoneBindList
        sendPack.InfoList.append(stoneMsg)
    sendPack.EquipCount = len(sendPack.InfoList)  
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return