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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerCharm
#
# @todo:÷ÈÁ¦
# @author hxp
# @date 2021-12-03
# @version 1.0
#
# ÏêϸÃèÊö: ÷ÈÁ¦
#
#-------------------------------------------------------------------------------
#"""Version = 2021-12-03 19:00"""
#-------------------------------------------------------------------------------
 
import ChConfig
import PlayerControl
import IpyGameDataPY
import ItemControler
import GameWorld
 
def OnPlayerLogin(curPlayer):
    
    # ÖØÐÂÉèÖ㬴¥·¢ÉÏÏß֪ͨ
    if PlayerControl.GetCharmLV(curPlayer):
        PlayerControl.SetCharmLV(curPlayer, PlayerControl.GetCharmLV(curPlayer))
        
    return
 
def GameServer_DoLogic_Charm(curPlayer, msgData):
    
    msgType = msgData[0]
    
    ## ÷ÈÁ¦µÈ¼¶ÌáÉý
    if msgType == "CharmLVUp":
        totalCharm = msgData[1]
        __DoCharmLVUp(curPlayer, totalCharm)
        
    return
 
def __DoCharmLVUp(curPlayer, totalCharm):
    
    playerID = curPlayer.GetPlayerID()
    charmLV = PlayerControl.GetCharmLV(curPlayer)
    ipyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
    if not ipyData:
        return
    
    if not ipyData.GetUpNeedCharm():
        GameWorld.DebugLog("÷ÈÁ¦µÈ¼¶ÒÑÂú¼¶£¬ÎÞ·¨Éý¼¶! charmLV=%s" % charmLV, playerID)
        return
    
    if totalCharm < ipyData.GetUpNeedCharm():
        GameWorld.DebugLog("÷ÈÁ¦Öµ²»×㣬ÎÞ·¨Éý¼¶! totalCharm=%s < %s, charmLV=%s" % (totalCharm, ipyData.GetUpNeedCharm(), charmLV), playerID)
        return
    
    charmLV += 1
    nextLVIpyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
    if not nextLVIpyData:
        return
    awardItemList = nextLVIpyData.GetLVAwardItemInfo()
    GameWorld.DebugLog("÷ÈÁ¦µÈ¼¶Éý¼¶! charmLV=%s" % charmLV, playerID)
    PlayerControl.SetCharmLV(curPlayer, charmLV)
    ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList)
    RefreshCharmAttr(curPlayer)
    return
 
def RefreshCharmAttr(curPlayer):
    CalcCharmAttr(curPlayer)
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    return
 
def CalcCharmAttr(curPlayer):
    
    allAttrList = [{} for _ in range(4)]
    
    charmLV = PlayerControl.GetCharmLV(curPlayer)
    
    ipyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
    if ipyData:
        lvAttrTypeList = ipyData.GetLVAttrType()
        lvAttrValueList = ipyData.GetLVAttrValue()
        for i, attrID in enumerate(lvAttrTypeList):
            attrValue = lvAttrValueList[i]
            PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
            
    # ±£´æ¼ÆËãÖµ
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Charm, allAttrList)
    return