hxp
2025-12-01 dd58f295c4eda273b8274cf43221b0262834dbb0
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerBeauty
#
# @todo:ºìÑÕ
# @author hxp
# @date 2025-11-21
# @version 1.0
#
# ÏêϸÃèÊö: ºìÑÕ
#
#-------------------------------------------------------------------------------
#"""Version = 2025-11-21 17:00"""
#-------------------------------------------------------------------------------
 
import ChConfig
import GameWorld
import ItemCommon
import PlayerOnline
import PlayerControl
import IpyGameDataPY
import ChPyNetSendPack
import PlayerGoldRush
import NetPackCommon
import ItemControler
import PyGameData
import PlayerTask
import FBCommon
import ObjPool
 
# ºìÑÕ½âËø·½Ê½
(
UnlockWay_Item, # ÎïÆ·½âËø 1
UnlockWay_TaskID, # Íê³ÉÖ÷ÏßÈÎÎñID 2
UnlockWay_ArenaWinCnt, # ÑÝÎ䳡ʤÀû´ÎÊý 3
UnlockWay_GoldRushWorker, # ÓµÓм๤ÊýÁ¿ 4
UnlockWay_FBZhanchui, # °×¹ÇÓ¯Ò°¹ý¹Ø 5
UnlockWay_OfficialRank, # ¹ÙÖ°´ïµ½ 6
UnlockWay_TravelCnt, # ÓÎÀú´ÎÊý 7
) = range(1, 1 + 7)
 
# Æ¤·ô½âËø·½Ê½
UnlockWaySkin_Default = 1 # Ä¬ÈϽâËø 1
UnlockWaySkin_Item = 2 # ÎïÆ·½âËø 2
 
# ºìÑÕЧ¹ûÀàÐÍ
(
EffType_BootyPer, # 1. Ö÷ÏßÕ½ÀûÆ·ÉÏÏÞÌá¸ß°Ù·Ö±È£¨¶ÔËùÓÐÖ÷ÏßÕ½ÀûÆ·ÉúЧ£©  Value:°Ù·Ö±È
EffType_ArenaItemEx, # 2. ÑÝÎ䳡ÌôսʤÀû£¬¸ÅÂʶîÍâ»ñµÃ1¸öÎïÆ·µÄ¸ÅÂÊ    TypeValue:ÎïÆ·ID  Value:¸ÅÂÊ
EffType_TravelEnergy, # 3.ÓÎÀúÌåÁ¦ÉÏÏÞÔö¼Ó     Value:Ôö¼ÓÉÏÏÞ
EffType_FBZhanchuiItemEx, # 4.°×¹ÇӯҰɨµ´¶îÍâÎïÆ·½±Àø      TypeValue:ÎïÆ·ID  Value:ÊýÁ¿
) = range(1, 1 + 4)
 
def OnPlayerLogin(curPlayer):
    SyncBeautyInfo(curPlayer)
    return
 
## Def_PDict_BeautyLVInfo ¾­Ñé*10000+µÈ¼¶*10+ÊÇ·ñÒѼ¤»î
def GetBeautyState(curPlayer, beautyID):
    ## ºìÑÕ¼¤»î״̬
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyLVInfo % beautyID) % 10
def SetBeautyState(curPlayer, beautyID, state):
    ## ÉèÖúìÑÕ¼¤»î״̬
    lvInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyLVInfo % beautyID)
    lvInfo = lvInfo / 10 * 10 + min(1, state)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautyLVInfo % beautyID, lvInfo)
    return lvInfo
def GetBeautyLVInfo(curPlayer, beautyID):
    ## »ñÈ¡ºìÑյȼ¶¾­Ñé
    lvInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyLVInfo % beautyID)
    exp = lvInfo / 10000
    lv = lvInfo % 10000 / 10
    return lv, exp
def SetBeautyLVInfo(curPlayer, beautyID, lv, exp):
    lvInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyLVInfo % beautyID)
    lvInfo = min(exp, 200000) * 10000 + min(lv, 999) * 10 + lvInfo % 10
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautyLVInfo % beautyID, lvInfo)
    return lvInfo
 
## Def_PDict_BeautySkinInfo ÐǼ¶*100+ÊÇ·ñʹÓÃ+ÊÇ·ñÒѼ¤»î
def GetBeautySkinState(curPlayer, skinID):
    ## ºìÑÕʱװ¼¤»î״̬
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID) % 10
def SetBeautySkinState(curPlayer, skinID, state):
    info = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID)
    info = info / 10 * 10 + min(1, state)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautySkinInfo % skinID, info)
    return info
def GetBeautySkinUsed(curPlayer, skinID):
    ## ÊÇ·ñʹÓÃÖÐ
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID) % 100 / 10
def SetBeautySkinUsed(curPlayer, skinID, isUsed):
    info = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID)
    info = info / 100 * 100 + min(1, isUsed) * 10 + info % 10
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautySkinInfo % skinID, info)
    return info
def GetBeautySkinStar(curPlayer, skinID):
    ## ºìÑÕʱװÐǼ¶
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID) / 100
def SetBeautySkinStar(curPlayer, skinID, star):
    info = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID)
    info = star * 100 + info % 100
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautySkinInfo % skinID, info)
    return info
 
def IsBeautySkinCanUse(curPlayer, beautyID, skinID, ipyData=None):
    ## ºìÑÕʱװÊÇ·ñ¿ÉÓÃ
    if GetBeautySkinState(curPlayer, skinID):
        return True
    
    if not ipyData:
        ipyData = GetBeautySkinIpyData(curPlayer, beautyID, skinID)
    if ipyData:
        unlockWay = ipyData.GetUnlockWay()
        if unlockWay == UnlockWaySkin_Default: # Ä¬Èϼ¤»îµÄ
            return True
        
    return False
 
#// B2 19 ºìÑÕ¼¤»î #tagCSBeautyActivate
#
#struct    tagCSBeautyActivate
#{
#    tagHead         Head;
#    WORD        BeautyID;    //ºìÑÕID
#};
def OnBeautyActivate(index, curPackData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    beautyID = curPackData.BeautyID
    
    if GetBeautyState(curPlayer, beautyID):
        GameWorld.DebugLog("ºìÑÕÒѾ­¼¤»î¹ý£¡ beautyID=%s" % beautyID, playerID)
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData("Beauty", beautyID)
    if not ipyData:
        return
    
    unlockWay = ipyData.GetUnlockWay()
    unlockValue = ipyData.GetUnlockValue()
    unlockNeedCnt = ipyData.GetUnlockNeedCnt()
    
    if unlockWay == UnlockWay_Item:
        needItemID = unlockValue
        needItemCnt = unlockNeedCnt
        itemCount = ItemControler.GetItemCountByID(curPlayer, needItemID)
        if itemCount < needItemCnt:
            GameWorld.DebugLog("¼¤»îºìÑÕÎïÆ·²»×ã! beautyID=%s,needItemID=%s,itemCount=%s < %s" % (beautyID, needItemID, itemCount, needItemCnt), playerID)
            return
        ItemControler.DelItemCountByID(curPlayer, needItemID, needItemCnt)
        
    elif unlockWay == UnlockWay_TaskID:
        taskID = unlockValue
        if not PlayerTask.IsTaskFinish(curPlayer, taskID):
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐèÈÎÎñδÍê³É! beautyID=%s,taskID=%s" % (beautyID, taskID), playerID)
            return
        
    elif unlockWay == UnlockWay_ArenaWinCnt:
        needWinCnt = unlockNeedCnt
        winCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ArenaWinCnt)
        if winCnt < needWinCnt:
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐèÑÝÎ䳡ʤÀû´ÎÊý²»×ã! beautyID=%s,winCnt=%s < %s" % (beautyID, winCnt, needWinCnt), playerID)
            return
        
    elif unlockWay == UnlockWay_GoldRushWorker:
        needWorkerCnt = unlockNeedCnt
        workerTotal = PlayerGoldRush.GetWorkerTotal(curPlayer)
        if workerTotal < needWorkerCnt:
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐè¼à¹¤²»×ã! beautyID=%s,workerTotal=%s < %s" % (beautyID, workerTotal, needWorkerCnt), playerID)
            return
        
    elif unlockWay == UnlockWay_FBZhanchui:
        mapID = ChConfig.Def_FBMapID_Zhanchui
        funcLineID = unlockValue
        isPass = FBCommon.IsFBPass(curPlayer, mapID, funcLineID)
        if not isPass:
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐ踱±¾Î´¹ý¹Ø! beautyID=%s,mapID=%s,funcLineID=%s" % (beautyID, mapID, funcLineID), playerID)
            return
        
    elif unlockWay == UnlockWay_OfficialRank:
        realmLV = curPlayer.GetOfficialRank()
        needRealmLV = unlockValue
        if realmLV < needRealmLV:
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐè¹ÙÖ°²»×ã! beautyID=%s,realmLV=%s < %s" % (beautyID, realmLV, needRealmLV), playerID)
            return
        
    elif unlockWay == UnlockWay_TravelCnt:
        travelCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TravelCnt)
        needTravelCnt = unlockNeedCnt
        if travelCnt < needTravelCnt:
            GameWorld.DebugLog("¼¤»îºìÑÕËùÐèÓÎÀú´ÎÊý²»×ã! beautyID=%s,travelCnt=%s < %s" % (beautyID, travelCnt, needTravelCnt), playerID)
            return
        
    else:
        GameWorld.DebugLog("¸ÃºìÑÕ²»Ö§³Ö¼¤»î! beautyID=%s,unlockWay=%s" % (beautyID, unlockWay), playerID)
        return
    
    DoBeautyActivate(curPlayer, beautyID)
    return
 
def DoBeautyActivate(curPlayer, beautyID):
    ## Ö´Ð줻îºìÑÕÂß¼­
    if GetBeautyState(curPlayer, beautyID):
        return
    lv, exp = 0, 0
    SetBeautyState(curPlayer, beautyID, 1)
    SetBeautyLVInfo(curPlayer, beautyID, lv, exp)
    GameWorld.DebugLog("ºìÑÕ¼¤»î³É¹¦£¡ beautyID=%s" % beautyID, curPlayer.GetPlayerID())
    RefreshBeautyAttr(curPlayer)
    SyncBeautyInfo(curPlayer, [beautyID])
    return
 
#// B2 20 ºìÑպøжÈÉý¼¶ #tagCSBeautyLVUP
#
#struct    tagCSBeautyLVUP
#{
#    tagHead         Head;
#    WORD        BeautyID;    //ºìÑÕID
#    DWORD        ItemID;        //ʹÓÃÎïÆ·ID
#    BYTE        IsQuick;        // ÊÇ·ñ¿ìËÙÉý¼¶£¬0-Ö»ÏûºÄ1¸öµÀ¾ß£»1-ÏûºÄÉý1¼¶µÄµÀ¾ß
#};
def OnBeautyLVUP(index, curPackData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    beautyID = curPackData.BeautyID
    itemID = curPackData.ItemID
    isQuick = curPackData.IsQuick
    
    if not GetBeautyState(curPlayer, beautyID):
        GameWorld.DebugLog("ºìÑÕδ¼¤»î£¡ beautyID=%s" % beautyID, playerID)
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData("Beauty", beautyID)
    if not ipyData:
        return
    quality = ipyData.GetBeautyQuality()
    curLV, curExp = GetBeautyLVInfo(curPlayer, beautyID)
    
    commItemIDList = IpyGameDataPY.GetFuncEvalCfg("BeautyLVUP", 1)
    commExpList = IpyGameDataPY.GetFuncEvalCfg("BeautyLVUP", 2)
    if itemID in commItemIDList:
        index = commItemIDList.index(itemID)
        perExp = commExpList[index] if len(commExpList) > index else 0
    else:
        exclusiveItemID = ipyData.GetExclusiveItemID()
        if itemID != exclusiveItemID:
            GameWorld.DebugLog("·Ç¸ÃºìÑÕרÊôÐÅÎïID£¡ beautyID=%s,itemID=%s != %s" % (beautyID, itemID, exclusiveItemID), playerID)
            return
        perExp = IpyGameDataPY.GetFuncCfg("BeautyLVUP", 3)
        
    if perExp <= 0:
        return
    
    nextLV = curLV + 1
    nextLVIpyData = IpyGameDataPY.GetIpyGameData("BeautyQualityLV", quality, nextLV)
    if not nextLVIpyData:
        GameWorld.DebugLog("ºìÑÕÒÑÂú¼¶£¡ beautyID=%s,quality=%s,curLV=%s" % (beautyID, quality, curLV), playerID)
        return
    lvNeedExp = nextLVIpyData.GetLVNeedExp()
    
    costItemCount = 0
    needExp = lvNeedExp - curExp # Éý¼¶»¹Ðè¾­Ñé
    if needExp > 0:
        if isQuick:
            costItemCount = needExp / perExp
            if needExp % perExp > 0:
                costItemCount += 1
        else:
            costItemCount = 1
            
        if costItemCount < 1:
            return
        
        costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, itemID, costItemCount)
        lackCnt = costItemCount - bindCnt - unBindCnt
        if lackCnt > 0:
            costItemCount -= lackCnt
            GameWorld.DebugLog("ÏûºÄµÀ¾ß²»×㣬ÓжàÉÙÏûºÄ¶àÉÙ! itemID=%s,costItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" 
                               % (itemID, costItemCount, bindCnt, unBindCnt, lackCnt))
        # ¿Û³ýÏûºÄ
        if costItemCount > 0:
            ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, "Beauty")
            
    addExp = costItemCount * perExp
    updExp = curExp + addExp
    GameWorld.DebugLog("ºìÑÕ¼Ó¾­Ñé: beautyID=%s,quality=%s,curLV=%s,curExp=%s,addExp=%s,updExp=%s/%s,itemID=%s,costItemCount=%s,perExp=%s" 
                       % (beautyID, quality, curLV, curExp, addExp, updExp, lvNeedExp, itemID, costItemCount, perExp))
    
    updLV = curLV
    if updExp >= lvNeedExp:
        updExp -= lvNeedExp
        updLV += 1
        GameWorld.DebugLog("    Éý¼¶: updLV=%s,updExp=%s" % (updLV, updExp))
        
    SetBeautyLVInfo(curPlayer, beautyID, updLV, updExp)
    
    SyncBeautyInfo(curPlayer, [beautyID])
    
    # ÓÐÉý¼¶¶îÍâ´¦Àí
    if updLV > updLV:
        RefreshBeautyAttr(curPlayer)
        
    return
 
def GetBeautyLVAward(curPlayer, beautyID):
    ## ÁìÈ¡ºìÑյȼ¶½±Àø
    if not GetBeautyState(curPlayer, beautyID):
        GameWorld.DebugLog("ºìÑÕδ¼¤»î£¡ beautyID=%s" % beautyID)
        return
    
    ipyData = IpyGameDataPY.GetIpyGameData("Beauty", beautyID)
    if not ipyData:
        return
    quality = ipyData.GetBeautyQuality()
    
    curLV = GetBeautyLVInfo(curPlayer, beautyID)[0]
    awardLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyAwardLV % beautyID)
    if awardLV >= curLV:
        GameWorld.DebugLog("µ±Ç°Ã»ÓкìÑյȼ¶½±Àø¿ÉÁìÈ¡£¡ beautyID=%s,quality=%s,awardLV=%s >= curLV=%s" % (beautyID, quality, awardLV, curLV))
        return
    GameWorld.DebugLog("ÁìÈ¡ºìÑյȼ¶½±Àø: beautyID=%s,quality=%s,curLV=%s,awardLV=%s" % (beautyID, quality, curLV, awardLV))
    
    updAwardLV = awardLV
    itemDict = {}
    for getLV in range(awardLV + 1, curLV + 1):
        lvIpyData = IpyGameDataPY.GetIpyGameData("BeautyQualityLV", quality, getLV)
        if not lvIpyData:
            break
        itemList = lvIpyData.GetAwardItemList()
        for itemInfo in itemList:
            itemID = itemInfo[0]
            itemCount = itemInfo[1]
            itemDict[itemID] = itemDict.get(itemID, 0) + itemCount
        updAwardLV = getLV
        
    if not itemDict:
        return
    awardItemList = [[itemID, itemCount] for itemID, itemCount in itemDict.items()]
    GameWorld.DebugLog("    updAwardLV=%s,awardItemList=%s" % (updAwardLV, awardItemList))
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_BeautyAwardLV % beautyID, updAwardLV)
    SyncBeautyInfo(curPlayer, [beautyID])
    ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["BeautyLVAward", False, {}])
    return
 
#// B2 21 ºìÑÕʱװ²Ù×÷ #tagCSBeautySkinOP
#
#struct    tagCSBeautySkinOP
#{
#    tagHead         Head;
#    WORD        BeautyID;    //ºìÑÕID
#    WORD        SkinID;        //ʱװID
#    BYTE        OPType;        //²Ù×÷ 1-¼¤»î£»2-Åå´÷£»3-ÉýÐÇ
#};
def OnBeautySkinOP(index, curPackData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    beautyID = curPackData.BeautyID
    skinID = curPackData.SkinID
    opType = curPackData.OPType
    
    if not GetBeautyState(curPlayer, beautyID):
        GameWorld.DebugLog("ºìÑÕδ¼¤»î£¡ beautyID=%s" % beautyID, playerID)
        return
    
    if opType == 1:
        OnBeautySkinActivate(curPlayer, beautyID, skinID)
    elif opType == 2:
        OnUseBeautySkin(curPlayer, beautyID, skinID)
    elif opType == 3:
        OnBeautySkinStarUP(curPlayer, beautyID, skinID)
    return
 
def GetBeautySkinIpyData(curPlayer, beautyID, skinID):
    ipyDataList = IpyGameDataPY.GetIpyGameDataList("BeautySkin", beautyID)
    if not ipyDataList:
        return
    for ipyData in ipyDataList:
        if ipyData.GetSkinID() == skinID:
            return ipyData
    return
 
def OnBeautySkinActivate(curPlayer, beautyID, skinID):
    ## ºìÑÕʱװ¼¤»î
    if GetBeautySkinState(curPlayer, skinID):
        GameWorld.DebugLog("ºìÑÕÆ¤·ôÒѼ¤»î! beautyID=%s,skinID=%s" % (beautyID, skinID))
        return
    
    ipyData = GetBeautySkinIpyData(curPlayer, beautyID, skinID)
    if not ipyData:
        return
    unlockWay = ipyData.GetUnlockWay()
    unlockValue = ipyData.GetUnlockValue()
    unlockNeedCnt = ipyData.GetUnlockNeedCnt()
    
    if unlockWay == UnlockWaySkin_Item:
        needItemID = unlockValue
        needItemCnt = unlockNeedCnt
        itemCount = ItemControler.GetItemCountByID(curPlayer, needItemID)
        if itemCount < needItemCnt:
            GameWorld.DebugLog("¼¤»îºìÑÕʱװÎïÆ·²»×ã! beautyID=%s,needItemID=%s,itemCount=%s < %s" % (beautyID, needItemID, itemCount, needItemCnt))
            return
        ItemControler.DelItemCountByID(curPlayer, needItemID, needItemCnt)
        
    else:
        GameWorld.DebugLog("ºìÑÕÆ¤·ô²»ÐèÒª¼¤»î! beautyID=%s,skinID=%s" % (beautyID, skinID))
        return
    
    SetBeautySkinState(curPlayer, skinID, 1)
    GameWorld.DebugLog("ºìÑÕÆ¤·ô¼¤»î: beautyID=%s,skinID=%s" % (beautyID, skinID))
    RefreshBeautyAttr(curPlayer)
    SyncBeautyInfo(curPlayer, [beautyID], [skinID])
    return
 
def OnUseBeautySkin(curPlayer, beautyID, skinID):
    playerID = curPlayer.GetPlayerID()
    if not IsBeautySkinCanUse(curPlayer, beautyID, skinID):
        GameWorld.DebugLog("¸ÃºìÑÕʱװ²»¿ÉÓÃ! beautyID=%s,skinID=%s" % (beautyID, skinID), playerID)
        return
    GameWorld.DebugLog("´©´÷ ºìÑÕʱװ! beautyID=%s,skinID=%s" % (beautyID, skinID), playerID)
    ipyDataList = IpyGameDataPY.GetIpyGameDataList("BeautySkin", beautyID)
    if not ipyDataList:
        return
    skinIDList = []
    for ipyData in ipyDataList:
        ipySkinID = ipyData.GetSkinID()
        if ipySkinID == skinID:
            SetBeautySkinUsed(curPlayer, skinID, 1)
        elif GetBeautySkinUsed(curPlayer, ipySkinID):
            SetBeautySkinUsed(curPlayer, ipySkinID, 0)
        else:
            continue
        skinIDList.append(ipySkinID)
    SyncBeautyInfo(curPlayer, [beautyID], skinIDList)
    return
 
def OnBeautySkinStarUP(curPlayer, beautyID, skinID):
    playerID = curPlayer.GetPlayerID()
    if not IsBeautySkinCanUse(curPlayer, beautyID, skinID):
        GameWorld.DebugLog("¸ÃºìÑÕʱװ²»¿ÉÓÃ! beautyID=%s,skinID=%s" % (beautyID, skinID), playerID)
        return
    ipyData = GetBeautySkinIpyData(curPlayer, beautyID, skinID)
    if not ipyData:
        return
    starMax = ipyData.GetStarMax()
    curStar = GetBeautySkinStar(curPlayer, skinID)
    if curStar >= starMax:
        GameWorld.DebugLog("ºìÑÕʱװÐǼ¶ÒÑÂú! skinID=%s,curStar=%s >= %s" % (skinID, curStar, starMax), playerID)
        return
    if ipyData.GetUnlockWay() != UnlockWaySkin_Item:
        return
    needItemID = ipyData.GetUnlockValue()
    needItemCnt = ipyData.GetUpNeedCnt()
    if not needItemID or not needItemCnt:
        return
    itemCount = ItemControler.GetItemCountByID(curPlayer, needItemID)
    if itemCount < needItemCnt:
        GameWorld.DebugLog("ºìÑÕʱװÉýÐÇÎïÆ·²»×ã! skinID=%s,needItemID=%s,itemCount=%s < %s" % (skinID, needItemID, itemCount, needItemCnt))
        return
    ItemControler.DelItemCountByID(curPlayer, needItemID, needItemCnt)
    
    nextStar = curStar + 1
    GameWorld.DebugLog("ºìÑÕʱװÉýÐÇ! skinID=%s,nextStar=%s" % (skinID, nextStar), playerID)
    SetBeautySkinStar(curPlayer, skinID, nextStar)
    RefreshBeautyAttr(curPlayer)
    SyncBeautyInfo(curPlayer, [beautyID], [skinID])
    return
 
def RefreshBeautyAttr(curPlayer):
    CalcBeautyAttr(curPlayer)
    PlayerOnline.GetOnlinePlayer(curPlayer).RefreshRoleAttr()
    return
 
def CalcBeautyAttr(curPlayer):
    
    playerID = curPlayer.GetPlayerID()
    attrDict = {}
    effTypeDict = {} # ÌØÊâЧ¹û»º´æ
    
    talentLVUPPer = IpyGameDataPY.GetFuncCfg("BeautyLVUP", 4) # Ã¿x¼¶ºÃ¸Ð¶ÈÌáÉýÒ»¼¶Ì츳Ч¹û
    
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for index in range(ipyDataMgr.GetBeautyCount()):
        ipyData = ipyDataMgr.GetBeautyByIndex(index)
        beautyID = ipyData.GetBeautyID()
        if not GetBeautyState(curPlayer, beautyID):
            continue
        quality = ipyData.GetBeautyQuality()
        beautyLV = GetBeautyLVInfo(curPlayer, beautyID)[0]
        # µÈ¼¶ÊôÐÔ
        for lv in range(beautyLV + 1):
            lvIpyData = IpyGameDataPY.GetIpyGameData("BeautyQualityLV", quality, lv)
            if not lvIpyData:
                continue
            lvAttrIDList = lvIpyData.GetAttrIDList()
            lvAttrValueList = lvIpyData.GetAttrValueList()
            for lvIndex, attrID in enumerate(lvAttrIDList):
                attrValue = lvAttrValueList[lvIndex] if len(lvAttrValueList) > lvIndex else 0
                attrDict[attrID] = attrDict.get(attrID, 0) + attrValue
        #GameWorld.DebugLog("ºìÑյȼ¶ÊôÐÔ: beautyID=%s,quality=%s,beautyLV=%s,%s" % (beautyID, quality, beautyLV, attrDict), playerID)
        
        # Ì츳ÊôÐÔ
        talentAttrIDList = ipyData.GetTalentAttrIDList()
        talentAttrValueList = ipyData.GetTalentAttrValueList()
        talentPerLVAddList = ipyData.GetTalentPerLVAddList()
        talentLV = beautyLV / talentLVUPPer
        for tIndex, attrID in enumerate(talentAttrIDList):
            initValue = talentAttrValueList[tIndex] if len(talentAttrValueList) > tIndex else 0
            perLVAdd = talentPerLVAddList[tIndex] if len(talentPerLVAddList) > tIndex else 0
            attrValue = initValue + perLVAdd * talentLV
            attrDict[attrID] = attrDict.get(attrID, 0) + attrValue
        #GameWorld.DebugLog("ºìÑÕÌ츳ÊôÐÔ: beautyID=%s,talentLV=%s,%s" % (beautyID, talentLV, attrDict), playerID)
        
        # ÌØÊâЧ¹û
        effType = ipyData.GetEffType()
        effTypeValue = ipyData.GetEffTypeValue()
        effValue = ipyData.GetEffValue()
        effPerLVAdd = ipyData.GetEffPerLVAdd()
        if effType:
            effValue = effValue + effPerLVAdd * talentLV
            effTypeDict[effType] = [effValue, effTypeValue]
            #GameWorld.DebugLog("ºìÑÕÌØÊâЧ¹û: beautyID=%s,effType=%s,talentLV=%s,%s" % (beautyID, effType, talentLV, effTypeDict), playerID)
            
        # Ê±×°
        ipyDataList = IpyGameDataPY.GetIpyGameDataList("BeautySkin", beautyID)
        if not ipyDataList:
            continue
        for skinIpyData in ipyDataList:
            skinID = skinIpyData.GetSkinID()
            if not IsBeautySkinCanUse(curPlayer, beautyID, skinID, skinIpyData):
                continue
            
            attrIDList = skinIpyData.GetAttrIDList()
            initAttrValueList = skinIpyData.GetInitAttrValueList()
            perStarAddList = skinIpyData.GetAttrPerStarAddList()
            star = GetBeautySkinStar(curPlayer, skinID)
            for sIndex, attrID in enumerate(attrIDList):
                initValue = initAttrValueList[sIndex] if len(initAttrValueList) > sIndex else 0
                perStarAdd = perStarAddList[sIndex] if len(perStarAddList) > sIndex else 0
                attrValue = initValue + perStarAdd * star
                attrDict[attrID] = attrDict.get(attrID, 0) + attrValue
            #GameWorld.DebugLog("ºìÑÕʱװÊôÐÔ: beautyID=%s,skinID=%s,star=%s,%s" % (beautyID, skinID, star, attrDict), playerID)
            
    # ±£´æ¼ÆËãÖµ
    GameWorld.DebugLog("ºìÑÕÊôÐÔ: %s" % attrDict, playerID)
    GameWorld.DebugLog("ºìÑÕЧ¹û: %s" % effTypeDict, playerID)
    PyGameData.g_beautyEffTypeDict[playerID] = effTypeDict
    PlayerOnline.GetOnlinePlayer(curPlayer).SetCalcAttr(ChConfig.Def_CalcAttr_Beauty, attrDict)
    return
 
def GetBeautyEffInfo(curPlayer, effType):
    ## »ñÈ¡ºìÑÕÌØÊâЧ¹ûÐÅÏ¢
    # @return: effValue, effTypeValue
    effTypeDict = PyGameData.g_beautyEffTypeDict.get(curPlayer.GetPlayerID(), {})
    return effTypeDict.get(effType, [0, 0])
 
def SyncBeautyInfo(curPlayer, beautyIDList=None, skinIDList=None):
    if beautyIDList == None:
        syncBeautyIDList = []
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for index in range(ipyDataMgr.GetBeautyCount()):
            ipyData = ipyDataMgr.GetBeautyByIndex(index)
            syncBeautyIDList.append(ipyData.GetBeautyID())
    else:
        syncBeautyIDList = beautyIDList
        
    beautyList = []
    for beautyID in syncBeautyIDList:
        state = GetBeautyState(curPlayer, beautyID)
        if not state and beautyIDList == None:
            continue
        lv, exp = GetBeautyLVInfo(curPlayer, beautyID)
        beauty = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCBeauty)
        beauty.BeautyID = beautyID
        beauty.State = state
        beauty.LV = lv
        beauty.Exp = exp
        beauty.AwardLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautyAwardLV % beautyID)
        
        beauty.SkinList = []
        ipyDataList = IpyGameDataPY.GetIpyGameDataList("BeautySkin", beautyID)
        if ipyDataList:
            for ipyData in ipyDataList:
                skinID = ipyData.GetSkinID()
                skinInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BeautySkinInfo % skinID)
                if skinIDList != None:
                    if skinID not in skinIDList:
                        continue
                else:
                    if not skinInfo:
                        continue
                beautySkin = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCBeautySkin)
                beautySkin.SkinID = skinID
                beautySkin.State = 1 if IsBeautySkinCanUse(curPlayer, beautyID, skinID, ipyData) else 0
                beautySkin.Used = GetBeautySkinUsed(curPlayer, skinID)
                beautySkin.Star = GetBeautySkinStar(curPlayer, skinID)
                beauty.SkinList.append(beautySkin)
        beauty.SkinCnt = len(beauty.SkinList)
        
        beautyList.append(beauty)
        
    if not beautyList:
        return
    
    clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCBeautyInfo)
    clientPack.BeautyList = beautyList
    clientPack.Count = len(clientPack.BeautyList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return