hxp
2020-03-11 eda67261f401cc667834c73bdffec1e11319f47a
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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Event.EventSrc.Operate_ItemCompound
#
# @todo:ÎïÆ·ºÏ³É
# @author hxp
# @date 2017-07-27
# @version 1.0
#
# ÏêϸÃèÊö: ÎïÆ·ºÏ³É
#
#-------------------------------------------------------------------------------
#"""Version = 2017-07-27 17:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
import ItemCommon
import ShareDefine
import IPY_GameWorld
import FormulaControl
import PlayerControl
import ItemControler
import IpyGameDataPY
import ChConfig
import PlayerSuccess
import DataRecordPack
import PlayerWing
import PlayerDogz
import EventShell
 
import random
import math
 
 
 
#//A3 03 ÎïÆ·ºÏ³É #tagCMItemCompound
#
#struct    tagCMItemCompound
#{
#    tagHead        Head;
#    DWORD        ID;        // ºÏ³ÉID
#    WORD        CompoundCnt;        //ºÏ³ÉÊýÁ¿(´ÎÊý)
#    BYTE        UnfixedItemIndexCnt;    // ²»¹Ì¶¨ÎïÆ·ÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        UnfixedItemIndex[UnfixedItemIndexCnt];    // ²»¹Ì¶¨ÎïÆ·ÔÚ±³°üµÄË÷ÒýÁбí
#    BYTE        FixedItemIndexCnt;    // ¹Ì¶¨ÎïÆ·ÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        FixedItemIndex[FixedItemIndexCnt];    // ¹Ì¶¨ÎïÆ·ÔÚ±³°üµÄË÷ÒýÁбí
#    BYTE        AddonsItemIndexCnt;    // ¸½¼ÓÎïÆ·ÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        AddonsItemIndex[AddonsItemIndexCnt];    // ¸½¼ÓÎïÆ·ÔÚ±³°üµÄË÷ÒýÁбí
#    BYTE        AddonsItemCount[AddonsItemIndexCnt];    // ¸½¼ÓÎïÆ·ÔÚ±³°üµÄË÷Òý¶ÔÓ¦¿Û³ýÊýÁ¿Áбí
#    BYTE        RateIncreaseItemIndexCnt;    // ÌáÉý¸ÅÂÊÎïÆ·ÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        RateIncreaseItemIndex[RateIncreaseItemIndexCnt];    // ÌáÉý¸ÅÂÊÎïÆ·ÔÚ±³°üµÄË÷ÒýÁбí
#};
def OnItemCompound(index, clientData, tick):    
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
 
    compoundID = clientData.ID
    compoundCnt = max(1, clientData.CompoundCnt) # ÖÁÉٺϳÉÒ»¸ö
    unfixedItemIndexList = clientData.UnfixedItemIndex
    fixedItemIndexList = clientData.FixedItemIndex
    addonsItemIndexList = clientData.AddonsItemIndex
    addonsItemCountList = clientData.AddonsItemCount
    incRateItemIndexList = clientData.RateIncreaseItemIndex
    GameWorld.DebugLog("ÎïÆ·ºÏ³É: ID=%s,compoundCnt=%s,unfixedItemIndexList=%s,fixedItemIndexList=%s,addonsItemIndexList=%s,addonsItemCountList=%s,incRateItemIndexList=%s"  
                       % (compoundID, compoundCnt, unfixedItemIndexList, fixedItemIndexList, addonsItemIndexList, addonsItemCountList, incRateItemIndexList), playerID)
    
    ipyData = IpyGameDataPY.GetIpyGameData("ItemCompound", compoundID)
    if not ipyData:
        GameWorld.ErrLog("ÕÒ²»µ½¸ÃºÏ³É±íÊý¾ÝÅäÖã¡ ID=%s" % compoundID)
        return
    
    composeGroup = ipyData.GetComposeGroup()
    makeIDList = ipyData.GetMakeID()
    unfixedItemIDList = ipyData.GetUnfixedItemID()
    fixedItemIDList = ipyData.GetFixedItemID()
    fixedItemCountList = ipyData.GetFixedItemCount()
    
    isFirstSuccMakeJobItem = False
    if ipyData.GetIsFirstSuccMakeJobItem() and not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID):
        isFirstSuccMakeJobItem = True
        makeItemID = 0
        for jobItemID in makeIDList:
            itemData = GameWorld.GetGameData().GetItemByTypeID(jobItemID)
            if itemData and ItemCommon.CheckJob(curPlayer, itemData):
                makeItemID = jobItemID
                break
    else:
        makeItemID = random.choice(makeIDList) # ´Ó¿ÉºÏ³ÉÎïÆ·ÁбíÀïËæ»úÒ»¸ö
    makeItemData = GameWorld.GetGameData().GetItemByTypeID(makeItemID)
    if not makeItemData:
        GameWorld.ErrLog("²»´æÔڸúϳÉÎïÆ·! makeItemID=%s" % makeItemID)
        return
    
    if not ItemCommon.CheckJob(curPlayer, makeItemData):
        if makeItemData.GetType() in [ChConfig.Def_ItemType_retPeerlessWeapon, ChConfig.Def_ItemType_retPeerlessWeapon2]:
            PlayerControl.NotifyCode(curPlayer, "ItemCompoundJoblimit")
            return
        
    packType = ChConfig.GetItemPackType(makeItemData.GetType(), IPY_GameWorld.rptItem)
    GameWorld.DebugLog("makeItemID=%s,packType=%s" % (makeItemID, packType), playerID)
    
    needSpace = int(math.ceil(float(compoundCnt) / makeItemData.GetPackCount()))
    emptySpace = ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace)
    #ÑéÖ¤±³°ü¿Õ¼ä
    if needSpace > emptySpace:
        #PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType])
        GameWorld.DebugLog("±³°ü¿Õ¼ä²»×㣡packType=%s,needSpace=%s > emptySpace=%s" % (packType, needSpace, emptySpace), playerID)
        return
    
    compoundBindCnt = 0
    needUnfixedItemCount = ipyData.GetUnfixedItemCount()
    needMoney = ipyData.GetNeedMoney()
    successRate = ipyData.GetSuccessRate()
    successRateMax = ipyData.GetSuccessRateMax()
    successRateIncrease = ipyData.GetSuccessRateIncrease()
    addonsCountMax = ipyData.GetAddonsCountMax() # ¿Éµþ¼ÓµÄËãµþ¼ÓÊýÁ¿
    # ¿ÉʹÓ÷ǹ̶¨µÀ¾ß »ò ¸½¼ÓµÀ¾ßµÄ µ¥´ÎºÏ³ÉÊýĬÈÏΪ1
    if unfixedItemIDList or addonsCountMax > 0 or incRateItemIndexList:
        compoundCnt = 1
    
    totalNeedMoney = needMoney * compoundCnt
    if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney):
        GameWorld.DebugLog("»õ±Ò²»×ãºÏ³É! totalNeedMoney=%s" % totalNeedMoney, playerID)
        return
    
    # Ä¿±êÎïÆ·¿É·ñ²ð½âÅжÏ
    canDecompoundItemTypeList = IpyGameDataPY.GetFuncEvalCfg("ItemDecompound", 1)
    decompoundMinColor = IpyGameDataPY.GetFuncCfg("ItemDecompound", 2)
    canDecompound = makeItemData.GetType() in canDecompoundItemTypeList and makeItemData.GetItemColor() >= decompoundMinColor
    decompoundItemInfo = [] # ²ð½â·µ»¹ÎïÆ·Áбí [×°±¸ID,²ÄÁÏ1ID,¸öÊý,ÊÇ·ñ°ó¶¨,²ÄÁÏ2ID,¸öÊý,ÊÇ·ñ°ó¶¨,...]
    
    itemPack = curPlayer.GetItemManager().GetPack(packType)
    itemExpireTime = 0
    wingItemExpInfo = None #²ÄÁϳá°ò¾«Á¶ÐÅÏ¢
    dogzEquipPlusExp = 0 #ÉñÊÞ×°±¸Ç¿»¯ÊìÁ·¶È
    liantaiInfo = None #Á«Ì¨Ïà¹ØÐÅÏ¢
    # ¼ì²é²»¹Ì¶¨ÏûºÄµÀ¾ß
    if unfixedItemIDList:
        unfixedItem = GameWorld.GetGameData().GetItemByTypeID(unfixedItemIDList[0])
        if not unfixedItem:
            return
        unfixedItemCostInfo = __CheckUnfixedItem(curPlayer, compoundID, makeItemData, itemPack, unfixedItemIndexList, 
                                                 unfixedItemIDList, needUnfixedItemCount)
        if not unfixedItemCostInfo:
            return
        unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime, liantaiInfo = unfixedItemCostInfo
        if expireTime:
            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
        
    # ¼ì²é¹Ì¶¨ÏûºÄµÀ¾ß
    if fixedItemIDList:
        fixedItemInfo = __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt)
        if not fixedItemInfo:
            return
        fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime = fixedItemInfo
        if expireTime:
            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
        
    # ¼ì²é¸½¼ÓµÀ¾ßÔö¼Ó³É¹¦ÂÊÏûºÄ
    addSuccRate, addSuccRateItemInfo = 0, []
    if addonsCountMax > 0:
        addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax)
        if addSuccRateInfo == None:
            return
        addSuccRate, addSuccRateItemInfo, expireTime = addSuccRateInfo
        if expireTime:
            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
    
    # ¼ì²éÌáÉý¸ÅÂʵÀ¾ß
    incRateItemCostList, needIncRateItemCount, incRate = [], 0, 0
    if successRateIncrease and len(successRateIncrease) == 3 and incRateItemIndexList:
        incRateItemID, needIncRateItemCount, incRate = successRateIncrease
        incRateItemInfo = __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount)
        if not incRateItemInfo:
            return
        incRateItemCostList, expireTime = incRateItemInfo
        if expireTime:
            itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime)
        
    # ¿ÛÍ­Ç®
    PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce, 
                           {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt})
    
    drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt, "itemExpireTime":itemExpireTime, "PackType":packType}
    if liantaiInfo:
        drDict["LiantaiInfo"] = liantaiInfo
        
    makeItemBind = False
    
    # ¿Û²»¹Ì¶¨ÏûºÄÎïÆ·
    if unfixedItemIDList:
        bindUnfixedIndexList, unbindUnfixedIndexList = unfixedItemCostList
        hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount, 
                                        False, ChConfig.ItemDel_ItemCompound, drDict)
        makeItemBind = True if hasBind else makeItemBind
        
    if canDecompound:
        decompoundUnfixedItemID = 0 if not unfixedItemIDList else random.choice(unfixedItemIDList) # ²ð½âÊ±Ëæ»ú·µ»¹Ò»¼þ²»¹Ì¶¨ÏûºÄµÀ¾ß
        decompoundItemInfo.append(decompoundUnfixedItemID)
        
    # ¿Û¹Ì¶¨ÏûºÄÎïÆ·
    if fixedItemIDList:
        for fixedItemID, countInfo in fixedItemNeedCntDict.items():
            delBindCnt, delUnBindCnt = countInfo
            bindFixedIndexList, unbindFixedIndexList = fixedItemIndexDict[fixedItemID]
            if delBindCnt:
                makeItemBind = True
                ItemCommon.ReduceItem(curPlayer, itemPack, bindFixedIndexList, delBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
                if canDecompound:
                    decompoundItemInfo.append(fixedItemID)
                    decompoundItemInfo.append(delBindCnt)
                    decompoundItemInfo.append(1) # °ó¶¨
            if delUnBindCnt:
                ItemCommon.ReduceItem(curPlayer, itemPack, unbindFixedIndexList, delUnBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict)
                if canDecompound:
                    decompoundItemInfo.append(fixedItemID)
                    decompoundItemInfo.append(delUnBindCnt)
                    decompoundItemInfo.append(0) # ²»°ó¶¨
                    
    # ¿Û¸½¼ÓµÀ¾ß
    if addonsCountMax > 0:
        for i, addonsItemIndex in enumerate(addonsItemIndexList):
            hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, [addonsItemIndex], addonsItemCountList[i], 
                                            False, ChConfig.ItemDel_ItemCompound, drDict)
            #makeItemBind = True if hasBind else makeItemBind #²ß»®Ëµ¸½¼Ó²ÄÁϲ»¾ö¶¨ºÏ³ÉÎïÆ·ÊÇ·ñ°ó¶¨
    
    # ¿ÛÌáÉý¸ÅÂʵÀ¾ß
    if incRateItemCostList:
        bindIncRateItemIndexList, unBindIncRateItemIndexList = incRateItemCostList
        hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, bindIncRateItemIndexList + unBindIncRateItemIndexList, needIncRateItemCount, 
                                        False, ChConfig.ItemDel_ItemCompound, drDict)
        
    if compoundCnt == 1 and makeItemBind:
        compoundBindCnt = 1
        
    # ¸øºÏ³ÉÎïÆ·
    totalSuccRate = successRate + addSuccRate + incRate
    if successRateMax:
        totalSuccRate = min(successRateMax, totalSuccRate)
    GameWorld.DebugLog("ºÏ³É³É¹¦ÂÊ: successRate=%s,addSuccRate=%s,incRate=%s,successRateMax=%s,totalSuccRate=%s" 
                       % (successRate, addSuccRate, incRate, successRateMax, totalSuccRate), playerID)
    # Ç°X´ÎºÏ³É³É¹¦ÂʰٷְÙ
    composeMustSuccessDict = IpyGameDataPY.GetFuncEvalCfg("ComposeMustSuccess", 1, {})
    if composeGroup in composeMustSuccessDict:
        mustSuccessCountTotal = composeMustSuccessDict[composeGroup]
        hisComposeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ComposeMustSuccess % composeGroup)
        if hisComposeCount < mustSuccessCountTotal:
            totalSuccRate = ShareDefine.Def_MaxRateValue
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ComposeMustSuccess % composeGroup, hisComposeCount + 1)
            GameWorld.DebugLog("ǰX´ÎºÏ³É±Ø¶¨³É¹¦!composeGroup=%s,hisComposeCount=%s,mustSuccessCountTotal=%s,totalSuccRate=%s" 
                               % (composeGroup, hisComposeCount, mustSuccessCountTotal, totalSuccRate), playerID)
            
    # ºÏ³É³É¹¦
    maxRateValue = ShareDefine.Def_MaxRateValue
    randValue = random.randint(1, maxRateValue)
    canHappen = randValue <= totalSuccRate
    GameWorld.DebugLog("canHappen=%s,randValue=%s,totalSuccRate=%s,maxRateValue=%s" 
                       % (canHappen, randValue, totalSuccRate, maxRateValue), playerID)
    if drDict:
        DataRecordPack.SendEventPack("ItemCompound_Liantai", drDict, curPlayer)
    # ²»Êǰٷְٳɹ¦µÄ¼Ç¼ºÏ³ÉÁ÷Ïò
    if successRate != maxRateValue:
        drDict = {"PlayerID":curPlayer.GetPlayerID(), "AccID":curPlayer.GetAccID(), "ID":compoundID, "MakeItemID":makeItemID, "IsSuccess":canHappen,
                  "RateInfo":{"totalSuccRate":"%s(%s+%s+%s)" % (totalSuccRate, successRate, addSuccRate, incRate), "randValue":randValue, "maxRateValue":maxRateValue},
                  "AddSuccRateItemInfo":addSuccRateItemInfo, "PackType":packType,
                  }
        DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer)
        
    if canHappen:
        GameWorld.DebugLog("ºÏ³É³É¹¦: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s,itemExpireTime=%s" % (makeItemID, compoundCnt, compoundBindCnt, itemExpireTime), playerID)
        userData = GiveNewCompoundItem(curPlayer, packType, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
        
        msgMark = ipyData.GetSysMark()
        paramType = ipyData.GetSysMarkParamType()
        if msgMark not in ['0', '', '-']:
            if paramType == 2 and fixedItemIDList and fixedItemCountList:
                PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), fixedItemCountList[0], fixedItemIDList[0], makeItemID, userData])
            else:
                PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), makeItemID, userData])
                
        if isFirstSuccMakeJobItem:
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID, 1)
            GameWorld.DebugLog("±ê¼ÇÊ״κϳɳɹ¦¸ø±¾Ö°ÒµÎïÆ·£¡", playerID)
            
        # Í¨ÖªºÏ³É³É¹¦
        ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess, makeItemID)
        #³É¹¦ºÏ³É1¸öÎïÆ·³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundItemEx, compoundCnt, [makeItemID])
        #ºÏ³ÉX½×XÑÕÉ«XÐǼ¶ÒÔÉÏ×°±¸, ÐǼ¶¸ÄΪװ±¸Î»ÁË£¬ÔÝʱûÓÐÓã¬ÆÁ±Î
        #classLV = ItemCommon.GetItemClassLV(makeItemData)
        #itemColor = makeItemData.GetItemColor()
        #itemQuality = makeItemData.GetItemQuality()
        #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundEquip, compoundCnt, [classLV, itemColor, itemQuality])
        #EventShell.EventRespons_CompoundEquip(curPlayer, itemColor, itemQuality)
    # ºÏ³Éʧ°Ü
    else:
        GameWorld.DebugLog("ºÏ³Éʧ°Ü£¡")
        __SendDogzEquipRemainExpMail(playerID, dogzEquipPlusExp, False)
        ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail, 0)
        #curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail)
 
    # ×°±¸ºÏ³ÉÊôÐÔÖ§³Ö... ´ýÀ©Õ¹
    # ºÏ³ÉÁ÷Ïò¼Ç¼µÈ
    #DataRecordPack.DR_EquipCompound(curPlayer, "EquipCompound_NewItem", newItemID, 1, recordData)
    return
 
 
def __CheckUnfixedItem(curPlayer, compoundID, makeItemData, itemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount):
    ## ¼ì²é²»¹Ì¶¨ÏûºÄµÀ¾ß, Ö»Òª¿Í»§¶ËÌá½»µÄÊý¾ÝÓв»·ûºÏÒªÇóµÄ£¬ÔòÖ±½Ó·µ»Ø None
    expireTime = 0
    wingItemExpInfo = None
    dogzEquipPlusExp = 0
    unfixedItemTotalCount = 0
    unfixedItemCostList = [[], []] # [[°ó¶¨Ë÷Òý], [·Ç°ó¶¨Ë÷Òý]]
    maxPackCount = itemPack.GetCount()
    playerID = curPlayer.GetPlayerID()
    makeItemID = makeItemData.GetItemTypeID()
    liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList = 0, 0, [], [], []
    liantaiDecomposeID = IpyGameDataPY.GetFuncCfg("ComposeLiantai", 1) # ºÏ³ÉÁ«Ì¨Ë鯬ID
    liantaiComposePreIDList = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 2) # ºÏ²¢Á«Ì¨Ô¤ÀÀID
    for index in unfixedItemIndexList:
        if index >= maxPackCount:
            GameWorld.Log("¸ÃÎïÆ·¸ñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨ºÏ³É£¡index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not __CheckItemCanUseCompound(playerID, index, curItem):
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉʹÓÃ!ÎÞ·¨ºÏ³É! ID=%s,index=%s" % (compoundID, index), playerID)
            return
        itemID = curItem.GetItemTypeID()
        if itemID not in unfixedItemIDList:
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉÓÃÓںϳÉÄ¿±êÎïÆ·!ID=%s,index=%s,itemID=%s not in unfixedItemIDList=%s" 
                          % (compoundID, index, itemID, unfixedItemIDList), playerID)
            return
        
        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
        if isExpireItem:
            if not remainingTime:
                GameWorld.Log("²»¹Ì¶¨ÏûºÄµÀ¾ßʱЧÎïÆ·ÒÑʧЧ£¬ÎÞ·¨ºÏ³É! index=%s,itemID=%s" % (index, itemID), playerID)
                return
            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
            
        isBind = curItem.GetIsBind()
        itemCount = curItem.GetCount()
        unfixedItemTotalCount += itemCount
        unfixedItemCostList[0].append(index) if isBind else unfixedItemCostList[1].append(index)
        
        #¼Ç¼³á°ò¾«Á¶Öµ
        if curItem.GetType() == ChConfig.Def_ItemType_retWing:
            wingItemExpInfo = PlayerWing.GetWingItemChangeExp(curItem, ItemCommon.GetItemClassLV(makeItemData))
        elif ItemCommon.GetIsDogzEquip(curItem):
            equipExpEff = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Effect_DogzEquipPlusExp)
            baseExp = 0 if not equipExpEff else equipExpEff.GetEffectValue(0)
            plusExp = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1)
            dogzEquipPlusExp += (baseExp + plusExp)
            GameWorld.DebugLog("    ÉñÊ޺ϳɲÄÁÏ: index=%s,itemID=%s,baseExp=%s,plusExp=%s" % (index, itemID, baseExp, plusExp))
            
        #ºÏ³ÉÁ«Ì¨Ë鯬
        if makeItemID == liantaiDecomposeID:
            liantaiDecomposeIDCount += __GetLiantaiDecomposeIDCount(curItem)
        #ºÏ²¢Á«Ì¨
        elif makeItemID in liantaiComposePreIDList:
            itemSkillIDList = ItemCommon.GetItemSkillIDList(curItem)
            for skillID in itemSkillIDList:
                if skillID in liantaiComposeSkillIDList:
                    GameWorld.Log("ºÏ³ÉÁ«Ì¨¼¼ÄÜIDÖØ¸´£¬ÎÞ·¨ºÏ³É! skillID=%s" % (skillID), playerID)
                    PlayerControl.NotifyCode(curPlayer, "CompoundLiantaiSkillRep", [skillID])
                    return
                liantaiComposeSkillIDList.append(skillID)
                
            liantaiComposeMakeID, liantaiLegendAttrList = __GetLiantaiComposeInfo(liantaiComposeMakeID, liantaiComposeAllItemIDList, curItem)
            
    if unfixedItemTotalCount < needUnfixedItemCount:
        GameWorld.Log("²»¹Ì¶¨ÏûºÄµÀ¾ß²»×㣬ÎÞ·¨ºÏ³É!ID=%s,unfixedItemIDList=%s,needUnfixedItemCount=%s > unfixedItemTotalCount=%s" 
                      % (compoundID, unfixedItemIDList, needUnfixedItemCount, unfixedItemTotalCount), playerID)
        return
    
    liantaiInfo = [liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList]
    return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime, liantaiInfo
 
def __GetLiantaiDecomposeIDCount(curItem):
    ## »ñÈ¡ºÏ³ÉÁ«Ì¨Ë鯬¸öÊý
    decCountTotal = 0
    decItemIDList = [curItem.GetItemTypeID()]
    for i in xrange(curItem.GetUserAttrCount(ShareDefine.Def_IudetLiantaiItemID)):
        itemID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLiantaiItemID, i)
        if itemID not in decItemIDList:
            decItemIDList.append(itemID)
    liantaiDecomposeIDCountDict = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 3, {})
    for itemID in decItemIDList:
        for itemIDTuple, decCount in liantaiDecomposeIDCountDict.items():
            if itemID in itemIDTuple:
                decCountTotal += decCount
    return decCountTotal
 
def __GetLiantaiComposeInfo(liantaiComposeMakeID, liantaiComposeAllItemIDList, curItem):
    ## »ñÈ¡ºÏ³ÉÁ«Ì¨µÄÄ¿±êÎïÆ·ID
    curItemID = curItem.GetItemTypeID()
    gameData = GameWorld.GetGameData()
    
    # ËùÓкϳɵÄÁ«Ì¨ID
    if curItemID not in liantaiComposeAllItemIDList:
        liantaiComposeAllItemIDList.append(curItemID)
    for i in xrange(curItem.GetUserAttrCount(ShareDefine.Def_IudetLiantaiItemID)):
        itemID = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetLiantaiItemID, i)
        if itemID not in liantaiComposeAllItemIDList:
            liantaiComposeAllItemIDList.append(itemID)
            
    # »ñÈ¡ºÏ³ÉÄ¿±êÁ«Ì¨ID
    if not liantaiComposeMakeID:
        liantaiComposeMakeID = curItemID
    else:
        makeLiantaiItemData = gameData.GetItemByTypeID(liantaiComposeMakeID)
        if makeLiantaiItemData:
            makeName = makeLiantaiItemData.GetName()
            curName = curItem.GetName()
            makeNameIndex, curNameIndex = 0, 0
            namePriorityList = IpyGameDataPY.GetFuncEvalCfg("ComposeLiantai", 4)
            for i, nameP in enumerate(namePriorityList):
                if nameP in makeName:
                    makeNameIndex = i
                if nameP in curName:
                    curNameIndex = i
            if curNameIndex > makeNameIndex:
                liantaiComposeMakeID = curItemID
                
    # ¶îÍâÁ«Ì¨´«ÆæÊôÐÔ
    liantaiLegendAttrList = []
    for itemID in liantaiComposeAllItemIDList:
        if itemID == liantaiComposeMakeID:
            # Ä¿±êÁ«Ì¨²»¼ÓÈë¶îÍâ´«ÆæÊôÐÔ
            continue
        itemData = gameData.GetItemByTypeID(itemID)
        if not itemData:
            continue
        
        for effIndex in xrange(itemData.GetEffectCount()):
            curEff = itemData.GetEffectByIndex(effIndex)
            effID = curEff.GetEffectID()
            if effID == 0:
                break
            liantaiLegendAttrList.append([effID, curEff.GetEffectValue(0)])
    # Ö§³Ö¶àÊôÐÔ£¬°´ÊôÐÔID¡¢ÊýÖµÅÅÐò
    if liantaiLegendAttrList:
        liantaiLegendAttrList.sort(reverse=True)
    return liantaiComposeMakeID, liantaiLegendAttrList
 
def __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt):
    ## ¼ì²é¹Ì¶¨ÏûºÄµÀ¾ß, Ö»Òª¿Í»§¶ËÌá½»µÄÊý¾ÝÓв»·ûºÏÒªÇóµÄ£¬ÔòÖ±½Ó·µ»Ø None
 
    maxPackCount = itemPack.GetCount()
    fixedItemIndexDict = {} # {itemID:[[°ó¶¨Ë÷Òý], [·Ç°ó¶¨Ë÷Òý]], ...}
    fixedItemCntDict = {} # {itemID:[°ó¶¨¸öÊý, ·Ç°ó¶¨¸öÊý], ...}
    if len(fixedItemIDList) != len(fixedItemCountList):
        GameWorld.Log("¹Ì¶¨ÏûºÄÅäÖôíÎó!ÎÞ·¨ºÏ³É£¡fixedItemIDList=%s,fixedItemCountList=%s" 
                      % (fixedItemIDList, fixedItemCountList), playerID)
        return
    
    expireTime = 0
    for index in fixedItemIndexList:
        if index >= maxPackCount:
            GameWorld.Log("¸ÃÎïÆ·¸ñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨ºÏ³É£¡index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not __CheckItemCanUseCompound(playerID, index, curItem):
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉʹÓÃ!ÎÞ·¨ºÏ³É! ID=%s,index=%s" % (compoundID, index), playerID)
            return
        fixedItemID = curItem.GetItemTypeID()
        if fixedItemID not in fixedItemIDList:
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉÓÃÓںϳÉÄ¿±êÎïÆ·!ID=%s,index=%s,fixedItemID=%s not in fixedItemIDList=%s" 
                          % (compoundID, index, fixedItemID, fixedItemIDList), playerID)
            return
        
        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
        if isExpireItem:
            if not remainingTime:
                GameWorld.Log("¹Ì¶¨ÏûºÄµÀ¾ßʱЧÎïÆ·ÒÑʧЧ£¬ÎÞ·¨ºÏ³É! index=%s,fixedItemID=%s" % (index, fixedItemID), playerID)
                return
            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
            
        isBind = curItem.GetIsBind()
        itemCount = curItem.GetCount()
        bindIndex = 0 if isBind else 1
        
        fixedItemCntList = fixedItemCntDict.get(fixedItemID, [0, 0])
        fixedItemCntList[bindIndex] +=  itemCount
        fixedItemCntDict[fixedItemID] = fixedItemCntList
        
        fixedItemIndexinfoList = fixedItemIndexDict.get(fixedItemID, [[], []])
        fixedItemIndexinfoList[bindIndex].append(index)
        fixedItemIndexDict[fixedItemID] = fixedItemIndexinfoList
        
    GameWorld.DebugLog("¹Ì¶¨ÏûºÄÎïÆ·IDË÷Òý:%s, ¸öÊý[°ó,²»°ó]:%s" % (fixedItemIndexDict, fixedItemCntDict))
    # ×°±¸¡¢³á°òºÏ³ÉÓÅÏÈÑ¡Ôñ²»°ó¶¨£» µÀ¾ß¡¢ÃÅÆ±ºÏ³ÉÓÅÏÈÑ¡Ôñ°ó¶¨£¨³ÌÐò£©
    # ÒòΪװ±¸¡¢³á°òĬÈÏÖ»ÄܺϳÉ1¸ö£¬ËùÒÔÈ«ÓÉǰ¶ËÑ¡ÔñµÄ²ÄÁÏÀ´¾ö¶¨°ó¶¨Óë·ñ
    # ÕâÀïÖ»´¦ÀíµÀ¾ßÀ࣬ĬÈÏÓÅÏȰó¶¨
    
    # ÏÈͳ¼ÆÇ°¶ËÌá½»µÄ²ÄÁÏË÷Òý×ܲÄÁÏÊý¿ÉºÏ³ÉµÄ×ÜÊý
    canCompoundBindCount = -1 # ×ܿɺϳɴ¿°ó¸öÊý, ¶àÖÖ²ÄÁÏÈ¡×îСµÄÄǸö
    canCompoundUnBindCount = -1 # ×ܿɺϳɴ¿·Ç°ó¸öÊý, ¶àÖÖ²ÄÁÏÈ¡×îСµÄÄǸö
    for index, fixedItemID in enumerate(fixedItemIDList):
        needCount = fixedItemCountList[index]
        totalNeedCount = needCount * compoundCnt
        bindCnt, unBindCnt = fixedItemCntDict.get(fixedItemID, [0, 0])
        itemTotalCnt = bindCnt + unBindCnt
        if itemTotalCnt < totalNeedCount:
            GameWorld.Log("¹Ì¶¨ÏûºÄµÀ¾ß²»×㣬ÎÞ·¨ºÏ³É!ID=%s,fixedItemID=%s,totalNeedCount=%s*%s(%s) > itemTotalCnt=%s" 
                          % (compoundID, fixedItemID, needCount, compoundCnt, totalNeedCount, itemTotalCnt), playerID)
            return
        
        if canCompoundBindCount == -1:
            canCompoundBindCount = bindCnt / needCount
        else:
            canCompoundBindCount = min(canCompoundBindCount, bindCnt / needCount)
            
        if canCompoundUnBindCount == -1:
            canCompoundUnBindCount = unBindCnt / needCount
        else:
            canCompoundUnBindCount = min(canCompoundUnBindCount, unBindCnt / needCount)
                
    canCompoundBindCount = max(0, canCompoundBindCount)
    canCompoundUnBindCount = max(0, canCompoundUnBindCount)
    
    # °ó¶¨ÓÅÏÈ
    bindFirst = True
    compoundBindCnt = 0
    compoundUnBindCnt = 0
    lackCnt = 0
    
    # ´¿µÄ¹»
    if (canCompoundBindCount + canCompoundUnBindCount) >= compoundCnt:
        if bindFirst:
            compoundBindCnt = min(compoundCnt, canCompoundBindCount)
            compoundUnBindCnt = compoundCnt - compoundBindCnt
        else:
            compoundUnBindCnt = min(compoundCnt, canCompoundUnBindCount)
            compoundBindCnt = compoundCnt - compoundUnBindCnt
    else:
        compoundUnBindCnt = canCompoundUnBindCount
        compoundBindCnt = canCompoundBindCount
        lackCnt = compoundCnt - compoundUnBindCnt - compoundBindCnt
        
    GameWorld.DebugLog("×ܿɺϳÉ: ´¿°ó=%s, ´¿²»°ó=%s, »¹²î=%s" % (canCompoundBindCount, canCompoundUnBindCount, lackCnt))
    
    compoundBindCnt += lackCnt # ·Ç´¿µÄ¶¼Áбí°ó¶¨Êý
    GameWorld.DebugLog("×îÖպϳÉ: °ó=%s, ²»°ó=%s" % (compoundBindCnt, compoundUnBindCnt))
    
    fixedItemNeedCntDict = {} # {itemID:[¿Û³ý°ó¶¨¸öÊý, ¿Û³ý·Ç°ó¶¨¸öÊý], ...}
    for index, fixedItemID in enumerate(fixedItemIDList):
        needCount = fixedItemCountList[index]
        totalNeedCount = needCount * compoundCnt
        bindCnt, unBindCnt = fixedItemCntDict.get(fixedItemID, [0, 0])
        costBindCnt = min(bindCnt, compoundBindCnt * needCount)
        costUnBindCnt = totalNeedCount - costBindCnt
        fixedItemNeedCntDict[fixedItemID] = [costBindCnt, costUnBindCnt]
        
        costTotalCnt = costBindCnt + costUnBindCnt
        if costTotalCnt < totalNeedCount:
            GameWorld.ErrLog("×îÖÕ¼ÆËãÏûºÄ×ÜÊýÓëʵ¼ÊËùÐè²»·û!ÎÞ·¨ºÏ³É!costBindCnt(%s) + costUnBindCnt(%s)=%s < totalNeedCount(%s)" 
                             % (costBindCnt, costUnBindCnt, costTotalCnt, totalNeedCount))
            return
        
    GameWorld.DebugLog("×îÖÕÏûºÄ²ÄÁϸöÊý: %s" % (fixedItemNeedCntDict))
    return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime
 
 
def __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax):
    ## ¼ì²é¸½¼Ó²ÄÁÏ
    
#    ComposeAddonsType    1|2|3|4|5    0    0    0    0    ¿É¸½¼ÓÎïÆ·ÀàÐÍ
#    ComposeAddonsQuality    4|2    0    0    0    0        ½×ÊýºÍÑÕÉ«
#    ComposeAddonsFormula    level*10    0    0    0    0        ¼ÆËãºÏ³Éʱ¸½¼Ó²ÄÁÏÔö¼ÓµÄ¼¸Âʹ«Ê½
 
    addSuccRateItemInfo = []
    composeAddonsTypeList = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsType")
    classLV, color = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsQuality", 1)
    ComposeAddonsFormula = IpyGameDataPY.GetFuncCfg("ComposeAddonsFormula")
    
    maxPackCount = itemPack.GetCount()
    if len(addonsItemIndexList) != len(addonsItemCountList):
        GameWorld.Log("¸½¼ÓÏûºÄ²ÄÁÏÊý¾Ý´íÎó!ÎÞ·¨ºÏ³É£¡addonsItemIndexList=%s,addonsItemCountList=%s" 
                      % (addonsItemIndexList, addonsItemCountList), playerID)
        return
    
    expireTime = 0
    useCount = 0
    addTotalSuccRate = 0
    for i, index in enumerate(addonsItemIndexList):
        if index >= maxPackCount:
            GameWorld.Log("¸ÃÎïÆ·¸ñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨ºÏ³É£¡index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not __CheckItemCanUseCompound(playerID, index, curItem):
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉʹÓÃ!ÎÞ·¨ºÏ³É! ID=%s,index=%s" % (compoundID, index), playerID)
            return
        
        itemID = curItem.GetItemTypeID()
        itemType = curItem.GetType()
        if itemType not in composeAddonsTypeList:
            GameWorld.Log("¸ÃÎïÆ·ÀàÐͲ»¿É×÷Ϊ¸½¼Ó²ÄÁÏ!ÎÞ·¨ºÏ³É! index=%s,itemID=%s,itemType=%s,composeAddonsTypeList=%s" 
                          % (index, itemID, itemType, composeAddonsTypeList), playerID)
            return
        
        itemColor = curItem.GetItemColor()
        if itemColor < color:
            GameWorld.Log("¸ÃÎïÆ·ÑÕÉ«²»¿É×÷Ϊ¸½¼Ó²ÄÁÏ!ÎÞ·¨ºÏ³É! index=%s,itemID=%s,itemColor=%s < %s" 
                          % (index, itemID, itemColor, color), playerID)
            return
        
        itemColor = curItem.GetItemColor()
        itemClassLV = ItemCommon.GetItemClassLV(curItem)
        if itemClassLV < classLV:
            GameWorld.Log("¸ÃÎïÆ·½×¼¶²»¿É×÷Ϊ¸½¼Ó²ÄÁÏ!ÎÞ·¨ºÏ³É! index=%s,itemID=%s,itemClassLV=%s < %s" 
                          % (index, itemID, itemClassLV, classLV), playerID)
            return
        costCount = addonsItemCountList[i]
        if costCount <= 0 or costCount > curItem.GetCount():
            GameWorld.Log("¸Ã¸½¼ÓÎïÆ·¸öÊý²»×ã,ÎÞ·¨ºÏ³É! index=%s,itemID=%s,costCount=%s" % (index, itemID, costCount), playerID)
            return
        useCount += costCount
        if useCount > addonsCountMax:
            GameWorld.Log("¸½¼ÓÎïÆ·×ܸöÊý³¬³öÏÞÖÆ,ÎÞ·¨ºÏ³É! useCount=%s > addonsCountMax=%s" % (useCount, addonsCountMax), playerID)
            return
        
        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
        if isExpireItem:
            if not remainingTime:
                GameWorld.Log("¸½¼Ó²ÄÁÏʱЧÎïÆ·ÒÑʧЧ£¬ÎÞ·¨ºÏ³É! index=%s,itemID=%s" % (index, itemID), playerID)
                return
            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
            
        addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula))
        addTotalSuccRate += (addSuccRate*costCount)
        addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount})
        
    return int(addTotalSuccRate), addSuccRateItemInfo, expireTime
 
def __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount):
    ## ¼ì²éÌáÉý¸ÅÂʵÀ¾ß, Ö»Òª¿Í»§¶ËÌá½»µÄÊý¾ÝÓв»·ûºÏÒªÇóµÄ£¬ÔòÖ±½Ó·µ»Ø None
    expireTime = 0
    incRateItemTotalCount = 0
    incRateItemCostList = [[], []] # [[°ó¶¨Ë÷Òý], [·Ç°ó¶¨Ë÷Òý]]
    maxPackCount = itemPack.GetCount()
    for index in incRateItemIndexList:
        if index >= maxPackCount:
            GameWorld.Log("¸ÃÎïÆ·¸ñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨ºÏ³É£¡index=%s,maxPackCount=%s" % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not __CheckItemCanUseCompound(playerID, index, curItem):
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉʹÓÃ!ÎÞ·¨ºÏ³É! ID=%s,index=%s" % (compoundID, index), playerID)
            return
        itemID = curItem.GetItemTypeID()
        if itemID != incRateItemID:
            GameWorld.Log("¸ÃÎïÆ·²»¿ÉÓÃÓÚÌáÉýºÏ³ÉÄ¿±êÎïÆ·¸ÅÂÊ!ID=%s,index=%s,itemID=%s != incRateItemID=%s" 
                          % (compoundID, index, itemID, incRateItemID), playerID)
            return
        isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem)
        if isExpireItem:
            if not remainingTime:
                GameWorld.Log("ÌáÉý¸ÅÂÊʱЧÎïÆ·ÒÑʧЧ£¬ÎÞ·¨ºÏ³É! index=%s,itemID=%s" % (index, itemID), playerID)
                return
            expireTime = remainingTime if not expireTime else min(expireTime, remainingTime)
            
        isBind = curItem.GetIsBind()
        itemCount = curItem.GetCount()
        incRateItemTotalCount += itemCount
        incRateItemCostList[0].append(index) if isBind else incRateItemCostList[1].append(index)
        
    if incRateItemTotalCount < needIncRateItemCount:
        GameWorld.Log("ÌáÉý¸ÅÂÊÏûºÄµÀ¾ß²»×㣬ÎÞ·¨ºÏ³É!ID=%s,incRateItemID=%s,needIncRateItemCount=%s > incRateItemTotalCount=%s" 
                      % (compoundID, incRateItemID, needIncRateItemCount, incRateItemTotalCount), playerID)
        return
    
    return incRateItemCostList, expireTime
 
def __CheckItemCanUseCompound(playerID, index, curItem):
    if not ItemCommon.CheckItemCanUse(curItem):
        GameWorld.DebugLog("¸ÃÎïÆ·²»¿ÉʹÓÃ!ÎÞ·¨ºÏ³É! index=%s" % (index), playerID)
        return
    
    # ÓÐÏâǶ±¦Ê¯£¬Ì××°ÊôÐÔ£¬Ï´Á·ÊôÐÔµÄ×°±¸ÎÞ·¨×÷ΪºÏ³É²ÄÁÏʹÓÃ
    if ItemCommon.CheckHasStone(curItem):
        GameWorld.DebugLog("¸ÃÎïÆ·ÓÐÏâǶ±¦Ê¯!ÎÞ·¨ºÏ³É! index=%s" % (index), playerID)
        return
    
    if curItem.GetIsSuite():
        GameWorld.DebugLog("¸ÃÎïÆ·ÎªÌ××°!ÎÞ·¨ºÏ³É! index=%s" % (index), playerID)
        return
    
    # Ï´Á·ÊôÐÔ´ýÌí¼Ó...
    
    return True
 
 
## ¸øÓèкϳɵÄÎïÆ·
#  @param curPlayer: Íæ¼Ò
#  @param newItem: ÐÂÎïÆ·
#  @param itemCount: ºÏ³ÉÊýÁ¿
#  @return None
def GiveNewCompoundItem(curPlayer, packType, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo):
    compoundUnBindCnt = itemCount - compoundBindCnt
    
    if compoundBindCnt > 0:
        userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
    if compoundUnBindCnt > 0:
        userData = __GivePlayerCompoundItem(curPlayer, packType, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime, liantaiInfo)
        
    if not userData:
        return ""
    return userData
 
def __GivePlayerCompoundItem(curPlayer, packType, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, expireTime, liantaiInfo):
    playerID = curPlayer.GetPlayerID()
    if liantaiInfo:
        liantaiDecomposeIDCount, liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList = liantaiInfo
        if liantaiDecomposeIDCount:
            itemCount = liantaiDecomposeIDCount
            GameWorld.DebugLog("·Ö½âÁ«Ì¨Ë鯬×ܸöÊý: %s" % liantaiDecomposeIDCount, playerID)
        if liantaiComposeMakeID:
            newItemID = liantaiComposeMakeID
            GameWorld.DebugLog("Á«Ì¨ºÏ³ÉÄ¿±êÁ«Ì¨ÎïÆ·ID: %s, ËùÓÐÁ«Ì¨ID: %s, ¶îÍâ´«ÆæÊôÐÔ: %s, ËùÓм¼ÄÜID: %s" \
                               % (liantaiComposeMakeID, liantaiComposeAllItemIDList, liantaiLegendAttrList, liantaiComposeSkillIDList), playerID)
    curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, False, expireTime, curPlayer=curPlayer)
    if not curSingleItem:
        GameWorld.ErrLog("´´ÔìÎïÆ·Ê§°Ü, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
        return
    
    changeTagWingExp, materialItemDict = 0, {}
    if wingItemExpInfo:
        changeTagWingExp, materialItemDict = wingItemExpInfo
    wingFinalExp = changeTagWingExp
    
    wingProgressExIDList = IpyGameDataPY.GetFuncEvalCfg("WingInitialWashValue", 2)
    if newItemID in wingProgressExIDList:
        wingProgressExPerList = IpyGameDataPY.GetFuncEvalCfg("WingInitialWashValue", 1)
        addPer = GameWorld.GetResultByRandomList(wingProgressExPerList, 0)
        addValue = PlayerWing.GetWingProgressPerValueByID(newItemID, addPer)
        wingFinalExp += addValue
        GameWorld.Log("ºÏ³É³á°òËæ»úÔùË;«Á¶Öµ: newItemID=%s,addPer=%s,addValue=%s,changeTagWingExp=%s,wingFinalExp=%s,materialItemDict=%s" 
                      % (newItemID, addPer, addValue, changeTagWingExp, wingFinalExp, materialItemDict), playerID)
        
    if wingFinalExp:#¼Ì³Ð³á°ò¾«Á¶Öµ
        PlayerWing.WingProgressUP(curSingleItem, wingFinalExp, materialItemDict)
    if dogzEquipPlusExp:#¼Ì³ÐÉñÊÞ×°±¸ÊìÁ·¶È
        dogzEquipLV, dogzEquipExp = PlayerDogz.GetDogzEquipPlusLVExpInfo(curSingleItem.GetItemColor(), curSingleItem.GetEquipPlace(), dogzEquipPlusExp)
        curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipLV)
        curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipExp)
        remainExp = max(0, dogzEquipPlusExp - dogzEquipExp)
        GameWorld.DebugLog("ºÏ³ÉÉñÊÞ×°±¸³É¹¦, dogzEquipLV=%s,dogzEquipExp=%s,remainExp=%s,×ÜEXP=%s" 
                           % (dogzEquipLV, dogzEquipExp, remainExp, dogzEquipPlusExp), playerID)
        __SendDogzEquipRemainExpMail(playerID, remainExp, True)
        
    # ±£ÁôºÏ³É²ÄÁÏÏûºÄ£¬²ð½âʱÓÃ
    if decompoundItemInfo:
        curSingleItem.ClearUserAttr(ShareDefine.Def_IudetItemDecompound)
        for decompoundValue in decompoundItemInfo:
            curSingleItem.AddUserAttr(ShareDefine.Def_IudetItemDecompound, decompoundValue)
        GameWorld.Log("±£´æ¿É²ð½â×°±¸²ð½âÎïÆ·ÐÅÏ¢: %s" % decompoundItemInfo, playerID)
        
    # Á«Ì¨ÊôÐÔ
    if liantaiInfo:
        if liantaiComposeAllItemIDList:
            curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLiantaiItemID)
            for liantaiItemID in liantaiComposeAllItemIDList:
                curSingleItem.AddUserAttr(ShareDefine.Def_IudetLiantaiItemID, liantaiItemID)
                
        if liantaiComposeSkillIDList:
            curSingleItem.ClearUserAttr(ShareDefine.Def_IudetAddSkillID)
            for skillID in liantaiComposeSkillIDList:
                curSingleItem.AddUserAttr(ShareDefine.Def_IudetAddSkillID, skillID)
                
        if liantaiLegendAttrList:
            curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrID)
            curSingleItem.ClearUserAttr(ShareDefine.Def_IudetLegendAttrValue)
            for liantaiLegAttrID, liantaiLegAttrValue in liantaiLegendAttrList:
                curSingleItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrID, liantaiLegAttrID)
                curSingleItem.AddUserAttr(ShareDefine.Def_IudetLegendAttrValue, liantaiLegAttrValue)
                
        ItemCommon.MakeEquipGS(curSingleItem)
                
    userData = curSingleItem.GetUserData()
    if not ItemControler.PlayerItemControler(curPlayer).PutInItem(packType, curSingleItem, event=[ChConfig.ItemGive_ItemCompound, False, {}]):
        GameWorld.ErrLog("¸øºÏ³ÉÎïÆ·Ê§°Ü, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID)
        curSingleItem.Clear()
        return
    
    if liantaiInfo and liantaiDecomposeIDCount:
        PlayerControl.NotifyCode(curPlayer, "DecompoundLiantai", [liantaiDecomposeIDCount, newItemID])
        
    return userData
 
def __SendDogzEquipRemainExpMail(playerID, remainExp, isSucc):
    if not remainExp:
        return
    
    expItemID = IpyGameDataPY.GetFuncCfg("DogzAssist", 5)
    itemData = GameWorld.GetGameData().GetItemByTypeID(expItemID)
    if not itemData:
        return
    
    effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Effect_DogzEquipPlusExp)
    if not effect:
        GameWorld.ErrLog("ÉñÊÞ×°±¸ºÏ³É·µ»ØÊìÁ·¶ÈÎïÆ·ID´íÎó! expItemID=%s,remainExp=%s" % (expItemID, remainExp), playerID)
        return
    baseExp = effect.GetEffectValue(0)
    if not baseExp:
        GameWorld.ErrLog("ÉñÊÞ×°±¸ºÏ³É·µ»ØÊìÁ·¶ÈÎïÆ·ID´íÎó! expItemID=%s,baseExp=%s,remainExp=%s" 
                         % (expItemID, baseExp, remainExp), playerID)
        return
    
    giveItemCount = int(remainExp/baseExp)
    if giveItemCount <= 0:
        return
    
    mailTypeKey = "DogzComposeSuc" if isSucc else "DogzComposeLose"
    GameWorld.DebugLog("ºÏ³ÉÉñÊÞ×°±¸, ·µ»¹Ç¿»¯ÊìÁ·¶È=%s,baseExp=%s,expItemID=%s,giveItemCount=%s" 
                       % (remainExp, baseExp, expItemID, giveItemCount), playerID)
        
    isBind = 1
    PlayerControl.SendMailByKey(mailTypeKey, [playerID], [[expItemID, giveItemCount, isBind]])
    return
 
#// A3 13 ÎïÆ·²ð½â #tagCMItemDecompound
#
#struct    tagCMItemDecompound
#{
#    tagHead        Head;
#    BYTE        Index;    // ²ð½âÎïÆ·ËùÔÚ±³°üË÷Òý
#};
def OnItemDecompound(index, clientData, tick):    
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    
    decompoundItemIndex = clientData.Index
    GameWorld.DebugLog("Íæ¼Ò²ð½âÎïÆ·: decompoundItemIndex=%s" % decompoundItemIndex, playerID)
    
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    if decompoundItemIndex < 0 or decompoundItemIndex >= itemPack.GetCount():
        return
    curEquip = itemPack.GetAt(decompoundItemIndex)
    
    if not ItemCommon.CheckItemCanUse(curEquip):
        return
    
    attrCount = curEquip.GetUserAttrCount(ShareDefine.Def_IudetItemDecompound)
    if not attrCount:
        GameWorld.DebugLog("    ¸ÃÎïÆ·Ã»ÓмǼ²ð½âÎïÆ·ÐÅÏ¢£¬ÎÞ·¨²ð½â£¡", playerID)
        return
    
    giveItemList = []
    giveEquipID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, 0)
    if giveEquipID:
        giveItemList.append([giveEquipID, 1, curEquip.GetIsBind()])
        
    if attrCount > 1:
        for i in range(1, attrCount)[::3]:
            if i + 3 > attrCount:
                break
            itemID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i)
            itemCount = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 1)
            isBind = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 2)
            giveItemList.append([itemID, itemCount, isBind])
    
    needSpace = len(giveItemList)
    emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
    #ÑéÖ¤±³°ü¿Õ¼ä
    if needSpace > emptySpace:
        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
        return
    
    decompoundItemNoteDict = ItemCommon.GetItemNoteDict(curEquip, curEquip.GetCount())  
    
    # É¾³ý²ð½âµÄÎïÆ·
    saveDataDict = {"giveItemList":giveItemList}
    ItemCommon.DelItem(curPlayer, curEquip, curEquip.GetCount(), False, "ItemDecompound", saveDataDict, isForceDR=True)
    
    # ·µ»¹ÎïÆ·
    for itemID, itemCount, isBind in giveItemList:
        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem], 
                                     event=["ItemDecompound", True, {"decompoundItemNoteDict":decompoundItemNoteDict}])
        
    GameWorld.Log("²ð½âÎïÆ·³É¹¦: decompoundItemNoteDict=%s" % str(decompoundItemNoteDict), playerID)
    GameWorld.Log("    giveItemList=%s" % str(giveItemList), playerID)
    return