xdh
2019-01-28 8305e47be942c376430044332780e6e69a3c7a7f
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.PlayerGatherSoul
#
# @todo:Íæ¼Ò¾Û»ê
# @author xdh
# @date 2018-12-10
# @version 1.0
#
# ÏêϸÃèÊö: Íæ¼Ò¾Û»ê
#---------------------------------------------------------------------
#"""Version = 2018-12-10 12:00"""
#---------------------------------------------------------------------
 
import GameWorld
import ShareDefine
import ChConfig
import ItemCommon
import ItemControler
import PlayerControl
import ChPyNetSendPack
import NetPackCommon
import IpyGameDataPY
import FormulaControl
import DataRecordPack
import PlayerSuccess
 
g_GatherSoulLVExpDict = {}  #¾­Ñ黺´æ
g_gatherSoulLVAttrDict = {}  #ÊôÐÔ»º´æ
 
 
##µÇ¼´¦Àí
# @param curPlayer Íæ¼Ò
# @return None
def PlayerLogin(curPlayer):
    Sync_GatherSoulHoleInfo(curPlayer)
    return 
 
 
## »ñÈ¡¾Û»êipyÊý¾Ý
def GetGatherSoulIpyData(itemID):return IpyGameDataPY.GetIpyGameData("GatherSoul", itemID)
 
 
## »ñÈ¡¾Û»êÉý¼¶ÐèÒª¾­Ñé
def GetGatherSoulNeedExp(itemID, lv):
    global g_GatherSoulLVExpDict
    #£¨£¨Éý¼¶¾­Ñé * Æ·ÖÊϵÊý£©* Éñ»êϵÊý£©*  ¶àÊôÐÔϵÊý
 
    itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
    if not itemData:
        return 0
    ipyData = GetGatherSoulIpyData(itemID)
    if not ipyData:
        return 0
    itemColor = itemData.GetItemColor()
    if lv == 0:  #³õʼ¾­Ñé
        expDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 4, {})
        exp = expDict.get(itemColor, 0)
    else:
        if lv in g_GatherSoulLVExpDict:
            exp = g_GatherSoulLVExpDict[lv]
        else:
            level = lv + 1  #¹«Ê½´Ó1¿ªÊ¼
            exp = eval(IpyGameDataPY.GetFuncCompileCfg('GatherSoulLevelUp'))
            g_GatherSoulLVExpDict[lv] = exp
            
        qualityPerDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 2, {}).get(str(itemData.GetType()), {})
        if str(itemColor) in qualityPerDict:
            exp *= float(qualityPerDict[str(itemColor)])
            
        attrTypeCnt = len(ipyData.GetAttrType())
        specialPer = IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 3, {}).get(attrTypeCnt, 1)
        exp *= float(specialPer)
        
    soulGrade = ipyData.GetSoulGrade()
    exp *= float(IpyGameDataPY.GetFuncEvalCfg('GatherSoulLevelUp', 5, {}).get(soulGrade, 1))
    return int(exp)
 
 
## »ñÈ¡¾Û»êÊôÐÔÊýÖµ
def GetGatherSoulAttrValue(itemID, lv):
    global g_gatherSoulLVAttrDict
    #£¨£¨³õʼÊôÐÔ + Éý¼¶ÊôÐÔ * Æ·ÖÊϵÊý£©* Éñ»êϵÊý £© * ¶àÊôÐÔϵÊý
 
    itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
    if not itemData:
        return {}
    ipyData = GetGatherSoulIpyData(itemID)
    if not ipyData:
        return {}
    level = lv + 1  #¹«Ê½´Ó1¿ªÊ¼
    
    attrTypeList = ipyData.GetAttrType()
    attrTypeCnt = len(attrTypeList)  #ÊôÐÔÌõÊý
    soulGrade = ipyData.GetSoulGrade()
    itemColor = itemData.GetItemColor()
    attrDict = {}
    for attrType in attrTypeList:
        attrIpyData = IpyGameDataPY.GetIpyGameData('GatherSoulAttr', attrType)
        if not attrIpyData:
            GameWorld.ErrLog('    ¾Û»êÊôÐÔ±íδÅäÖøÃÊôÐÔ attrType=%s' % attrType)
            continue
        key = '%s_%s' % (attrType, level)
        if key in g_gatherSoulLVAttrDict:
            value = g_gatherSoulLVAttrDict[key]
        else:
            attrFormula = FormulaControl.GetCompileFormula('GatherSoulAttr%s' % attrType, attrIpyData.GetAttrInfo1())
            if not attrFormula:
                continue
            value = eval(attrFormula)
            g_gatherSoulLVAttrDict[key] = value
        qualityPerDict = attrIpyData.GetAttrInfo2()
        if itemColor in qualityPerDict:
            value *= float(qualityPerDict[itemColor])
        extraValueDict = attrIpyData.GetAttrInfo4()
        value += extraValueDict.get(itemColor, 0)
        #½×¶ÎϵÊý
        value *= float(attrIpyData.GetAttrInfo5().get(soulGrade, 1))
        #ÊôÐÔÌõĿϵÊý
        specialPer = attrIpyData.GetAttrInfo3().get(attrTypeCnt, 1)
        value *= float(specialPer)
            
        attrDict[int(attrType)] = int(value)
    return attrDict
 
 
def GetGatherSoulMaxLV(itemID):
    # »ñÈ¡¾Û»ê×î´óµÈ¼¶
    itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
    if not itemData:
        return 0
    GatherSoulMaxLVDict = IpyGameDataPY.GetFuncEvalCfg('GatherSoulMaxLevel', 1, {})
    itemColor = itemData.GetItemColor()
    GatherSoulMaxLV = GatherSoulMaxLVDict.get(itemColor, 0)
    return GatherSoulMaxLV
 
 
def SwitchGatherSoul(curPlayer, srcBackpack, desBackPack, srcIndex, destIndex):
    # ÏâǶ/ժϾۻê
    if not ((desBackPack == ShareDefine.rptGatherSoul and srcBackpack == ShareDefine.rptTempSwap) \
            or (srcBackpack == ShareDefine.rptGatherSoul and desBackPack == ShareDefine.rptTempSwap)):
        return False
    playerID = curPlayer.GetPlayerID()
    GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})
    maxGatherSoulHole = len(GatherSoulUnlockDict)
    # ´©
    if desBackPack == ShareDefine.rptTempSwap:
        desGatherSoulNum = destIndex
        if desGatherSoulNum < 0 or desGatherSoulNum >= maxGatherSoulHole:
            GameWorld.DebugLog("²»´æÔڸþۻê¿×! desGatherSoulNum=%s" % desGatherSoulNum, playerID)
            return True
        
        if curPlayer.GetLV() < GatherSoulUnlockDict.get(desGatherSoulNum, 0):
            GameWorld.DebugLog("¸Ã¾Û»ê¿×δ½âËø! desGatherSoulNum=%s,needlv=%s" % (desGatherSoulNum, GatherSoulUnlockDict.get(desGatherSoulNum, 0)), playerID)
            return True
        
        srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem 
                                                     % (ShareDefine.rptGatherSoul, srcIndex))  # ¾Û»ê±³°üÖеÄÖµ
        if not srcGatherSoulData:
            GameWorld.DebugLog("¾Û»ê±³°ü¸ÃλÖÃûÓоۻê! srcIndex=%s" % srcIndex, playerID)
            return True
        srcGatherSoulItemID = ItemControler.GetGatherSoulItemID(srcGatherSoulData)
        srcItemData = GameWorld.GetGameData().GetItemByTypeID(srcGatherSoulItemID)
        if not srcItemData:
            return
        srcGatherSoulType = srcItemData.GetType()
        needItemType = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 2, {}).get(desGatherSoulNum, 0)
        if srcGatherSoulType != needItemType:
            GameWorld.DebugLog("¸Ã¾Û»ê¿×²»ÄÜÏâǶ¸Ã¾Û»êÀàÐÍ! desGatherSoulNum=%s£¬srcGatherSoulType=%s,needItemType=%s" % (desGatherSoulNum, srcGatherSoulType, needItemType), playerID)
            return
        
        srcIpyData = GetGatherSoulIpyData(srcGatherSoulItemID)
        if not srcIpyData:
            GameWorld.Log("¸Ã¾Û»êûÓÐÅäÖÃÊôÐÔ! ÎÞ·¨ÏâǶ! itemID=%s" % srcGatherSoulItemID, playerID)
            return True
        
        srcGatherSoulAttrTypeList = srcIpyData.GetAttrType()
        # ÅжÏÊÇ·ñÒÑÓÐÏâǶ¸ÃÊôÐÔÀàÐÍ
        for GatherSoulNum in xrange(maxGatherSoulHole):
            if GatherSoulNum == desGatherSoulNum:  # Ä¿±ê¿×²»ÅжÏ
                continue
            GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % GatherSoulNum, 0)
            if not GatherSoulData:
                continue
            GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
            ipyData = GetGatherSoulIpyData(GatherSoulItemID)
            if not ipyData:
                continue
            attrTypeList = ipyData.GetAttrType()
            if set(srcGatherSoulAttrTypeList) & set(attrTypeList):
                GameWorld.DebugLog("ÒÑÓÐÏâǶ¸ÃÊôÐÔÀàÐÍ! ÎÞ·¨ÏâǶ! GatherSoulHoleNum=%s,attrTypeList=%s,srcGatherSoulAttrTypeList=%s" % (GatherSoulNum, attrTypeList, srcGatherSoulAttrTypeList), playerID)
                return True
       
        desGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % desGatherSoulNum, 0)  # ¿×ÉϵÄÖµ
        
        # ÉèÖþۻê¿×Êý¾Ý
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % desGatherSoulNum, srcGatherSoulData)
        # Ô­À´µÄ¿×Êý¾Ý£¬Ôò·ÅÈë¾Û»ê±³°üÖÐ
        ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, srcIndex, desGatherSoulData)
 
    else:  #ÍÑ
        srcGatherSoulNum = srcIndex
        srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % srcGatherSoulNum, 0)
        if not srcGatherSoulData:
            GameWorld.DebugLog("¸Ã¾Û»ê¿×ûÓÐÏâǶ¾Û»ê! srcGatherSoulNum=%s, srcGatherSoulData=%s" % (srcGatherSoulNum, srcGatherSoulData), curPlayer.GetPlayerID())
            return True
        
        emptyIndex = ItemCommon.GetEmptyIndexInPack(curPlayer, ShareDefine.rptGatherSoul)
        if emptyIndex == -1:
            GameWorld.DebugLog("¾Û»ê±³°üÒÑÂú£¬ÎÞ·¨ÕªÏÂ! ", curPlayer.GetPlayerID())
            return True
        desGatherSoulData = 0
        # ÕªÏÂÉèÖÿ×Êý¾ÝΪ0
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % srcGatherSoulNum, 0)
        ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, emptyIndex, srcGatherSoulData)
    dataDict = {'desBackPack':desBackPack, 'srcGatherSoulData':srcGatherSoulData, 'desGatherSoulData':desGatherSoulData}
    DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_GatherSoul, dataDict)
    RefreshGatherSoulAttr(curPlayer)
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    Sync_GatherSoulHoleInfo(curPlayer)
    DoGatherSoulSuccessLogic(curPlayer)
    return True
 
 
#// A5 18 ¾Û»êÉý¼¶ #tagCMGatherSoulUp
#struct    tagCMGatherSoulUp
#{
#    tagHead        Head;
#    BYTE        PlaceType;    // Î»ÖÃÀàÐÍ£»0-±³°ü£¬1-¿×
#    WORD        PlaceIndex;    // Î»ÖÃË÷Òý
#};
def OnGatherSoulUp(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    placeType = clientData.PlaceType
    placeIndex = clientData.PlaceIndex
    if placeType == 0:
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (ShareDefine.rptGatherSoul, placeIndex))
    elif placeType == 1:
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % (placeIndex), 0)
    else:
        return
    
    playerID = curPlayer.GetPlayerID()
    if not GatherSoulData:
        GameWorld.DebugLog("¸ÃλÖò»´æÔÚ¾Û»ê, ÎÞ·¨Éý¼¶! placeType=%s,placeIndex=%s" % (placeType, placeIndex), playerID)
        return
    
    GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
    GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)
 
    itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)
    if not itemData:
        return
    
    GatherSoulMaxLV = GetGatherSoulMaxLV(GatherSoulItemID)
    if GatherSoulItemPlusLV + 1 >= GatherSoulMaxLV:
        GameWorld.DebugLog('¸Ã¾Û»êÒÑÂú¼¶£¬ÎÞ·¨Éý¼¶£¡GatherSoulMaxLV=%s' % GatherSoulMaxLV)
        return
    
    plusCost = GetGatherSoulNeedExp(GatherSoulItemID, GatherSoulItemPlusLV + 1)
    plusCost = int(plusCost)
    if not plusCost:
        GameWorld.DebugLog("¸Ã¾Û»êÎÞ·¨Éý¼¶!  placeType=%s,placeIndex=%s,itemID=%s,plusLV=%s" 
                           % (placeType, placeIndex, GatherSoulItemID, GatherSoulItemPlusLV), playerID)
        return
 
    updGatherSoulData = ItemControler.GetGatherSoulItemKeyData(GatherSoulItemID, GatherSoulItemPlusLV + 1)
    if not PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, plusCost):
        curGatherSoulMoney = PlayerControl.GetMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust)
        GameWorld.DebugLog("¾Û»ê³¾µã²»×㣬ÎÞ·¨Éý¼¶!placeType=%s,placeIndex=%s,itemID=%s,plusLV=%s,plusCost=%s,curGatherSoulMoney=%s" 
                           % (placeType, placeIndex, GatherSoulItemID, GatherSoulItemPlusLV, plusCost, curGatherSoulMoney), playerID)
        return
    
    if placeType == 0:
        ItemControler.SetVPackItemKeyData(curPlayer, ShareDefine.rptGatherSoul, placeIndex, updGatherSoulData)
    elif placeType == 1:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % (placeIndex), updGatherSoulData)
        RefreshGatherSoulAttr(curPlayer)
        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
        Sync_GatherSoulHoleInfo(curPlayer)
        DoGatherSoulSuccessLogic(curPlayer)
    GameWorld.DebugLog("¾Û»êÉý¼¶!placeType=%s,placeIndex=%s,GatherSoulData=%s,updGatherSoulData=%s" 
                       % (placeType, placeIndex, GatherSoulData, updGatherSoulData), playerID)
    return
 
 
#// A5 19 ¾Û»ê·Ö½â #tagCMGatherSoulDecompose
#
#struct    tagCMGatherSoulDecompose
#{
#    tagHead        Head;
#    BYTE        IsAuto;    // ÊÇ·ñ×Ô¶¯·Ö½â
#    BYTE        Count;    // Ö¸¶¨ÅúÁ¿·Ö½âÊý£¬×î´ó²»³¬¹ý50¸ö
#    WORD        PlaceIndexList[Count];    // ÅúÁ¿·Ö½âλÖÃË÷ÒýÁбí
#};
def OnGatherSoulDecompose(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    isAuto = clientData.IsAuto
    placeList = clientData.PlaceIndexList
    
    delPlaceDict = {}
    totalSoulDust = 0
    totalSoulSplinters = 0
    totalSoulCore = 0
    giveMaterialDict = {}
    needPackSpace = 0
    packIndex = ShareDefine.rptGatherSoul
    
    for place in placeList:
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (packIndex, place))
        if not GatherSoulData:
            continue
        
        GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
        GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)
        itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)
        if not itemData:
            continue
        soulidList, soulSplinters, soulCore, soulDust = [], 0, 0, 0
        if itemData.GetType() == ChConfig.Def_ItemType_GatherSoulExp:  #¾«»ªÎïÆ·¶ÁЧ¹ûÖµ
            curEff = itemData.GetEffectByIndex(0)
            soulDust = curEff.GetEffectValue(0)
        else:
            #ÏȼÆËãÉý¼¶ÏûºÄµÄ²ÄÁÏ
            soulDust = 0
            for lv in xrange(1, GatherSoulItemPlusLV + 1):
                soulDust += GetGatherSoulNeedExp(GatherSoulItemID, lv)
                    
            #¶àÊôÐÔµÄÏȲð½â³Éµ¥ÊôÐԵľۻê
            soulidList, soulSplinters, soulCore = __GetGatherSoulSplitMaterial(GatherSoulItemID)
            for itemID in soulidList:
                giveMaterialDict[itemID] = giveMaterialDict.get(itemID, 0) + 1
                needPackSpace += 1
            if not soulidList and not soulSplinters and not soulCore:
                #²»Äܲð½âµÄÔòÒªËã0¼¶µÄ·Ö½â
                soulDust += GetGatherSoulNeedExp(GatherSoulItemID, 0)
                
 
        totalSoulSplinters += soulSplinters
        totalSoulCore += soulCore
        totalSoulDust += soulDust
        delPlaceDict[place] = [GatherSoulData, soulidList, int(soulDust), soulSplinters, soulCore]
        
    if not delPlaceDict:
        return
    if delPlaceDict:
        ItemCommon.DelVPackItem(curPlayer, packIndex, delPlaceDict.keys(), ChConfig.ItemDel_GatherSoul)
    addDataDict = {"delPlaceDict":delPlaceDict, "isAuto":isAuto}
    if totalSoulDust:
        totalSoulDust = int(totalSoulDust)
        PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, totalSoulDust,
                                ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)
        PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulDust, ShareDefine.TYPE_Price_SoulDust])
    if totalSoulSplinters:
        PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulSplinters, totalSoulSplinters,
                                ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)
        PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulSplinters, ShareDefine.TYPE_Price_SoulSplinters])
    if totalSoulCore:
        PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulCore, totalSoulCore,
                                ChConfig.Def_GiveMoney_GatherSoulDecompose, addDataDict, False)
        PlayerControl.NotifyCode(curPlayer, 'hwj_20170807_1', [totalSoulCore, ShareDefine.TYPE_Price_SoulCore])
        
    if giveMaterialDict:
        emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptGatherSoul, needPackSpace)
        if emptySpace < needPackSpace:
            giveMaterialList = [[itemID, itemCnt, 0] for itemID, itemCnt in giveMaterialDict.items()]
            PlayerControl.SendMailByKey('JHBagFull1', [curPlayer.GetID()], giveMaterialList)
        else:
            for itemID, itemCnt in giveMaterialDict.items():
                ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [ShareDefine.rptGatherSoul])
    GameWorld.DebugLog("¾Û»ê·Ö½â: isAuto=%s,PlaceIndexList=%s, delPlaceDict=%s, giveMaterialDict=%s" % (isAuto, placeList, delPlaceDict, giveMaterialDict))
    if not isAuto:
        curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitGatherSoulDecompose, 1)
    return
 
 
def __GetGatherSoulSplitMaterial(gathersoulID):
    ##²ð½â¶àÊôÐԾۻ꠷µ»Øµ¥ÊôÐÔ¾Û»êID,²ÄÁÏ
    soulidList, soulSplinters, soulCore= [], 0, 0
    compoundIpyData = IpyGameDataPY.GetIpyGameDataNotLog('GatherSoulCompound', gathersoulID)
    if compoundIpyData:
        materialList = compoundIpyData.GetNeedItem()
        soulSplinters += compoundIpyData.GetNeedSoulSplinters()
        soulCore += compoundIpyData.GetNeedSoulCore()
        for itemID in materialList:
#            soulIpyData = GetGatherSoulIpyData(itemID)
#            if soulIpyData and len(soulIpyData.GetAttrType()) > 1:
#                __GetGatherSoulSplitMaterial(itemID, soulidList, soulSplinters, soulCore)
#            else:
            soulidList.append(itemID)
    return soulidList, soulSplinters, soulCore
 
 
#// A5 1C ¾Û»êºÏ³É #tagCMGatherSoulCompound
#
#struct    tagCMGatherSoulCompound
#{
#    tagHead        Head;
#    BYTE        Cnt;
#    BYTE        PackList[Cnt];    //ËùÔÚλÖà0-±³°ü 1-¿×
#    WORD        IndexList[Cnt];    //ÎïÆ·Ë÷Òý
#    DWORD        TagItemID;    //ºÏ³ÉÄ¿±êÎïÆ·ID
#};
def OnGatherSoulCompound(index, clientData, tick):
    ##¾Û»êºÏ³É
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    tagItemID = clientData.TagItemID
    packList = clientData.PackList
    indexList = clientData.IndexList
    GameWorld.DebugLog('    ¾Û»êºÏ³É tagItemID=%s' % tagItemID)
    ipyData = IpyGameDataPY.GetIpyGameData('GatherSoulCompound', tagItemID)
    if not ipyData:
        return
    if curPlayer.GetLV() < ipyData.GetNeedLV():
        return
    
    materialsIDList = []
    materialsLVDict = {}
    indexList1 = []  #±³°üµÄ¾Û»êË÷Òý
    indexList2 = []  #¿×Ë÷Òý
    for i, placeType in enumerate(packList):
        index = indexList[i]
        if placeType == 0:
            GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_VPackItem % (ShareDefine.rptGatherSoul, index))  # ¾Û»ê±³°üÖеÄÖµ
            indexList1.append(index)
        else:
            GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % (index), 0)
            indexList2.append(index)
        if not GatherSoulData:
            continue
        GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
        GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)
        materialsIDList.append(GatherSoulItemID) 
        materialsLVDict[GatherSoulItemID] = GatherSoulItemPlusLV
    
    needItemIDList = ipyData.GetNeedItem()
    if sorted(materialsIDList) != sorted(needItemIDList):
        GameWorld.DebugLog('    ¾Û»êºÏ³É ²ÄÁϲ»¶Ô tagItemID=%s, materialsIDList=%s, needItemIDList=%s' % (tagItemID, materialsIDList, needItemIDList))
        return
    
    if 0 not in packList:
        #Èç¹ûûÓб³°üµÄ²ÄÁÏÒªÅжϸñ×ÓÊý
        emptySpace = ItemCommon.GetItemPackSpace(curPlayer, ShareDefine.rptGatherSoul, 1)
        if emptySpace < 1:
            PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [ShareDefine.rptGatherSoul])
            GameWorld.DebugLog('    ¾Û»êºÏ³É ±³°ü¸ñ×ÓÊýÁ¿²»×ã1¸ö')
            return 
        
    costMoneyDict = {ShareDefine.TYPE_Price_SoulSplinters:ipyData.GetNeedSoulSplinters(),
                     ShareDefine.TYPE_Price_SoulCore:ipyData.GetNeedSoulCore(), }
    for moneyType, costMoney in costMoneyDict.items():
        if not PlayerControl.HaveMoney(curPlayer, moneyType, costMoney):
            GameWorld.DebugLog('¾Û»êºÏ³ÉÇ®²»¹» moneyType=%s, costMoney=%s'%(moneyType, costMoney))
            return
    
    infoDict = {"TagItemID":tagItemID}
    for moneyType, costMoney in costMoneyDict.items():
        PlayerControl.PayMoney(curPlayer, moneyType, costMoney, ChConfig.Def_Cost_ItemProduce, infoDict)
     
    totalPoint = 0
    for itemID in materialsIDList:
        decompose = 0
        GatherSoulItemPlusLV = materialsLVDict.get(itemID, 0)
        for lv in range(1, GatherSoulItemPlusLV + 1):
            decompose += GetGatherSoulNeedExp(itemID, lv)
        totalPoint += decompose
    totalPoint = int(totalPoint)
    tagItemLV = 0
 
    GatherSoulMaxLV = GetGatherSoulMaxLV(tagItemID)
    for lv in xrange(1, GatherSoulMaxLV):
        needExp = GetGatherSoulNeedExp(tagItemID, lv)
        if totalPoint < needExp:
            break
        tagItemLV = lv
        totalPoint -= needExp
    
    #ɾ³ý²ÄÁÏÎïÆ·
    if indexList1:
        ItemCommon.DelVPackItem(curPlayer, ShareDefine.rptGatherSoul, indexList1, ChConfig.ItemDel_GatherSoul)
    if indexList2:
        for index in indexList2:
            srcGatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % index, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GatherSoulHoleData % index, 0)
            dataDict = {'doType':'GatherSoulCompound', 'srcGatherSoulData':srcGatherSoulData, 'desGatherSoulData':0}
            DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_GatherSoul, dataDict)
            
        Sync_GatherSoulHoleInfo(curPlayer)
        RefreshGatherSoulAttr(curPlayer)
        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    #·µ»¹¶àÓà»ê³¾
    totalPoint = int(totalPoint)
    if totalPoint > 0:
        PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_SoulDust, totalPoint)
    #¸øÐÂÎïÆ·
    curItem = ItemControler.GetOutPutItemObj(tagItemID)
    curItem.SetUserAttr(ShareDefine.Def_IudetGatherSoulLV, tagItemLV)
    PlayerItemControler = ItemControler.PlayerItemControler(curPlayer)
    PlayerItemControler.PutInItem(ShareDefine.rptGatherSoul, curItem, event=[ChConfig.ItemGive_ItemCompound, False, {'indexList1':indexList1, 'indexList2':indexList2, 'soulDust':totalPoint}])
    GameWorld.DebugLog('    ¾Û»êºÏ³É ³É¹¦')
    curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitGatherSoulCompound, 1)
    return
 
 
def DoGatherSoulSuccessLogic(curPlayer):
    #¾Û»ê³É¾Í´¦Àí
    #Çåµô#ÏâǶXöXÆ·ÖʾۻêµÄ³É¾ÍÐÅÏ¢
    PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayGatherSoul)
    totalLV = 0
    GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})
    maxGatherSoulHole = len(GatherSoulUnlockDict)
    for holeNum in xrange(maxGatherSoulHole):
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % holeNum, 0)
        if not GatherSoulData:
            continue
        GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
        itemData = GameWorld.GetGameData().GetItemByTypeID(GatherSoulItemID)
        if not itemData:
            continue
#        if itemData.GetType() == ChConfig.Def_ItemType_GatherSoulCore:
#            continue
        itemColor = itemData.GetItemColor()
        GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData) + 1 #¿Í»§¶Ë1¿ªÊ¼
        totalLV += GatherSoulItemPlusLV
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayGatherSoul, 1, [itemColor])
    PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GatherSoulLvUp, totalLV)
    return
 
def RefreshGatherSoulAttr(curPlayer):
    allAttrList = [{} for _ in range(4)]
    GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})
    maxGatherSoulHole = len(GatherSoulUnlockDict)
    for holeNum in xrange(maxGatherSoulHole):
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % holeNum, 0)
        if not GatherSoulData:
            continue
        GatherSoulItemID = ItemControler.GetGatherSoulItemID(GatherSoulData)
        GatherSoulItemPlusLV = ItemControler.GetGatherSoulItemPlusLV(GatherSoulData)
        
        attrDict = GetGatherSoulAttrValue(GatherSoulItemID, GatherSoulItemPlusLV)
        
        if not attrDict:
            continue
        GameWorld.DebugLog('    Ë¢¾Û»êÊôÐÔ holeNum=%s, attrDict=%s' % (holeNum, attrDict))
        for attrID, attrValue in attrDict.items():
            PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
        
    # ±£´æ¼ÆËãÖµ
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GatherSoul, allAttrList)
    
    return
 
 
def Sync_GatherSoulHoleInfo(curPlayer):
    ##֪ͨ¾Û»ê¿×ÐÅÏ¢
    GatherSoulUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GatherSoulHole", 1, {})
    maxGatherSoulHole = len(GatherSoulUnlockDict)
    GatherSoulInfoPack = ChPyNetSendPack.tagMCGatherSoulHoleInfo()
    GatherSoulInfoPack.Clear()
    GatherSoulInfoPack.GatherSoulDataList = []
    for GatherSoulNum in xrange(maxGatherSoulHole):
        GatherSoulData = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GatherSoulHoleData % GatherSoulNum, 0)
        GatherSoulInfoPack.GatherSoulDataList.append(GatherSoulData)
    GatherSoulInfoPack.Count = len(GatherSoulInfoPack.GatherSoulDataList)
    NetPackCommon.SendFakePack(curPlayer, GatherSoulInfoPack)
    return